| @@ -6,7 +6,7 @@ import Typography from "@mui/material/Typography"; | |||||
| import { Metadata } from "next"; | import { Metadata } from "next"; | ||||
| export const metadata: Metadata = { | export const metadata: Metadata = { | ||||
| title: "Create Customer", | |||||
| title: "Create Client", | |||||
| }; | }; | ||||
| const CreateCustomer: React.FC = async () => { | const CreateCustomer: React.FC = async () => { | ||||
| @@ -19,7 +19,7 @@ export interface CreateStaffInputs { | |||||
| companyId: number; | companyId: number; | ||||
| gradeId: number; | gradeId: number; | ||||
| teamId: number; | teamId: number; | ||||
| salaryEffId: number; | |||||
| salaryId: number; | |||||
| email: string; | email: string; | ||||
| phone1: string; | phone1: string; | ||||
| phone2: string; | phone2: string; | ||||
| @@ -179,7 +179,7 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||||
| label: t("Team"), | label: t("Team"), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: teamCombo, | options: teamCombo, | ||||
| required: true, | |||||
| required: false, | |||||
| }, | }, | ||||
| { | { | ||||
| id: "departmentId", | id: "departmentId", | ||||
| @@ -193,14 +193,14 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||||
| label: t("Grade"), | label: t("Grade"), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: gradeCombo, | options: gradeCombo, | ||||
| required: true, | |||||
| required: false, | |||||
| }, | }, | ||||
| { | { | ||||
| id: "skillSetId", | id: "skillSetId", | ||||
| label: t("Skillset"), | label: t("Skillset"), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: skillCombo, | options: skillCombo, | ||||
| required: true, | |||||
| required: false, | |||||
| }, | }, | ||||
| { | { | ||||
| id: "currentPositionId", | id: "currentPositionId", | ||||
| @@ -210,19 +210,19 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||||
| required: true, | required: true, | ||||
| }, | }, | ||||
| { | { | ||||
| id: "salaryEffId", | |||||
| id: "salaryId", | |||||
| label: t("Salary Point"), | label: t("Salary Point"), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: salaryCombo, | options: salaryCombo, | ||||
| required: true, | 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", | id: "employType", | ||||
| label: t("Employ Type"), | label: t("Employ Type"), | ||||
| @@ -245,7 +245,7 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||||
| label: t("Phone1"), | label: t("Phone1"), | ||||
| type: "text", | type: "text", | ||||
| value: "", | value: "", | ||||
| pattern: "^\\d{8}$", | |||||
| // pattern: "^\\d{8}$", | |||||
| message: t("input correct phone no."), | message: t("input correct phone no."), | ||||
| required: true, | required: true, | ||||
| }, | }, | ||||
| @@ -254,9 +254,9 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||||
| label: t("Phone2"), | label: t("Phone2"), | ||||
| type: "text", | type: "text", | ||||
| value: "", | value: "", | ||||
| pattern: "^\\d{8}$", | |||||
| // pattern: "^\\d{8}$", | |||||
| message: t("input correct phone no."), | message: t("input correct phone no."), | ||||
| required: true, | |||||
| required: false, | |||||
| }, | }, | ||||
| ], | ], | ||||
| [ | [ | ||||
| @@ -272,7 +272,7 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||||
| label: t("Emergency Contact Phone"), | label: t("Emergency Contact Phone"), | ||||
| type: "text", | type: "text", | ||||
| value: "", | value: "", | ||||
| pattern: "^\\d{8}$", | |||||
| // pattern: "^\\d{8}$", | |||||
| message: t("input correct phone no."), | message: t("input correct phone no."), | ||||
| required: true, | required: true, | ||||
| }, | }, | ||||
| @@ -274,7 +274,7 @@ const CustomInputForm: React.FC<CustomInputFormProps> = ({ | |||||
| fullWidth | fullWidth | ||||
| {...register(field.id, { | {...register(field.id, { | ||||
| pattern: | 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}` : ""} | defaultValue={!field.value ? `${field.value}` : ""} | ||||
| required={field.required ?? false} | required={field.required ?? false} | ||||
| @@ -231,7 +231,7 @@ const ContactInfo: React.FC<Props> = ({ | |||||
| if (errorRows.length > 0) { | if (errorRows.length > 0) { | ||||
| setError("addContacts", { message: "Contact details include empty fields", type: "required" }) | setError("addContacts", { message: "Contact details include empty fields", type: "required" }) | ||||
| } else { | } 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) { | if (errorRows_EmailFormat.length > 0) { | ||||
| setError("addContacts", { message: "Contact details include empty fields", type: "email_format" }) | setError("addContacts", { message: "Contact details include empty fields", type: "email_format" }) | ||||
| } else { | } else { | ||||
| @@ -167,7 +167,7 @@ const CustomerDetail: React.FC<Props> = ({ | |||||
| formProps.setError("code", { message: "Code is empty", type: "required" }) | 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 | // haveError = true | ||||
| // formProps.setError("email", { message: "Email format is not valid", type: "custom" }) | // formProps.setError("email", { message: "Email format is not valid", type: "custom" }) | ||||
| // } | // } | ||||
| @@ -182,7 +182,7 @@ const CustomerDetail: React.FC<Props> = ({ | |||||
| formProps.setError("addContacts", { message: "Contact info includes empty fields", type: "required" }) | 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 | haveError = true | ||||
| formProps.setError("addContacts", { message: "Contact info includes invalid email", type: "email_format" }) | formProps.setError("addContacts", { message: "Contact info includes invalid email", type: "email_format" }) | ||||
| } | } | ||||
| @@ -107,7 +107,7 @@ const CustomerInfo: React.FC<Props> = ({ | |||||
| label={t("Customer Email")} | label={t("Customer Email")} | ||||
| fullWidth | fullWidth | ||||
| {...register("email", { | {...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)} | error={Boolean(errors.email)} | ||||
| helperText={Boolean(errors.email) && t("Please input correct customer email")} | helperText={Boolean(errors.email) && t("Please input correct customer email")} | ||||
| @@ -77,7 +77,7 @@ const EditStaff: React.FC = async () => { | |||||
| "grade", | "grade", | ||||
| "skill", | "skill", | ||||
| "currentPosition", | "currentPosition", | ||||
| "salaryEffective", | |||||
| "salary", | |||||
| "hourlyRate", | "hourlyRate", | ||||
| "employType", | "employType", | ||||
| "email", | "email", | ||||
| @@ -140,6 +140,7 @@ const EditStaff: React.FC = async () => { | |||||
| label: t(`Staff ID`), | label: t(`Staff ID`), | ||||
| type: "text", | type: "text", | ||||
| value: data[key] ?? "", | value: data[key] ?? "", | ||||
| required: true, | |||||
| }; | }; | ||||
| case "name": | case "name": | ||||
| return { | return { | ||||
| @@ -179,7 +180,7 @@ const EditStaff: React.FC = async () => { | |||||
| label: t(`Grade`), | label: t(`Grade`), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: gradeCombo, | options: gradeCombo, | ||||
| value: data[key].id ?? "", | |||||
| value: data[key] !== null ? data[key].id ?? "" : "", | |||||
| }; | }; | ||||
| case "skill": | case "skill": | ||||
| return { | return { | ||||
| @@ -187,7 +188,7 @@ const EditStaff: React.FC = async () => { | |||||
| label: t(`Skillset`), | label: t(`Skillset`), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: skillCombo, | options: skillCombo, | ||||
| value: data[key].id ?? "", | |||||
| value: data[key] !== null ? data[key].id ?? "" : "", | |||||
| }; | }; | ||||
| case "currentPosition": | case "currentPosition": | ||||
| return { | return { | ||||
| @@ -197,23 +198,23 @@ const EditStaff: React.FC = async () => { | |||||
| options: positionCombo, | options: positionCombo, | ||||
| value: data[key].id ?? "", | value: data[key].id ?? "", | ||||
| }; | }; | ||||
| case "salaryEffective": | |||||
| case "salary": | |||||
| return { | return { | ||||
| id: `salaryEffId`, | |||||
| id: `salaryId`, | |||||
| label: t(`Salary Point`), | label: t(`Salary Point`), | ||||
| type: "combo-Obj", | type: "combo-Obj", | ||||
| options: salaryCombo, | 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": | case "employType": | ||||
| return { | return { | ||||
| id: `${key}`, | id: `${key}`, | ||||
| @@ -236,7 +237,7 @@ const EditStaff: React.FC = async () => { | |||||
| id: `${key}`, | id: `${key}`, | ||||
| label: t(`Phone1`), | label: t(`Phone1`), | ||||
| type: "text", | type: "text", | ||||
| pattern: "^\\d{8}$", | |||||
| // pattern: "^\\d{8}$", | |||||
| message: t("input correct phone no."), | message: t("input correct phone no."), | ||||
| value: data[key] ?? "", | value: data[key] ?? "", | ||||
| }; | }; | ||||
| @@ -245,7 +246,7 @@ const EditStaff: React.FC = async () => { | |||||
| id: `${key}`, | id: `${key}`, | ||||
| label: t(`Phone2`), | label: t(`Phone2`), | ||||
| type: "text", | type: "text", | ||||
| pattern: "^\\d{8}$", | |||||
| // pattern: "^\\d{8}$", | |||||
| message: t("input correct phone no."), | message: t("input correct phone no."), | ||||
| value: data[key] ?? "", | value: data[key] ?? "", | ||||
| } as Field; | } as Field; | ||||
| @@ -269,7 +270,7 @@ const EditStaff: React.FC = async () => { | |||||
| id: `${key}`, | id: `${key}`, | ||||
| label: t(`Emergency Contact Phonee`), | label: t(`Emergency Contact Phonee`), | ||||
| type: "text", | type: "text", | ||||
| pattern: "^\\d{8}$", | |||||
| // pattern: "^\\d{8}$", | |||||
| message: t("input correct phone no."), | message: t("input correct phone no."), | ||||
| value: data[key] ?? "", | value: data[key] ?? "", | ||||
| } as Field; | } as Field; | ||||
| @@ -231,7 +231,7 @@ const ContactInfo: React.FC<Props> = ({ | |||||
| if (errorRows.length > 0) { | if (errorRows.length > 0) { | ||||
| setError("addContacts", { message: "Contact details include empty fields", type: "required" }) | setError("addContacts", { message: "Contact details include empty fields", type: "required" }) | ||||
| } else { | } 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) { | if (errorRows_EmailFormat.length > 0) { | ||||
| setError("addContacts", { message: "Contact details include empty fields", type: "email_format" }) | setError("addContacts", { message: "Contact details include empty fields", type: "email_format" }) | ||||
| @@ -157,7 +157,7 @@ const SubsidiaryDetail: React.FC<Props> = ({ | |||||
| formProps.setError("addContacts", { message: "Contact info includes empty fields", type: "required" }) | 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 | haveError = true | ||||
| formProps.setError("addContacts", { message: "Contact info includes invalid email", type: "email_format" }) | formProps.setError("addContacts", { message: "Contact info includes invalid email", type: "email_format" }) | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| { | { | ||||
| "Overview": "Overview", | "Overview": "Overview", | ||||
| "customer": "Customer", | |||||
| "Create Customer": "Create Customer" | |||||
| "customer": "Client", | |||||
| "Create Customer": "Create Client" | |||||
| } | } | ||||
| @@ -15,8 +15,8 @@ | |||||
| "Customer Type": "Client Type", | "Customer Type": "Client Type", | ||||
| "Customer Allocation": "Client Allocation", | "Customer Allocation": "Client Allocation", | ||||
| "Search by customer code, name or br no.": "Search by client code, name or br no.", | "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 code": "Please input correct client code", | ||||
| "Please input correct subsidiary name": "Please input correct client name", | "Please input correct subsidiary name": "Please input correct client name", | ||||