fix(penawaran): perbaiki pengolahan email kantor
- Mengubah struktur penyimpanan email dari array menjadi Set untuk menghindari duplikasi. - Memastikan semua email dari detail_email_kantor ditambahkan dengan benar. - Mengonversi Set kembali menjadi array sebelum validasi email.
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
email_kantor: {
|
email_kantor: {
|
||||||
title: 'Email Kantor',
|
title: 'Email Kantor',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
let emails = [data.kjpp.email_kantor]; // Always include the main email
|
let emails = new Set([data.kjpp.email_kantor]); // Always include the main email
|
||||||
|
|
||||||
// Check if there's a detail_email_kantor and try to parse it
|
// Check if there's a detail_email_kantor and try to parse it
|
||||||
if (data.kjpp.detail_email_kantor) {
|
if (data.kjpp.detail_email_kantor) {
|
||||||
@@ -56,15 +56,12 @@
|
|||||||
// If the parsed result is an array, extract emails from each object and concatenate
|
// If the parsed result is an array, extract emails from each object and concatenate
|
||||||
if (Array.isArray(detailEmails)) {
|
if (Array.isArray(detailEmails)) {
|
||||||
detailEmails.forEach(item => {
|
detailEmails.forEach(item => {
|
||||||
if (item.email_kantor) {
|
emails.add(item);
|
||||||
emails.push(item
|
|
||||||
.email_kantor); // Add the email from each object
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// If it's a single object (not an array), just add the email
|
// If it's a single object (not an array), just add the email
|
||||||
if (detailEmails.email_kantor) {
|
if (detailEmails) {
|
||||||
emails.push(detailEmails.email_kantor);
|
emails.add(detailEmails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -74,6 +71,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emails = Array.from(emails);
|
||||||
|
|
||||||
// Helper function for basic email validation (regex pattern)
|
// Helper function for basic email validation (regex pattern)
|
||||||
const isValidEmail = (email) => {
|
const isValidEmail = (email) => {
|
||||||
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||||||
|
|||||||
Reference in New Issue
Block a user