diff --git a/src/components/CustomerSave/ContactInfo.tsx b/src/components/CustomerSave/ContactInfo.tsx index 983a6d6..14f070e 100644 --- a/src/components/CustomerSave/ContactInfo.tsx +++ b/src/components/CustomerSave/ContactInfo.tsx @@ -234,20 +234,20 @@ const ContactInfo: React.FC = ({ if (getValues("addContacts").length === 0) { clearErrors("addContacts") } else { - const errorRows = rows.filter(row => String(row.name).trim().length === 0 || String(row.phone).trim().length === 0 || String(row.email).trim().length === 0) + const errorRows = rows.filter(row => String(row.name).trim().length === 0) if (errorRows.length > 0) { setError("addContacts", { message: "Contact details include empty fields", type: "required" }) } else { - const errorRows_EmailFormat = rows.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))) + // const errorRows_EmailFormat = rows.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))) - const errorRows_PhoneFormat = rows.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))) + // const errorRows_PhoneFormat = rows.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))) - if (errorRows_EmailFormat.length > 0 || errorRows_PhoneFormat.length > 0) { - setError("addContacts", { message: "Contact details include empty fields", type: "format" }) - } else { + // if (errorRows_EmailFormat.length > 0 || errorRows_PhoneFormat.length > 0) { + // setError("addContacts", { message: "Contact details include empty fields", type: "format" }) + // } else { clearErrors("addContacts") - } + // } } } }, [rows, rowModesModel]) @@ -273,7 +273,7 @@ const ContactInfo: React.FC = ({ {t("Contact Info")} {Boolean(errors.addContacts?.type === "required") && ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap> - {t("Please ensure at least one row is created, and all the fields are inputted and saved")} + {t("Please ensure at least one row is created, and all the 'Contact Name' fields are inputted and saved")} } {Boolean(errors.addContacts?.type === "format") && ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap> {t("Please ensure all the email and phone formats are correct")} diff --git a/src/components/CustomerSave/CustomerSave.tsx b/src/components/CustomerSave/CustomerSave.tsx index 13ebcfc..dc5d6b6 100644 --- a/src/components/CustomerSave/CustomerSave.tsx +++ b/src/components/CustomerSave/CustomerSave.tsx @@ -177,17 +177,17 @@ const CustomerSave: React.FC = ({ formProps.setError("brNo", { message: "Br No. format is not valid", type: "custom" }) } - if (data.addContacts.length === 0 || data.addContacts.filter(row => String(row.name).trim().length === 0 || String(row.phone).trim().length === 0 || String(row.email).trim().length === 0).length > 0) { + if (data.addContacts.length === 0 || data.addContacts.filter(row => String(row.name).trim().length === 0).length > 0) { haveError = true formProps.setError("addContacts", { message: "Contact info includes empty fields", type: "required" }) } - if (data.addContacts.length > 0 - && data.addContacts.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))).length > 0 - && data.addContacts.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))).length > 0) { - haveError = true - formProps.setError("addContacts", { message: "Contact info includes invalid email or phone", type: "format" }) - } + // if (data.addContacts.length > 0 + // && data.addContacts.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))).length > 0 + // && data.addContacts.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))).length > 0) { + // haveError = true + // formProps.setError("addContacts", { message: "Contact info includes invalid email or phone", type: "format" }) + // } if (haveError) { // go to the error tab diff --git a/src/components/SubsidiaryDetail/ContactInfo.tsx b/src/components/SubsidiaryDetail/ContactInfo.tsx index 68797c0..0908060 100644 --- a/src/components/SubsidiaryDetail/ContactInfo.tsx +++ b/src/components/SubsidiaryDetail/ContactInfo.tsx @@ -226,20 +226,20 @@ const ContactInfo: React.FC = ({ if (getValues("addContacts").length === 0) { clearErrors("addContacts") } else { - const errorRows = rows.filter(row => String(row.name).trim().length === 0 || String(row.phone).trim().length === 0 || String(row.email).trim().length === 0) + const errorRows = rows.filter(row => String(row.name).trim().length === 0) if (errorRows.length > 0) { setError("addContacts", { message: "Contact details include empty fields", type: "required" }) } else { - const errorRows_EmailFormat = rows.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))) + // const errorRows_EmailFormat = rows.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))) - const errorRows_PhoneFormat = rows.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))) + // const errorRows_PhoneFormat = rows.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))) - if (errorRows_EmailFormat.length > 0 || errorRows_PhoneFormat.length > 0) { - setError("addContacts", { message: "Contact details include empty fields", type: "format" }) - } else { + // if (errorRows_EmailFormat.length > 0 || errorRows_PhoneFormat.length > 0) { + // setError("addContacts", { message: "Contact details include empty fields", type: "format" }) + // } else { clearErrors("addContacts") - } + // } } } }, [rows]) @@ -265,7 +265,7 @@ const ContactInfo: React.FC = ({ {t("Contact Info")} {Boolean(errors.addContacts?.type === "required") && ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap> - {t("Please ensure at least one row is created, and all the fields are inputted and saved")} + {t("Please ensure at least one row is created, and all the 'Contact Name' fields are inputted and saved")} } {Boolean(errors.addContacts?.type === "format") && ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap> {t("Please ensure all the email and phone formats are correct")} diff --git a/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx b/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx index 77b83c7..c96a67a 100644 --- a/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx +++ b/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx @@ -152,17 +152,17 @@ const SubsidiaryDetail: React.FC = ({ formProps.setError("brNo", { message: "Br No. format is not valid", type: "custom" }) } - if (data.addContacts.length === 0 || data.addContacts.filter(row => String(row.name).trim().length === 0 || String(row.phone).trim().length === 0 || String(row.email).trim().length === 0).length > 0) { + if (data.addContacts.length === 0 || data.addContacts.filter(row => String(row.name).trim().length === 0).length > 0) { haveError = true formProps.setError("addContacts", { message: "Contact info includes empty fields", type: "required" }) } - if (data.addContacts.length > 0 - && data.addContacts.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))).length > 0 - && data.addContacts.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))).length > 0) { - haveError = true - formProps.setError("addContacts", { message: "Contact info includes invalid email or phone", type: "format" }) - } + // if (data.addContacts.length > 0 + // && data.addContacts.filter(row => !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(String(row.email))).length > 0 + // && data.addContacts.filter(row => !/^[+0-9][0-9\s]*$/.test(String(row.phone))).length > 0) { + // haveError = true + // formProps.setError("addContacts", { message: "Contact info includes invalid email or phone", type: "format" }) + // } if (haveError) { // go to the error tab diff --git a/src/i18n/zh/customer.json b/src/i18n/zh/customer.json index 92947a0..31a61ac 100644 --- a/src/i18n/zh/customer.json +++ b/src/i18n/zh/customer.json @@ -43,7 +43,7 @@ "Contact Name": "聯絡姓名", "Contact Email": "聯絡電郵", "Contact Phone": "聯絡電話", - "Please ensure at least one row is created, and all the fields are inputted and saved": "請確保已建立至少一行, 及已輸入和儲存所有欄位", + "Please ensure at least one row is created, and all the 'Contact Name' fields are inputted and saved": "請確保已建立至少一行, 及已輸入和儲存所有聯絡姓名欄位", "Please ensure all the email and phone formats are correct": "請確保所有電郵和電話格式輸入正確", "Do you want to submit?": "你是否確認要提交?", diff --git a/src/i18n/zh/subsidiary.json b/src/i18n/zh/subsidiary.json index dc50dc5..aff8241 100644 --- a/src/i18n/zh/subsidiary.json +++ b/src/i18n/zh/subsidiary.json @@ -43,7 +43,7 @@ "Contact Name": "聯絡姓名", "Contact Email": "聯絡電郵", "Contact Phone": "聯絡電話", - "Please ensure at least one row is created, and all the fields are inputted and saved": "請確保已建立至少一行, 及已輸入和儲存所有欄位", + "Please ensure at least one row is created, and all the 'Contact Name' fields are inputted and saved": "請確保已建立至少一行, 及已輸入和儲存所有聯絡姓名欄位", "Please ensure all the email and phone formats are correct": "請確保所有電郵和電話格式輸入正確", "Do you want to submit?": "你是否確認要提交?",