Ver código fonte

1. update project

2. update client & subsidiary contact info
tags/Baseline_30082024_FRONTEND_UAT
cyril.tsui 1 ano atrás
pai
commit
5e2c166be1
9 arquivos alterados com 71 adições e 38 exclusões
  1. +5
    -5
      src/components/CreateProject/ProjectClientDetails.tsx
  2. +25
    -6
      src/components/CustomerSave/ContactInfo.tsx
  3. +18
    -16
      src/components/CustomerSave/CustomerSave.tsx
  4. +15
    -5
      src/components/SubsidiaryDetail/ContactInfo.tsx
  5. +4
    -2
      src/components/SubsidiaryDetail/SubsidiaryDetail.tsx
  6. +1
    -1
      src/i18n/en/customer.json
  7. +1
    -1
      src/i18n/en/subsidiary.json
  8. +1
    -1
      src/i18n/zh/customer.json
  9. +1
    -1
      src/i18n/zh/subsidiary.json

+ 5
- 5
src/components/CreateProject/ProjectClientDetails.tsx Ver arquivo

@@ -382,9 +382,9 @@ const ProjectClientDetails: React.FC<Props> = ({
fullWidth
type="number"
inputProps={{ step: "0.01" }}
InputLabelProps={{
shrink: Boolean(watch("subContractFee")),
}}
// InputLabelProps={{
// shrink: Boolean(watch("subContractFee")),
// }}
{...register("subContractFee", { valueAsNumber: true })}
/>
</Grid>
@@ -412,9 +412,9 @@ const ProjectClientDetails: React.FC<Props> = ({
<Typography variant="overline" display="block">
{t("Client Details")}
</Typography>
<Button LinkComponent={Link} href="/settings/customer">
{/* <Button LinkComponent={Link} href="/settings/customer">
{t("Add or Edit Clients")}
</Button>
</Button> */}
</Stack>
<Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
<Grid item xs={6}>


+ 25
- 6
src/components/CustomerSave/ContactInfo.tsx Ver arquivo

@@ -142,7 +142,7 @@ const ContactInfo: React.FC<Props> = ({
resetField("addContacts")
// reset({addContacts: defaultValues.addContacts})
setRows((prev) => defaultValues.addContacts)
setRowModesModel(rows.reduce((acc, row) => ({...acc, [row.id]: { mode: GridRowModes.View } }), {}))
setRowModesModel(rows.reduce((acc, row) => ({ ...acc, [row.id]: { mode: GridRowModes.View } }), {}))
}
}, [defaultValues])

@@ -159,6 +159,14 @@ const ContactInfo: React.FC<Props> = ({
headerName: t('Contact Phone'),
editable: true,
flex: 1,
// type: "number",
// valueSetter: ({ value, row }) => {

// const phone = value.replace(/\D/g, '')

// return { ...row, phone }
// },
},
{
field: 'email',
@@ -232,8 +240,11 @@ const ContactInfo: React.FC<Props> = ({
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)))
if (errorRows_EmailFormat.length > 0) {
setError("addContacts", { message: "Contact details include empty fields", type: "email_format" })

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 {
clearErrors("addContacts")
}
@@ -264,8 +275,8 @@ const ContactInfo: React.FC<Props> = ({
{Boolean(errors.addContacts?.type === "required") && <Typography sx={(theme) => ({ 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")}
</Typography>}
{Boolean(errors.addContacts?.type === "email_format") && <Typography sx={(theme) => ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap>
{t("Please ensure all the email formats are correct")}
{Boolean(errors.addContacts?.type === "format") && <Typography sx={(theme) => ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap>
{t("Please ensure all the email and phone formats are correct")}
</Typography>}
{/* </div> */}
<CustomDatagrid
@@ -284,7 +295,15 @@ const ContactInfo: React.FC<Props> = ({
toolbar: { setRows, setRowModesModel },
}}
sx={{
height: '100%'
height: '100%',
'& input[type=number]::-webkit-outer-spin-button': {
'-webkit-appearance': 'none',
margin: 0
},
'& input[type=number]::-webkit-inner-spin-button': {
'-webkit-appearance': 'none',
margin: 0
}
}}
/>
<CardActions sx={{ justifyContent: "flex-end" }}>


+ 18
- 16
src/components/CustomerSave/CustomerSave.tsx Ver arquivo

@@ -182,9 +182,11 @@ const CustomerSave: React.FC<Props> = ({
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) {
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", type: "email_format" })
formProps.setError("addContacts", { message: "Contact info includes invalid email or phone", type: "format" })
}

if (haveError) {
@@ -199,20 +201,20 @@ const CustomerSave: React.FC<Props> = ({
setServerError("");

submitDialog(async () => {
const response = await saveCustomer(data);
if (response.message === "Success") {
successDialog(t("Submit Success"), t).then(() => {
router.replace("/settings/customer");
})
} else {
errorDialog(t("Submit Fail"), t).then(() => {
formProps.setError("code", { message: response.message, type: "custom" })
setTabIndex(0)
return false
})
}
}, t)
const response = await saveCustomer(data);
if (response.message === "Success") {
successDialog(t("Submit Success"), t).then(() => {
router.replace("/settings/customer");
})
} else {
errorDialog(t("Submit Fail"), t).then(() => {
formProps.setError("code", { message: response.message, type: "custom" })
setTabIndex(0)
return false
})
}
}, t)
} catch (e) {
console.log(e)
setServerError(t("An error has occurred. Please try again later."));


+ 15
- 5
src/components/SubsidiaryDetail/ContactInfo.tsx Ver arquivo

@@ -233,8 +233,10 @@ const ContactInfo: React.FC<Props> = ({
} else {
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" })
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 {
clearErrors("addContacts")
}
@@ -265,8 +267,8 @@ const ContactInfo: React.FC<Props> = ({
{Boolean(errors.addContacts?.type === "required") && <Typography sx={(theme) => ({ 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")}
</Typography>}
{Boolean(errors.addContacts?.type === "email_format") && <Typography sx={(theme) => ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap>
{t("Please ensure all the email formats are correct")}
{Boolean(errors.addContacts?.type === "format") && <Typography sx={(theme) => ({ color: theme.palette.error.main })} variant="overline" display='inline-block' noWrap>
{t("Please ensure all the email and phone formats are correct")}
</Typography>}
{/* </div> */}
<CustomDatagrid
@@ -285,7 +287,15 @@ const ContactInfo: React.FC<Props> = ({
toolbar: { setRows, setRowModesModel },
}}
sx={{
height: '100%'
height: '100%',
'& input[type=number]::-webkit-outer-spin-button': {
'-webkit-appearance': 'none',
margin: 0
},
'& input[type=number]::-webkit-inner-spin-button': {
'-webkit-appearance': 'none',
margin: 0
}
}}
/>
<CardActions sx={{ justifyContent: "flex-end" }}>


+ 4
- 2
src/components/SubsidiaryDetail/SubsidiaryDetail.tsx Ver arquivo

@@ -157,9 +157,11 @@ 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-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/.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
&& 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", type: "email_format" })
formProps.setError("addContacts", { message: "Contact info includes invalid email or phone", type: "format" })
}

if (haveError) {


+ 1
- 1
src/i18n/en/customer.json Ver arquivo

@@ -44,7 +44,7 @@
"Contact Email": "Contact Email",
"Contact Phone": "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 fields are inputted and saved",
"Please ensure all the email formats are correct": "Please ensure all the email formats are correct",
"Please ensure all the email and phone formats are correct": "Please ensure all the email and phone formats are correct",

"Do you want to submit?": "Do you want to submit?",
"Submit Success": "Submit Success",


+ 1
- 1
src/i18n/en/subsidiary.json Ver arquivo

@@ -44,7 +44,7 @@
"Contact Email": "Contact Email",
"Contact Phone": "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 fields are inputted and saved",
"Please ensure all the email formats are correct": "Please ensure all the email formats are correct",
"Please ensure all the email and phone formats are correct": "Please ensure all the email and phone formats are correct",

"Do you want to submit?": "Do you want to submit?",
"Submit Success": "Submit Success",


+ 1
- 1
src/i18n/zh/customer.json Ver arquivo

@@ -44,7 +44,7 @@
"Contact Email": "聯絡電郵",
"Contact Phone": "聯絡電話",
"Please ensure at least one row is created, and all the fields are inputted and saved": "請確保已建立至少一行, 及已輸入和儲存所有欄位",
"Please ensure all the email formats are correct": "請確保所有電郵格式輸入正確",
"Please ensure all the email and phone formats are correct": "請確保所有電郵和電話格式輸入正確",
"Do you want to submit?": "你是否確認要提交?",
"Submit Success": "提交成功",


+ 1
- 1
src/i18n/zh/subsidiary.json Ver arquivo

@@ -44,7 +44,7 @@
"Contact Email": "聯絡電郵",
"Contact Phone": "聯絡電話",
"Please ensure at least one row is created, and all the fields are inputted and saved": "請確保已建立至少一行, 及已輸入和儲存所有欄位",
"Please ensure all the email formats are correct": "請確保所有電郵格式輸入正確",
"Please ensure all the email and phone formats are correct": "請確保所有電郵和電話格式輸入正確",
"Do you want to submit?": "你是否確認要提交?",
"Submit Success": "提交成功",


Carregando…
Cancelar
Salvar