|
|
@@ -1,18 +1,20 @@ |
|
|
|
// material-ui |
|
|
|
import { |
|
|
|
Grid, Button, Checkbox, FormControlLabel, Typography, |
|
|
|
Grid, Button, |
|
|
|
// Checkbox, FormControlLabel, |
|
|
|
Typography, |
|
|
|
Dialog, DialogTitle, DialogContent, DialogActions, |
|
|
|
} from '@mui/material'; |
|
|
|
// import { FormControlLabel } from '@material-ui/core'; |
|
|
|
import MainCard from "../../../components/MainCard"; |
|
|
|
import MainCard from "components/MainCard"; |
|
|
|
import * as React from "react"; |
|
|
|
import { useFormik } from 'formik'; |
|
|
|
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"; |
|
|
|
const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); |
|
|
|
import Loadable from 'components/Loadable'; |
|
|
|
import { lazy } from 'react'; |
|
|
@@ -48,52 +50,25 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
enableReinitialize: true, |
|
|
|
initialValues: currentUserData, |
|
|
|
validationSchema: yup.object().shape({ |
|
|
|
enCompanyName: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'userRequireEnglishName'}))), |
|
|
|
chCompanyName: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'userRequireChineseName'}))).nullable(), |
|
|
|
addressLine1: yup.string().max(255).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))), |
|
|
|
addressLine2: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'noMoreThen255Words'}))), |
|
|
|
addressLine3: yup.string().max(255, displayErrorMsg(intl.formatMessage({id: 'noMoreThen255Words'}))), |
|
|
|
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, displayErrorMsg(intl.formatMessage({id: 'require8Number'}))).nullable(), |
|
|
|
brExpiryDate: yup.string().min(8).required(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInBusinessRegCertValidityDate'}))), |
|
|
|
brNo: yup.string().required(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInBusinessRegCertNumber'}))).test('checkBrNoFormat', displayErrorMsg(displayErrorMsg(intl.formatMessage({id: 'pleaseFillInValidBusinessRegCertNumber'}))), function (value) { |
|
|
|
var brNo_pattern = /[0-9]{8}/ |
|
|
|
if (value !== undefined) { |
|
|
|
if (value.match(brNo_pattern)) { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
}), |
|
|
|
}), |
|
|
|
onSubmit: vaule => { |
|
|
|
console.log(vaule) |
|
|
|
HttpUtils.post({ |
|
|
|
url: UrlUtils.POST_ORG_SAVE_PATH, |
|
|
|
url: UrlUtils.POST_PUB_ORG_SAVE_PATH, |
|
|
|
params: { |
|
|
|
id: id > 0 ? id : null, |
|
|
|
enCompanyName: vaule.enCompanyName, |
|
|
|
chCompanyName: vaule.chCompanyName, |
|
|
|
brNo: vaule.brNo, |
|
|
|
brExpiryDate: vaule.brExpiryDate, |
|
|
|
enCompanyNameTemp: vaule.enCompanyNameTemp, |
|
|
|
chCompanyNameTemp: vaule.chCompanyNameTemp, |
|
|
|
brExpiryDateTemp: vaule.brExpiryDateTemp, |
|
|
|
contactPerson: vaule.contactPerson, |
|
|
|
contactTel: { |
|
|
|
countryCode: vaule.tel_countryCode, |
|
|
|
phoneNumber: vaule.phoneNumber |
|
|
|
}, |
|
|
|
faxNo: { |
|
|
|
countryCode: vaule.fax_countryCode, |
|
|
|
faxNumber: vaule.faxNumber |
|
|
|
}, |
|
|
|
addressTemp: { |
|
|
|
country: vaule.country, |
|
|
|
district: vaule.district, |
|
|
|
country: vaule.country.id, |
|
|
|
district: vaule.district.id, |
|
|
|
addressLine1: vaule.addressLine1, |
|
|
|
addressLine2: vaule.addressLine2, |
|
|
|
addressLine3: vaule.addressLine3, |
|
|
@@ -134,26 +109,6 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
setEditMode(true); |
|
|
|
}; |
|
|
|
|
|
|
|
const markAsCreditor = () => { |
|
|
|
setCreditorConfirmPopUp(false); |
|
|
|
HttpUtils.get({ |
|
|
|
url: UrlUtils.GET_ORG_MARK_AS_CREDITOR + "/" + id, |
|
|
|
onSuccess: () => { |
|
|
|
loadDataFun(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
const markAsNonCreditor = () => { |
|
|
|
setNonCreditorConfirmPopUp(false); |
|
|
|
HttpUtils.get({ |
|
|
|
url: UrlUtils.GET_ORG_MARK_AS_NON_CREDITOR + "/" + id, |
|
|
|
onSuccess: () => { |
|
|
|
loadDataFun(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<MainCard elevation={0} |
|
|
|
border={false} |
|
|
@@ -230,34 +185,6 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
<Typography variant="h5">Edit</Typography> |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
<Grid item sx={{ ml: 3, mr: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
color="orange" |
|
|
|
onClick={()=>setCreditorConfirmPopUp(true)} |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}} |
|
|
|
> |
|
|
|
<Typography variant="h5">Mark as Creditor</Typography> |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
<Grid item sx={{ ml: 3, mr: 3 }}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
color="error" |
|
|
|
onClick={()=>setNonCreditorConfirmPopUp(true)} |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}} |
|
|
|
> |
|
|
|
<Typography variant="h5">Mark as Non-Creditor</Typography> |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
</> |
|
|
|
} |
|
|
|
</Grid> |
|
|
@@ -270,20 +197,25 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
<Grid container spacing={1}> |
|
|
|
<Grid item xs={12}> |
|
|
|
<Typography variant="h4" sx={{ mb: 2, mr: 3, borderBottom: "1px solid black" }}> |
|
|
|
Organisation Details |
|
|
|
Organization Details |
|
|
|
</Typography> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={4} > |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("BR No.:"), |
|
|
|
valueName: "brNo", |
|
|
|
disabled: (!editMode && !createMode), |
|
|
|
disabled: true, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4} > |
|
|
|
<FormControlLabel |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: "Creditor Account" + ":", |
|
|
|
valueName: "creditor", |
|
|
|
disabled: true, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
{/* <FormControlLabel |
|
|
|
control={<Checkbox checked={formik.values.creditor} />} |
|
|
|
label="is Creditor" |
|
|
|
name="creditor" |
|
|
@@ -292,7 +224,7 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
}} |
|
|
|
disabled={true} |
|
|
|
//disabled={!editMode && !createMode} |
|
|
|
/> |
|
|
|
/> */} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
<Grid item lg={4} ></Grid> |
|
|
@@ -301,7 +233,7 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Name (Eng):"), |
|
|
|
valueName: "enCompanyName", |
|
|
|
disabled: (!editMode && !createMode), |
|
|
|
disabled: true, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
@@ -310,7 +242,7 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
{FieldUtils.getTextField({ |
|
|
|
label: "Name (Ch):", |
|
|
|
valueName: "chCompanyName", |
|
|
|
disabled: (!editMode && !createMode), |
|
|
|
disabled: true, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
@@ -319,7 +251,7 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
{FieldUtils.getDateField({ |
|
|
|
label: FieldUtils.notNullFieldLabel("Expiry Date:"), |
|
|
|
valueName: "brExpiryDate", |
|
|
|
disabled: (!editMode && !createMode), |
|
|
|
disabled: true, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
@@ -352,7 +284,7 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => { |
|
|
|
code: "fax_countryCode", |
|
|
|
num: "faxNumber" |
|
|
|
}, |
|
|
|
disabled: (!editMode && !createMode), |
|
|
|
disabled: true, |
|
|
|
form: formik |
|
|
|
})} |
|
|
|
</Grid> |
|
|
|