|
|
@@ -2,12 +2,13 @@ |
|
|
|
import { |
|
|
|
Grid, Button, Typography, |
|
|
|
Dialog, DialogTitle, DialogContent, DialogActions, |
|
|
|
FormHelperText |
|
|
|
FormHelperText, TextField |
|
|
|
} from '@mui/material'; |
|
|
|
import MainCard from "components/MainCard"; |
|
|
|
import * as React from "react"; |
|
|
|
import * as yup from 'yup'; |
|
|
|
import { useEffect, useState } from "react"; |
|
|
|
import * as DateUtils from 'utils/DateUtils'; |
|
|
|
import * as HttpUtils from 'utils/HttpUtils'; |
|
|
|
import * as UrlUtils from "utils/ApiPathConst"; |
|
|
|
import * as FieldUtils from "utils/FieldUtils"; |
|
|
@@ -18,7 +19,7 @@ const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingCo |
|
|
|
import Loadable from 'components/Loadable'; |
|
|
|
import { lazy } from 'react'; |
|
|
|
import { notifyCreateSuccess } from 'utils/CommonFunction'; |
|
|
|
import {useIntl} from "react-intl"; |
|
|
|
import { useIntl } from "react-intl"; |
|
|
|
|
|
|
|
// ==============================|| DASHBOARD - DEFAULT ||============================== // |
|
|
|
|
|
|
@@ -48,34 +49,34 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
enableReinitialize: true, |
|
|
|
initialValues: currentUserData, |
|
|
|
validationSchema: yup.object().shape({ |
|
|
|
enCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'userRequireEnglishName'}))).required(displayErrorMsg(intl.formatMessage({id: 'userRequireEnglishName'}))), |
|
|
|
chCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'userRequireChineseName'}))).nullable(), |
|
|
|
addressLine1: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), |
|
|
|
enCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({ id: 'userRequireEnglishName' }))).required(displayErrorMsg(intl.formatMessage({ id: 'userRequireEnglishName' }))), |
|
|
|
chCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({ id: 'userRequireChineseName' }))).nullable(), |
|
|
|
addressLine1: yup.string().max(40).required(displayErrorMsg(intl.formatMessage({ id: 'validateAddressLine1' }))), |
|
|
|
addressLine2: yup.string().max(40).nullable(), |
|
|
|
addressLine3: yup.string().max(40).nullable(), |
|
|
|
fax_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))).nullable(), |
|
|
|
tel_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))), |
|
|
|
phoneNumber: yup.string().min(8, displayErrorMsg(intl.formatMessage({id: 'requiredValidNumber'}))).required(displayErrorMsg(intl.formatMessage({id: 'requireContactNumber'}))), |
|
|
|
fax_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({ id: 'requireDialingCode' }))).nullable(), |
|
|
|
tel_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({ id: 'requireDialingCode' }))), |
|
|
|
phoneNumber: yup.string().min(8, displayErrorMsg(intl.formatMessage({ id: 'requiredValidNumber' }))).required(displayErrorMsg(intl.formatMessage({ id: 'requireContactNumber' }))), |
|
|
|
faxNumber: yup.string().min(8).nullable(), |
|
|
|
brExpiryDate: yup.string().min(8).required(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInBusinessRegCertValidityDate'}))), |
|
|
|
brNo: yup.string().max(8).required(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInBusinessRegCertNumber'}))) |
|
|
|
.test('checkBrNoFormat', displayErrorMsg(`${intl.formatMessage({id: 'pleaseFillInValidBusinessRegCertNumber'})} (e.g. 12341234)`), function (value) { |
|
|
|
var brNo_pattern = /[0-9]{8}/ |
|
|
|
if (value !== undefined) { |
|
|
|
if (value.match(brNo_pattern)) { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
return false |
|
|
|
brExpiryDate: yup.string().min(8).required(displayErrorMsg(intl.formatMessage({ id: 'pleaseFillInBusinessRegCertValidityDate' }))), |
|
|
|
brNo: yup.string().max(8).required(displayErrorMsg(intl.formatMessage({ id: 'pleaseFillInBusinessRegCertNumber' }))) |
|
|
|
.test('checkBrNoFormat', displayErrorMsg(`${intl.formatMessage({ id: 'pleaseFillInValidBusinessRegCertNumber' })} (e.g. 12341234)`), function (value) { |
|
|
|
var brNo_pattern = /[0-9]{8}/ |
|
|
|
if (value !== undefined) { |
|
|
|
if (value.match(brNo_pattern)) { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}), |
|
|
|
}), |
|
|
|
}), |
|
|
|
onSubmit: values => { |
|
|
|
if (values.country==null){ |
|
|
|
setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'})) |
|
|
|
if (values.country == null) { |
|
|
|
setErrorMsg(intl.formatMessage({ id: 'pleaseFillInCountry' })) |
|
|
|
} else { |
|
|
|
if (values.country.key ==1 && values.district == null){ |
|
|
|
setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'})) |
|
|
|
if (values.country.key == 1 && values.district == null) { |
|
|
|
setErrorMsg(intl.formatMessage({ id: 'pleaseFillInDistrict' })) |
|
|
|
} else { |
|
|
|
HttpUtils.post({ |
|
|
|
url: UrlUtils.POST_ORG_SAVE_PATH, |
|
|
@@ -107,7 +108,7 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
} |
|
|
|
}, |
|
|
|
onSuccess: function (responseData) { |
|
|
|
if(responseData.msg){ |
|
|
|
if (responseData.msg) { |
|
|
|
setFailText(responseData.msg); |
|
|
|
setIsFailPopUp(true); |
|
|
|
return; |
|
|
@@ -143,131 +144,148 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
|
|
|
|
|
|
|
|
<div style={{ padding: 24 }}> |
|
|
|
<form onSubmit={formik.handleSubmit}> |
|
|
|
{!onReady? |
|
|
|
<LoadingComponent /> |
|
|
|
: |
|
|
|
<Grid container spacing={1}> |
|
|
|
{/*top*/} |
|
|
|
<Grid item s={12} md={12} lg={12} sx={{ mb: 3 }} alignItems={"start"} justifyContent="center"> |
|
|
|
<Grid item sx={{mr: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
type="submit" |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}} |
|
|
|
> |
|
|
|
Create |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
{/*top*/} |
|
|
|
<form onSubmit={formik.handleSubmit}> |
|
|
|
{!onReady ? |
|
|
|
<LoadingComponent /> |
|
|
|
: |
|
|
|
<Grid container spacing={1}> |
|
|
|
{/*top*/} |
|
|
|
<Grid item s={12} md={12} lg={12} sx={{ mb: 3 }} alignItems={"start"} justifyContent="center"> |
|
|
|
<Grid item sx={{ mr: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
type="submit" |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}} |
|
|
|
> |
|
|
|
Create |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
{/*top*/} |
|
|
|
|
|
|
|
<Grid item xs={12}> |
|
|
|
<FormHelperText error id="helper-text-address1-signup"> |
|
|
|
<Typography variant="errorMessage1"> |
|
|
|
{errorMsg} |
|
|
|
</Typography> |
|
|
|
</FormHelperText> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: "BR No.:", |
|
|
|
valueName: "brNo", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item xs={12}> |
|
|
|
<FormHelperText error id="helper-text-address1-signup"> |
|
|
|
<Typography variant="errorMessage1"> |
|
|
|
{errorMsg} |
|
|
|
</Typography> |
|
|
|
</FormHelperText> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={8}></Grid> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: "BR No.:", |
|
|
|
valueName: "brNo", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Name (Eng):"), |
|
|
|
valueName: "enCompanyName", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={8}></Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: "Name (Ch):", |
|
|
|
valueName: "chCompanyName", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Name (Eng):"), |
|
|
|
valueName: "enCompanyName", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getDateField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Expiry Date:"), |
|
|
|
valueName: "brExpiryDate", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: "Name (Ch):", |
|
|
|
valueName: "chCompanyName", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Contact Person:"), |
|
|
|
valueName: "contactPerson", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4} > |
|
|
|
<Grid container alignItems={"center"}> |
|
|
|
<Grid item xs={12} md={3} lg={3} sx={{ display: 'flex', alignItems: 'center' }}> |
|
|
|
<Typography variant="pnspsFormParagraphBold">{FieldUtils.notNullFieldLabel("Expiry Date:")}</Typography> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={12} md={6} lg={6}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id="brExpiryDate" |
|
|
|
name="brExpiryDate" |
|
|
|
type="date" |
|
|
|
inputProps={{ min: DateUtils.dateStr(new Date()) }} |
|
|
|
error={Boolean(formik.errors["brExpiryDate"])} |
|
|
|
helperText={formik.errors["brExpiryDate"] ? formik.errors["brExpiryDate"] : ''} |
|
|
|
onChange={formik.handleChange} |
|
|
|
value={formik.values["brExpiryDate"]} |
|
|
|
sx={{ |
|
|
|
width: '100%' |
|
|
|
}} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getPhoneField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Contact Tel:"), |
|
|
|
valueName: { |
|
|
|
code: "tel_countryCode", |
|
|
|
num: "phoneNumber" |
|
|
|
}, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getPhoneField({ |
|
|
|
label: "Fax No:", |
|
|
|
valueName: { |
|
|
|
code: "fax_countryCode", |
|
|
|
num: "faxNumber" |
|
|
|
}, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Contact Person:"), |
|
|
|
valueName: "contactPerson", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getComboField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Country:"), |
|
|
|
valueName: "country", |
|
|
|
dataList: ComboData.country, |
|
|
|
getOptionLabel: (option) => option.type? intl.formatMessage({ id: option.type}) : "", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getPhoneField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Contact Tel:"), |
|
|
|
valueName: { |
|
|
|
code: "tel_countryCode", |
|
|
|
num: "phoneNumber" |
|
|
|
}, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getComboField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("District:"), |
|
|
|
valueName: "district", |
|
|
|
dataList: ComboData.district, |
|
|
|
getOptionLabel: (option) => option.type? intl.formatMessage({ id: option.type}) : "", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getPhoneField({ |
|
|
|
label: "Fax No:", |
|
|
|
valueName: { |
|
|
|
code: "fax_countryCode", |
|
|
|
num: "faxNumber" |
|
|
|
}, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getAddressField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Address:"), |
|
|
|
valueName: ["addressLine1", "addressLine2", "addressLine3"], |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
} |
|
|
|
</form> |
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getComboField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Country:"), |
|
|
|
valueName: "country", |
|
|
|
dataList: ComboData.country, |
|
|
|
getOptionLabel: (option) => option.type ? intl.formatMessage({ id: option.type }) : "", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getComboField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("District:"), |
|
|
|
valueName: "district", |
|
|
|
dataList: ComboData.district, |
|
|
|
getOptionLabel: (option) => option.type ? intl.formatMessage({ id: option.type }) : "", |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4}> |
|
|
|
{FieldUtils.getAddressField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Address:"), |
|
|
|
valueName: ["addressLine1", "addressLine2", "addressLine3"], |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
} |
|
|
|
</form> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div> |
|
|
|