diff --git a/src/app/(main)/settings/customer/create/page.tsx b/src/app/(main)/settings/customer/create/page.tsx index c4f13b4..e0dc0e0 100644 --- a/src/app/(main)/settings/customer/create/page.tsx +++ b/src/app/(main)/settings/customer/create/page.tsx @@ -6,7 +6,7 @@ import Typography from "@mui/material/Typography"; import { Metadata } from "next"; export const metadata: Metadata = { - title: "Create Customer", + title: "Create Client", }; const CreateCustomer: React.FC = async () => { diff --git a/src/app/api/staff/actions.ts b/src/app/api/staff/actions.ts index 8eb5ff3..1098508 100644 --- a/src/app/api/staff/actions.ts +++ b/src/app/api/staff/actions.ts @@ -19,7 +19,7 @@ export interface CreateStaffInputs { companyId: number; gradeId: number; teamId: number; - salaryEffId: number; + salaryId: number; email: string; phone1: string; phone2: string; diff --git a/src/components/CreateStaff/CreateStaff.tsx b/src/components/CreateStaff/CreateStaff.tsx index 0aed5ab..35b8ded 100644 --- a/src/components/CreateStaff/CreateStaff.tsx +++ b/src/components/CreateStaff/CreateStaff.tsx @@ -179,7 +179,7 @@ const CreateStaff: React.FC = ({ Title }) => { label: t("Team"), type: "combo-Obj", options: teamCombo, - required: true, + required: false, }, { id: "departmentId", @@ -193,14 +193,14 @@ const CreateStaff: React.FC = ({ Title }) => { label: t("Grade"), type: "combo-Obj", options: gradeCombo, - required: true, + required: false, }, { id: "skillSetId", label: t("Skillset"), type: "combo-Obj", options: skillCombo, - required: true, + required: false, }, { id: "currentPositionId", @@ -210,19 +210,19 @@ const CreateStaff: React.FC = ({ Title }) => { required: true, }, { - id: "salaryEffId", + id: "salaryId", label: t("Salary Point"), type: "combo-Obj", options: salaryCombo, required: true, }, - { - id: "hourlyRate", - label: t("Hourly Rate"), - type: "numeric-testing", - value: "", - required: true, - }, + // { + // id: "hourlyRate", + // label: t("Hourly Rate"), + // type: "numeric-testing", + // value: "", + // required: false, + // }, { id: "employType", label: t("Employ Type"), @@ -245,7 +245,7 @@ const CreateStaff: React.FC = ({ Title }) => { label: t("Phone1"), type: "text", value: "", - pattern: "^\\d{8}$", + // pattern: "^\\d{8}$", message: t("input correct phone no."), required: true, }, @@ -254,9 +254,9 @@ const CreateStaff: React.FC = ({ Title }) => { label: t("Phone2"), type: "text", value: "", - pattern: "^\\d{8}$", + // pattern: "^\\d{8}$", message: t("input correct phone no."), - required: true, + required: false, }, ], [ @@ -272,7 +272,7 @@ const CreateStaff: React.FC = ({ Title }) => { label: t("Emergency Contact Phone"), type: "text", value: "", - pattern: "^\\d{8}$", + // pattern: "^\\d{8}$", message: t("input correct phone no."), required: true, }, diff --git a/src/components/CustomInputForm/CustomInputForm.tsx b/src/components/CustomInputForm/CustomInputForm.tsx index ffcaa7a..dc7f269 100644 --- a/src/components/CustomInputForm/CustomInputForm.tsx +++ b/src/components/CustomInputForm/CustomInputForm.tsx @@ -274,7 +274,7 @@ const CustomInputForm: React.FC = ({ fullWidth {...register(field.id, { pattern: - /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/, + /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/, })} defaultValue={!field.value ? `${field.value}` : ""} required={field.required ?? false} diff --git a/src/components/CustomerDetail/ContactInfo.tsx b/src/components/CustomerDetail/ContactInfo.tsx index 9566264..f608b00 100644 --- a/src/components/CustomerDetail/ContactInfo.tsx +++ b/src/components/CustomerDetail/ContactInfo.tsx @@ -231,7 +231,7 @@ const ContactInfo: React.FC = ({ if (errorRows.length > 0) { setError("addContacts", { message: "Contact details include empty fields", type: "required" }) } else { - const errorRows_EmailFormat = rows.filter(row => !/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/.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))) if (errorRows_EmailFormat.length > 0) { setError("addContacts", { message: "Contact details include empty fields", type: "email_format" }) } else { diff --git a/src/components/CustomerDetail/CustomerDetail.tsx b/src/components/CustomerDetail/CustomerDetail.tsx index 2c81e17..88a99ad 100644 --- a/src/components/CustomerDetail/CustomerDetail.tsx +++ b/src/components/CustomerDetail/CustomerDetail.tsx @@ -167,7 +167,7 @@ const CustomerDetail: React.FC = ({ formProps.setError("code", { message: "Code is empty", type: "required" }) } - // if (data.email && data.email?.length > 0 && !/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/.test(data.email)) { + // if (data.email && data.email?.length > 0 && !/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.test(data.email)) { // haveError = true // formProps.setError("email", { message: "Email format is not valid", type: "custom" }) // } @@ -182,7 +182,7 @@ const CustomerDetail: React.FC = ({ formProps.setError("addContacts", { message: "Contact info includes empty fields", type: "required" }) } - if (data.addContacts.length > 0 && data.addContacts.filter(row => !/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/.test(String(row.email))).length > 0) { + 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) { haveError = true formProps.setError("addContacts", { message: "Contact info includes invalid email", type: "email_format" }) } diff --git a/src/components/CustomerDetail/CustomerInfo.tsx b/src/components/CustomerDetail/CustomerInfo.tsx index 695f6d5..3eaa327 100644 --- a/src/components/CustomerDetail/CustomerInfo.tsx +++ b/src/components/CustomerDetail/CustomerInfo.tsx @@ -107,7 +107,7 @@ const CustomerInfo: React.FC = ({ label={t("Customer Email")} fullWidth {...register("email", { - pattern: /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/, + pattern: /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/, })} error={Boolean(errors.email)} helperText={Boolean(errors.email) && t("Please input correct customer email")} diff --git a/src/components/EditStaff/EditStaff.tsx b/src/components/EditStaff/EditStaff.tsx index 02a3d04..76ebdc7 100644 --- a/src/components/EditStaff/EditStaff.tsx +++ b/src/components/EditStaff/EditStaff.tsx @@ -77,7 +77,7 @@ const EditStaff: React.FC = async () => { "grade", "skill", "currentPosition", - "salaryEffective", + "salary", "hourlyRate", "employType", "email", @@ -140,6 +140,7 @@ const EditStaff: React.FC = async () => { label: t(`Staff ID`), type: "text", value: data[key] ?? "", + required: true, }; case "name": return { @@ -179,7 +180,7 @@ const EditStaff: React.FC = async () => { label: t(`Grade`), type: "combo-Obj", options: gradeCombo, - value: data[key].id ?? "", + value: data[key] !== null ? data[key].id ?? "" : "", }; case "skill": return { @@ -187,7 +188,7 @@ const EditStaff: React.FC = async () => { label: t(`Skillset`), type: "combo-Obj", options: skillCombo, - value: data[key].id ?? "", + value: data[key] !== null ? data[key].id ?? "" : "", }; case "currentPosition": return { @@ -197,23 +198,23 @@ const EditStaff: React.FC = async () => { options: positionCombo, value: data[key].id ?? "", }; - case "salaryEffective": + case "salary": return { - id: `salaryEffId`, + id: `salaryId`, label: t(`Salary Point`), type: "combo-Obj", options: salaryCombo, - value: data[key].salary.id ?? "", - }; - case "hourlyRate": - return { - id: `${key}`, - label: t(`hourlyRate`), - type: "text", - value: "", - // value: data[key], - readOnly: true, + value: data[key] !== null ? data[key].id ?? "" : "", }; + // case "hourlyRate": + // return { + // id: `${key}`, + // label: t(`hourlyRate`), + // type: "text", + // value: "", + // // value: data[key], + // readOnly: true, + // }; case "employType": return { id: `${key}`, @@ -236,7 +237,7 @@ const EditStaff: React.FC = async () => { id: `${key}`, label: t(`Phone1`), type: "text", - pattern: "^\\d{8}$", + // pattern: "^\\d{8}$", message: t("input correct phone no."), value: data[key] ?? "", }; @@ -245,7 +246,7 @@ const EditStaff: React.FC = async () => { id: `${key}`, label: t(`Phone2`), type: "text", - pattern: "^\\d{8}$", + // pattern: "^\\d{8}$", message: t("input correct phone no."), value: data[key] ?? "", } as Field; @@ -269,7 +270,7 @@ const EditStaff: React.FC = async () => { id: `${key}`, label: t(`Emergency Contact Phonee`), type: "text", - pattern: "^\\d{8}$", + // pattern: "^\\d{8}$", message: t("input correct phone no."), value: data[key] ?? "", } as Field; diff --git a/src/components/SubsidiaryDetail/ContactInfo.tsx b/src/components/SubsidiaryDetail/ContactInfo.tsx index 9e2c16d..ef84ad7 100644 --- a/src/components/SubsidiaryDetail/ContactInfo.tsx +++ b/src/components/SubsidiaryDetail/ContactInfo.tsx @@ -231,7 +231,7 @@ const ContactInfo: React.FC = ({ if (errorRows.length > 0) { setError("addContacts", { message: "Contact details include empty fields", type: "required" }) } else { - const errorRows_EmailFormat = rows.filter(row => !/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/.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))) if (errorRows_EmailFormat.length > 0) { setError("addContacts", { message: "Contact details include empty fields", type: "email_format" }) diff --git a/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx b/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx index 339fd52..5f89570 100644 --- a/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx +++ b/src/components/SubsidiaryDetail/SubsidiaryDetail.tsx @@ -157,7 +157,7 @@ const SubsidiaryDetail: React.FC = ({ formProps.setError("addContacts", { message: "Contact info includes empty fields", type: "required" }) } - if (data.addContacts.length > 0 && data.addContacts.filter(row => !/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/.test(String(row.email))).length > 0) { + 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) { haveError = true formProps.setError("addContacts", { message: "Contact info includes invalid email", type: "email_format" }) } diff --git a/src/i18n/en/breadcrumb.json b/src/i18n/en/breadcrumb.json index 72bdcc8..5361966 100644 --- a/src/i18n/en/breadcrumb.json +++ b/src/i18n/en/breadcrumb.json @@ -1,6 +1,6 @@ { "Overview": "Overview", - "customer": "Customer", - "Create Customer": "Create Customer" + "customer": "Client", + "Create Customer": "Create Client" } \ No newline at end of file diff --git a/src/i18n/en/subsidiary.json b/src/i18n/en/subsidiary.json index d26d4e1..3c06c1c 100644 --- a/src/i18n/en/subsidiary.json +++ b/src/i18n/en/subsidiary.json @@ -15,8 +15,8 @@ "Customer Type": "Client Type", "Customer Allocation": "Client Allocation", "Search by customer code, name or br no.": "Search by client code, name or br no.", - "Client Pool": "Client Pool", - "Allocated Client": "Allocated Client", + "Customer Pool": "Client Pool", + "Allocated Customer": "Allocated Client", "Please input correct subsidiary code": "Please input correct client code", "Please input correct subsidiary name": "Please input correct client name",