|
|
@@ -2,15 +2,16 @@ |
|
|
|
import { |
|
|
|
Grid, Button, Typography, |
|
|
|
Dialog, DialogTitle, DialogContent, DialogActions, |
|
|
|
FormHelperText |
|
|
|
} from '@mui/material'; |
|
|
|
import MainCard from "../../../components/MainCard"; |
|
|
|
import MainCard from "components/MainCard"; |
|
|
|
import * as React from "react"; |
|
|
|
import * as yup from 'yup'; |
|
|
|
import { useEffect, useState } from "react"; |
|
|
|
import * as HttpUtils from '../../../utils/HttpUtils'; |
|
|
|
import * as UrlUtils from "../../../utils/ApiPathConst"; |
|
|
|
import * as FieldUtils from "../../../utils/FieldUtils"; |
|
|
|
import * as ComboData from "../../../utils/ComboData"; |
|
|
|
import * as HttpUtils from 'utils/HttpUtils'; |
|
|
|
import * as UrlUtils from "utils/ApiPathConst"; |
|
|
|
import * as FieldUtils from "utils/FieldUtils"; |
|
|
|
import * as ComboData from "utils/ComboData"; |
|
|
|
import { useNavigate } from "react-router-dom"; |
|
|
|
import { useFormik } from 'formik'; |
|
|
|
const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); |
|
|
@@ -29,6 +30,7 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
const [onReady, setOnReady] = useState(false); |
|
|
|
const [isFailPopUp, setIsFailPopUp] = useState(false); |
|
|
|
const [failText, setFailText] = useState(""); |
|
|
|
const [errorMsg, setErrorMsg] = useState(""); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
//if state data are ready and assign to different field |
|
|
@@ -57,7 +59,7 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
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(displayErrorMsg(`${intl.formatMessage({id: 'pleaseFillInValidBusinessRegCertNumber'})} (e.g. 12341234)`)), function (value) { |
|
|
|
.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)) { |
|
|
@@ -69,45 +71,53 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
}), |
|
|
|
}), |
|
|
|
onSubmit: values => { |
|
|
|
HttpUtils.post({ |
|
|
|
url: UrlUtils.POST_ORG_SAVE_PATH, |
|
|
|
params: { |
|
|
|
id: null, |
|
|
|
primaryUserId: userId, |
|
|
|
enCompanyName: values.enCompanyName, |
|
|
|
chCompanyName: values.chCompanyName, |
|
|
|
brNo: values.brNo, |
|
|
|
brExpiryDate: values.brExpiryDate, |
|
|
|
enCompanyNameTemp: values.enCompanyNameTemp, |
|
|
|
chCompanyNameTemp: values.chCompanyNameTemp, |
|
|
|
brExpiryDateTemp: values.brExpiryDateTemp, |
|
|
|
contactPerson: values.contactPerson, |
|
|
|
contactTel: { |
|
|
|
countryCode: values.tel_countryCode, |
|
|
|
phoneNumber: values.phoneNumber |
|
|
|
}, |
|
|
|
faxNo: { |
|
|
|
countryCode: values.fax_countryCode, |
|
|
|
faxNumber: values.faxNumber |
|
|
|
}, |
|
|
|
addressTemp: { |
|
|
|
country: values.country.key, |
|
|
|
district: values.district.key, |
|
|
|
addressLine1: values.addressLine1, |
|
|
|
addressLine2: values.addressLine2, |
|
|
|
addressLine3: values.addressLine3, |
|
|
|
} |
|
|
|
}, |
|
|
|
onSuccess: function (responseData) { |
|
|
|
if(responseData.msg){ |
|
|
|
setFailText(responseData.msg); |
|
|
|
setIsFailPopUp(true); |
|
|
|
return; |
|
|
|
} |
|
|
|
navigate('/org/' + responseData.id); |
|
|
|
notifyCreateSuccess() |
|
|
|
if (values.country==null){ |
|
|
|
setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'})) |
|
|
|
} else { |
|
|
|
if (values.country.key ==1 && values.district == null){ |
|
|
|
setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'})) |
|
|
|
} else { |
|
|
|
HttpUtils.post({ |
|
|
|
url: UrlUtils.POST_ORG_SAVE_PATH, |
|
|
|
params: { |
|
|
|
id: null, |
|
|
|
primaryUserId: userId, |
|
|
|
enCompanyName: values.enCompanyName, |
|
|
|
chCompanyName: values.chCompanyName, |
|
|
|
brNo: values.brNo, |
|
|
|
brExpiryDate: values.brExpiryDate, |
|
|
|
enCompanyNameTemp: values.enCompanyNameTemp, |
|
|
|
chCompanyNameTemp: values.chCompanyNameTemp, |
|
|
|
brExpiryDateTemp: values.brExpiryDateTemp, |
|
|
|
contactPerson: values.contactPerson, |
|
|
|
contactTel: { |
|
|
|
countryCode: values.tel_countryCode, |
|
|
|
phoneNumber: values.phoneNumber |
|
|
|
}, |
|
|
|
faxNo: { |
|
|
|
countryCode: values.fax_countryCode, |
|
|
|
faxNumber: values.faxNumber |
|
|
|
}, |
|
|
|
addressTemp: { |
|
|
|
country: values.country.key, |
|
|
|
district: values.district?.key, |
|
|
|
addressLine1: values.addressLine1, |
|
|
|
addressLine2: values.addressLine2, |
|
|
|
addressLine3: values.addressLine3, |
|
|
|
} |
|
|
|
}, |
|
|
|
onSuccess: function (responseData) { |
|
|
|
if(responseData.msg){ |
|
|
|
setFailText(responseData.msg); |
|
|
|
setIsFailPopUp(true); |
|
|
|
return; |
|
|
|
} |
|
|
|
navigate('/org/' + responseData.id); |
|
|
|
notifyCreateSuccess() |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@@ -140,9 +150,7 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
<Grid container spacing={1}> |
|
|
|
{/*top*/} |
|
|
|
<Grid item s={12} md={12} lg={12} sx={{ mb: 3 }} alignItems={"start"} justifyContent="center"> |
|
|
|
|
|
|
|
|
|
|
|
<Grid item sx={{ ml: 3, mr: 3 }}> |
|
|
|
<Grid item sx={{mr: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
@@ -155,10 +163,17 @@ const OrganizationCard_loadFromUser = ({ userData, userId }) => { |
|
|
|
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.:", |
|
|
|