This commit is contained in:
Malai Raja
2023-12-14 18:31:11 +05:30
parent a38ff4f960
commit fa38e252c3
4 changed files with 597 additions and 372 deletions

View File

@@ -62,13 +62,13 @@ const Createclient = () => {
const [suburb, setSuburb] = useState('');
const [latlong, setLatlong] = useState({});
const [profiledetails, setProfiledetails] = useState({});
const [primarycontact,setPrimarycontact]=useState('')
const [firstname,setFirstname]=useState('');
const [doorno,setDoorno]=useState('');
const [landmark,setLandmark]=useState('');
const [primarycontact, setPrimarycontact] = useState('')
const [firstname, setFirstname] = useState('');
const [doorno, setDoorno] = useState('');
const [landmark, setLandmark] = useState('');
const [tenantinfo, setTenantinfo] = useState({});
const navigate = useNavigate();
@@ -81,7 +81,7 @@ const Createclient = () => {
useEffect(() => {
// fetchprofiledetails(localStorage.getItem('appuserid'));
// fetchprofiledetails(181);
if(localStorage.getItem('tenantid')){
if (localStorage.getItem('tenantid')) {
fetchtenantinfo(localStorage.getItem('tenantid'))
}
}, [])
@@ -106,7 +106,7 @@ const Createclient = () => {
console.log(error)
}
);
} catch (err) {
console.log(err)
@@ -193,7 +193,7 @@ const Createclient = () => {
console.log(place)
setAddress(place.formatted_address)
let city1, zipcode1, state1,suburb1;
let city1, zipcode1, state1, suburb1;
for (let i = 0; i < place.address_components.length; i++) {
for (let j = 0; j < place.address_components[i].types.length; j++) {
switch (place.address_components[i].types[j]) {
@@ -232,17 +232,17 @@ const Createclient = () => {
const createprofile = async () => {
console.log('res', businessname, businessno, mobilenumber, emailaddress, address, city, zipcode)
if (!businessname) {
opentoast('Fill Business name')
} else if (!businessno) {
opentoast('Fill Registration No')
} else if (!businessno) {
opentoast('Fill Registration No')
} else if (!firstname) {
// if (!businessname) {
// opentoast('Fill Business name')
// } else if (!businessno) {
// opentoast('Fill Registration No')
// }
// else
if (!firstname) {
opentoast('Fill Full name')
} else if (!mobilenumber) {
} else if (!mobilenumber) {
opentoast('Fill Mobile Number')
}else if (!emailaddress) {
} else if (!emailaddress) {
opentoast('Fill emailaddress')
} else if (!address) {
opentoast('Fill Address')
@@ -250,45 +250,46 @@ const Createclient = () => {
opentoast('Fill City')
} else if (!zipcode) {
opentoast('Fill post code')
} else if (!suburb) {
} else if (!suburb) {
opentoast('Fill suburb')
} else if (!emailaddress) {
opentoast('Fill emailaddress')
} else if (!latlong.lat || !latlong.lng) {
opentoast('Choose valid address')
} else {
let obj={
"customerid":0,
"configid":1,
"firstname":firstname,
"applocationid":tenantinfo.applolcationid,
"profileimage":"",
"dialcode":"+91",
"contactno":mobilenumber,
"devicetype":"",
"deviceid":"",
"customertoken":"",
"address":address,
"suburb":suburb,
"city":city,
"state":state,
"postcode":zipcode,
"landmark":landmark,
"doorno":doorno,
"latitude":latlong.lat.toString(),
"longitude":latlong.lng.toString(),
"tenantid":parseInt(localStorage.getItem('tenantid'))
} else {
let obj = {
"customerid": 0,
"configid": 1,
"firstname": firstname,
"applocationid": tenantinfo.applolcationid,
"profileimage": "",
"dialcode": "+91",
"contactno": mobilenumber,
"devicetype": "",
"deviceid": "",
"customertoken": "",
"address": address,
"suburb": suburb,
"city": city,
"state": state,
"postcode": zipcode,
"landmark": landmark,
"doorno": doorno,
"latitude": latlong.lat.toString(),
"longitude": latlong.lng.toString(),
"tenantid": parseInt(localStorage.getItem('tenantid')),
"email" : emailaddress
}
console.log(obj)
setLoading(true)
try {
await axios.post(`${process.env.REACT_APP_URL}/customers/create`,obj)
await axios.post(`${process.env.REACT_APP_URL}/customers/create`, obj)
.then((res) => {
console.log(res)
if (res.data.status) {
enqueueSnackbar(' Created Successfully ', {
variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
@@ -298,7 +299,7 @@ const Createclient = () => {
// fetchprofiledetails(localStorage.getItem('appuserid'));
// },2000)
}else if(res.data.message == "Customer Already available"){
} else if (res.data.message == "Customer Already available") {
enqueueSnackbar("Customer Already available", {
variant: 'error', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
@@ -307,7 +308,7 @@ const Createclient = () => {
setLoading(false)
}).catch((err) => {
console.log(err)
setLoading(false)
enqueueSnackbar(err.message, {
variant: 'error', anchorOrigin: { vertical: 'top', horizontal: 'right' },
@@ -341,7 +342,7 @@ const Createclient = () => {
</Grid>
<MainCard>
<Grid container spacing={3}>
<Grid item xs={12} sm={4} >
{/* <Grid item xs={12} sm={4} >
<MainCard title="Personal Information" sx={{ height: '100%' }}>
<Grid container spacing={3}>
<Grid item xs={12}>
@@ -398,44 +399,18 @@ const Createclient = () => {
<Grid item xs={12}
>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-first-name">Business Name</InputLabel>
<TextField fullWidth
id="personal-first-name" placeholder="Business Name" autoFocus
onChange={(e) => setBusinessname(e.target.value)}
value={businessname}
autoComplete='off'
/>
</Stack>
</Grid>
<Grid item xs={12}
>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-last-name">Registration No</InputLabel>
<TextField fullWidth
id="personal-last-name" placeholder="Registration No"
onChange={(e) => setBusinessno(e.target.value)}
value={businessno}
autoComplete='off'
/>
</Stack>
</Grid>
<Grid item xs={12}
>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-last-name">Name</InputLabel>
<TextField fullWidth
id="personal-last-name" placeholder="Name"
onChange={(e) => setFirstname(e.target.value)}
value={firstname}
autoComplete='off'
/>
</Stack>
</Grid>
{/* <Grid item xs={12}
<Grid item xs={12}
>
<Stack spacing={1.25}>
@@ -449,24 +424,65 @@ const Createclient = () => {
/>
</Stack>
</Grid> */}
</Grid>
</Grid>
</MainCard>
</Grid>
<Grid item xs={12} sm={8} >
</Grid> */}
<Grid item xs={12}
// sm={8}
>
<MainCard title="Contact Information" sx={{ height: '100%' }}>
<MainCard
// title="Contact Information"
sx={{ height: '100%' }}>
<Grid container spacing={3}>
<Grid item xs={12}
{/* <Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-first-name">Business Name</InputLabel>
<TextField fullWidth
id="personal-first-name" placeholder="Business Name" autoFocus
onChange={(e) => setBusinessname(e.target.value)}
value={businessname}
autoComplete='off'
/>
</Stack>
</Grid>
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-last-name">Registration No</InputLabel>
<TextField fullWidth
id="personal-last-name" placeholder="Registration No"
onChange={(e) => setBusinessno(e.target.value)}
value={businessno}
autoComplete='off'
/>
</Stack>
</Grid> */}
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-last-name">Admin Name</InputLabel>
<TextField fullWidth
id="personal-last-name" placeholder="Name"
onChange={(e) => setFirstname(e.target.value)}
value={firstname}
autoComplete='off'
/>
</Stack>
</Grid>
<Grid item xs={12} sm={6}>
</Grid>
<Grid item xs={12} sm={6}
>
<Stack spacing={1.25} >
<InputLabel htmlFor="personal-phone">Phone Number</InputLabel>
<Stack direction="row" justifyContent="space-between" alignItems="center"
spacing={2}>
<Select defaultValue="+1" disabled sx={{cursor: 'not-allowed'}}>
<Stack direction="row" justifyContent="space-between" alignItems="center"
spacing={2}>
<Select defaultValue="+1" disabled sx={{ cursor: 'not-allowed' }}>
<MenuItem value="+1">+91</MenuItem>
</Select>
<TextField
type='number'
@@ -478,21 +494,21 @@ const Createclient = () => {
placeholder="Phone Number"
// defaultValue="8654239581"
// onBlur={() => { }}
onChange={(e) => {
if(e.target.value.toString().length <= 10){
onChange={(e) => {
if (e.target.value.toString().length <= 10) {
setMobilenumber(e.target.value)
}
}}
}}
value={mobilenumber}
autoComplete='off'
// disabled
sx={{cursor: 'not-allowed'}}
sx={{ cursor: 'not-allowed' }}
/>
</Stack>
</Stack>
</Grid>
<Grid item xs={12}
// sm={6}
sm={6}
>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-email">Email Address</InputLabel>
@@ -506,7 +522,7 @@ const Createclient = () => {
/>
</Stack>
</Grid>
<Grid item xs={12}>
<Stack spacing={1.25}>
@@ -578,7 +594,7 @@ const Createclient = () => {
/>
</Stack>
</Grid>
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-location">Door No</InputLabel>
@@ -593,7 +609,7 @@ const Createclient = () => {
</Stack>
</Grid>
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-email">Landmark</InputLabel>
<TextField type="email" fullWidth
// defaultValue="stebin.ben@gmail.com"
@@ -604,7 +620,7 @@ const Createclient = () => {
/>
</Stack>
</Grid>
</Grid>
</Grid>
</MainCard>