|
|
@@ -2,11 +2,8 @@ |
|
|
|
import { |
|
|
|
Grid, TextField, Typography, Button |
|
|
|
} from '@mui/material'; |
|
|
|
// import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; |
|
|
|
// import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; |
|
|
|
import MainCard from "../../components/MainCard"; |
|
|
|
import * as React from "react"; |
|
|
|
import {useForm} from "react-hook-form"; |
|
|
|
import {useEffect, useState} from "react"; |
|
|
|
import * as DateUtils from '../../utils/DateUtils'; |
|
|
|
import * as HttpUtils from '../../utils/HttpUtils'; |
|
|
@@ -20,8 +17,6 @@ import { useFormik } from 'formik'; |
|
|
|
const OrganizationCard_loadFromUser = ({userData, id}) => { |
|
|
|
|
|
|
|
const [currentUserData, setCurrentUserData] = useState(userData); |
|
|
|
const form = useForm({defaultValues: userData}); |
|
|
|
const {register,reset} = form; |
|
|
|
|
|
|
|
const navigate = useNavigate(); |
|
|
|
|
|
|
@@ -32,7 +27,7 @@ const OrganizationCard_loadFromUser = ({userData, id}) => { |
|
|
|
HttpUtils.post({ |
|
|
|
url: UrlUtils.POST_ORG_SAVE_PATH, |
|
|
|
params: { |
|
|
|
id:id>0?id:null, |
|
|
|
id:null, |
|
|
|
enCompanyName: values.enCompanyName, |
|
|
|
chCompanyName: values.chCompanyName, |
|
|
|
brNo: values.brNo, |
|
|
@@ -92,60 +87,9 @@ const OrganizationCard_loadFromUser = ({userData, id}) => { |
|
|
|
}, [userData]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
reset(currentUserData); |
|
|
|
}, [currentUserData]); |
|
|
|
|
|
|
|
const getTextField=(label, key, form)=>{ |
|
|
|
return <Grid item lg={4} > |
|
|
|
<Grid container alignItems={"center"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'center'}}> |
|
|
|
{label} |
|
|
|
</Grid> |
|
|
|
<Grid item xs={7} s={7} md={7} lg={6}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key} |
|
|
|
name={key} |
|
|
|
type="text" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid>; |
|
|
|
} |
|
|
|
|
|
|
|
const getPhoneField=(label, key, key2, form)=>{ |
|
|
|
return <Grid item lg={4}> |
|
|
|
<Grid container alignItems={"center"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'center'}}> |
|
|
|
{label} |
|
|
|
</Grid> |
|
|
|
<Grid item xs={2}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key} |
|
|
|
name={key} |
|
|
|
type="number" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key2} |
|
|
|
name={key2} |
|
|
|
type="number" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key2]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid>; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
<MainCard elevation={0} |
|
|
@@ -159,85 +103,159 @@ const OrganizationCard_loadFromUser = ({userData, id}) => { |
|
|
|
<form onSubmit={formik.handleSubmit}> |
|
|
|
|
|
|
|
<Grid container spacing={1}> |
|
|
|
{/*bottom top*/} |
|
|
|
<Grid item s={12} md={12} lg={12} sx={{mb: 3}} alignItems={"start"} justifyContent="center"> |
|
|
|
|
|
|
|
|
|
|
|
<Grid item sx={{ml: 3, mr: 3}}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
type="submit" |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}} |
|
|
|
> |
|
|
|
Create |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
</Grid> |
|
|
|
{/*bottom top*/} |
|
|
|
{/*bottom top*/} |
|
|
|
<Grid item s={12} md={12} lg={12} sx={{mb: 3}} alignItems={"start"} justifyContent="center"> |
|
|
|
|
|
|
|
|
|
|
|
<Grid item sx={{ml: 3, mr: 3}}> |
|
|
|
<Button |
|
|
|
size="large" |
|
|
|
variant="contained" |
|
|
|
type="submit" |
|
|
|
sx={{ |
|
|
|
textTransform: 'capitalize', |
|
|
|
alignItems: 'end' |
|
|
|
}} |
|
|
|
> |
|
|
|
Create |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
</Grid> |
|
|
|
{/*bottom top*/} |
|
|
|
|
|
|
|
{getTextField("BR No.:","brNo",formik)} |
|
|
|
<Grid item lg={8}></Grid> |
|
|
|
{getTextField("Name (Eng):","enCompanyName",formik)} |
|
|
|
{getTextField("Name (Ch):","chCompanyName",formik)} |
|
|
|
{getTextField("Expiry Date:","brExpiryDate",formik)} {/* TODO: date field */} |
|
|
|
{getDateField("Expiry Date:","brExpiryDate",formik)} |
|
|
|
{getTextField("Contact Person:","contactPerson",formik)} |
|
|
|
{getPhoneField("Contact Tel:","tel_countryCode", "phoneNumber",formik)} |
|
|
|
{getPhoneField("Fax No.:","fax_countryCode", "faxNumber",formik)} |
|
|
|
{getTextField("Country:","country",formik)} |
|
|
|
{getTextField("District :","district", formik)} |
|
|
|
{getTextField("Expiry Date:","brExpiryDate",formik)} |
|
|
|
|
|
|
|
<Grid item lg={4} > |
|
|
|
<Grid container alignItems={"top"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'top'}}> |
|
|
|
<Grid item lg={12} sx={{alignItems: 'center'}}>Address :</Grid> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={6}> |
|
|
|
<Grid item lg={12}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("addressLine1")} |
|
|
|
id='addressLine1' |
|
|
|
|
|
|
|
inputProps={{ maxLength: 255 }} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={12}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("addressLine2")} |
|
|
|
id='addressLine2' |
|
|
|
|
|
|
|
inputProps={{ maxLength: 255 }} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={12}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
{...register("addressLine3")} |
|
|
|
id='addressLine3' |
|
|
|
|
|
|
|
inputProps={{ maxLength: 255 }} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
|
|
|
{getAddressField("Address:","addressLine1","addressLine2","addressLine3",formik)} |
|
|
|
</Grid> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</form> |
|
|
|
</MainCard> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
const getDateField=(label, key, form)=>{ |
|
|
|
return <Grid item lg={4} > |
|
|
|
<Grid container alignItems={"center"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'center'}}> |
|
|
|
{label} |
|
|
|
</Grid> |
|
|
|
<Grid item xs={7} s={7} md={7} lg={6}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key} |
|
|
|
name={key} |
|
|
|
type="date" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid>; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getTextField=(label, key, form)=>{ |
|
|
|
return <Grid item lg={4} > |
|
|
|
<Grid container alignItems={"center"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'center'}}> |
|
|
|
{label} |
|
|
|
</Grid> |
|
|
|
<Grid item xs={7} s={7} md={7} lg={6}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key} |
|
|
|
name={key} |
|
|
|
type="text" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid>; |
|
|
|
} |
|
|
|
|
|
|
|
const getPhoneField=(label, key, key2, form)=>{ |
|
|
|
return <Grid item lg={4}> |
|
|
|
<Grid container alignItems={"center"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'center'}}> |
|
|
|
{label} |
|
|
|
</Grid> |
|
|
|
<Grid item xs={2}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key} |
|
|
|
name={key} |
|
|
|
type="number" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={4}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key2} |
|
|
|
name={key2} |
|
|
|
type="number" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key2]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid>; |
|
|
|
} |
|
|
|
|
|
|
|
const getAddressField=(label, key, key2, key3, form)=>{ |
|
|
|
return <Grid item lg={4} > |
|
|
|
<Grid container alignItems={"top"}> |
|
|
|
<Grid item xs={4} s={4} md={4} lg={4} |
|
|
|
sx={{ml: 3, mr: 3, display: 'flex', alignItems: 'top'}}> |
|
|
|
<Grid item lg={12} sx={{alignItems: 'center'}}>{label}</Grid> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={6}> |
|
|
|
<Grid item lg={12}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key} |
|
|
|
name={key} |
|
|
|
type="text" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={12}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key2} |
|
|
|
name={key2} |
|
|
|
type="text" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key2]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
<Grid item lg={12}> |
|
|
|
<TextField |
|
|
|
fullWidth |
|
|
|
id={key3} |
|
|
|
name={key3} |
|
|
|
type="text" |
|
|
|
onChange={form.handleChange} |
|
|
|
value={form.values[key3]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
</Grid>; |
|
|
|
} |
|
|
|
|
|
|
|
export default OrganizationCard_loadFromUser; |