@@ -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 () => { | |||
@@ -19,7 +19,7 @@ export interface CreateStaffInputs { | |||
companyId: number; | |||
gradeId: number; | |||
teamId: number; | |||
salaryEffId: number; | |||
salaryId: number; | |||
email: string; | |||
phone1: string; | |||
phone2: string; | |||
@@ -179,7 +179,7 @@ const CreateStaff: React.FC<formProps> = ({ Title }) => { | |||
label: t("Team"), | |||
type: "combo-Obj", | |||
options: teamCombo, | |||
required: true, | |||
required: false, | |||
}, | |||
{ | |||
id: "departmentId", | |||
@@ -193,14 +193,14 @@ const CreateStaff: React.FC<formProps> = ({ 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<formProps> = ({ 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<formProps> = ({ 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<formProps> = ({ 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<formProps> = ({ Title }) => { | |||
label: t("Emergency Contact Phone"), | |||
type: "text", | |||
value: "", | |||
pattern: "^\\d{8}$", | |||
// pattern: "^\\d{8}$", | |||
message: t("input correct phone no."), | |||
required: true, | |||
}, | |||
@@ -274,7 +274,7 @@ const CustomInputForm: React.FC<CustomInputFormProps> = ({ | |||
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} | |||
@@ -231,7 +231,7 @@ const ContactInfo: React.FC<Props> = ({ | |||
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 { | |||
@@ -167,7 +167,7 @@ const CustomerDetail: React.FC<Props> = ({ | |||
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<Props> = ({ | |||
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" }) | |||
} | |||
@@ -107,7 +107,7 @@ const CustomerInfo: React.FC<Props> = ({ | |||
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")} | |||
@@ -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; | |||
@@ -231,7 +231,7 @@ const ContactInfo: React.FC<Props> = ({ | |||
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" }) | |||
@@ -157,7 +157,7 @@ const SubsidiaryDetail: React.FC<Props> = ({ | |||
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" }) | |||
} | |||
@@ -1,6 +1,6 @@ | |||
{ | |||
"Overview": "Overview", | |||
"customer": "Customer", | |||
"Create Customer": "Create Customer" | |||
"customer": "Client", | |||
"Create Customer": "Create Client" | |||
} |
@@ -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", | |||