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

Submodule nearlexpressbuild updated: 7af311220e...088ac08a24

View File

@@ -167,27 +167,21 @@ const Accountsettings = () => {
<Grid item xs={12} > <Grid item xs={12} >
<MainCard <MainCard
// title="Other Details" // title={ <Stack direction="row" alignItems="center" spacing={1} justifyContent="flex-start">
title={ <Stack direction="row" alignItems="center" spacing={1} justifyContent="flex-start"> // <Avatar
<Avatar // alt=""
alt="" // size="sm"
size="sm" // sx={{
// src={row.profileimage} // width: '25px',
sx={{ // height: '25px'
width: '25px', // }}
height: '25px' // >
}}
>
</Avatar> // </Avatar>
<Stack direction="column"> // <Stack direction="column">
<Typography variant="caption">{info.companyname}</Typography> // <Typography variant="caption">{info.companyname}</Typography>
{/* <Typography variant="caption" color="textSecondary"> // </Stack>
// </Stack>}
{info.registrationno}
</Typography> */}
</Stack>
</Stack>}
> >
<List sx={{ py: 0 }}> <List sx={{ py: 0 }}>
<ListItem divider={!matchDownMD}> <ListItem divider={!matchDownMD}>
@@ -199,11 +193,28 @@ const Accountsettings = () => {
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={12} md={6}> <Grid item xs={12} md={6}>
<Stack spacing={0.5}> <Stack spacing={0.5}>
<Typography color="secondary">Company Name</Typography>
<Typography>{info.companyname || ''}</Typography>
</Stack>
</Grid>
</Grid>
</ListItem>
<ListItem divider={!matchDownMD}>
<Grid container spacing={3}>
<Grid item xs={12} md={6}>
<Stack spacing={0.5}>
<Typography color="secondary">Registration No</Typography> <Typography color="secondary">Registration No</Typography>
<Typography>{info.registrationno || ''}</Typography> <Typography>{info.registrationno || ''}</Typography>
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={12} md={6}>
<Stack spacing={0.5}>
<Typography color="secondary">Info</Typography>
<Typography>{info.info || ''}</Typography>
</Stack>
</Grid>
</Grid> </Grid>
</ListItem> </ListItem>
<ListItem divider={!matchDownMD}> <ListItem divider={!matchDownMD}>
@@ -266,13 +277,13 @@ const Accountsettings = () => {
</List> </List>
</MainCard> </MainCard>
</Grid> </Grid>
<Grid item xs={12}> {/* <Grid item xs={12}>
<MainCard title="Info"> <MainCard title="Info">
<Typography color="secondary"> <Typography color="secondary">
{info.info || ''} {info.info || ''}
</Typography> </Typography>
</MainCard> </MainCard>
</Grid> </Grid> */}
</Grid> </Grid>
</Grid> </Grid>

View File

@@ -10,7 +10,17 @@ import { useState, Fragment } from 'react';
// import AccessTimeOutlinedIcon from '@mui/icons-material/AccessTimeOutlined'; // import AccessTimeOutlinedIcon from '@mui/icons-material/AccessTimeOutlined';
// import CustomerCard from 'sections/apps/customer/CustomerCard'; // import CustomerCard from 'sections/apps/customer/CustomerCard';
// import CustomerCardPage from 'pages/apps/customer/card'; // import CustomerCardPage from 'pages/apps/customer/card';
import { DeleteFilled, NotificationOutlined } from '@ant-design/icons'; import { usePlacesWidget } from "react-google-autocomplete";
import Autocomplete from "react-google-autocomplete";
import { Autocomplete as Autocomplete1 } from '@mui/material';
import Geocode from "react-geocode";
import {
DeleteFilled,
NotificationOutlined,
// EditTwoTone,
} from '@ant-design/icons';
import { Empty } from 'antd'; import { Empty } from 'antd';
import { import {
@@ -43,14 +53,18 @@ import {
// TableSortLabel, // TableSortLabel,
TableRow, TableRow,
Tooltip, Tooltip,
// List, List,
// ListItem, ListItem,
// ListItemIcon, ListItemIcon,
FormControl, FormControl,
OutlinedInput, OutlinedInput,
InputAdornment, InputAdornment,
Popper, Popper,
ClickAwayListener, ClickAwayListener,
InputLabel,
TextField,
Select,
MenuItem,
// Tooltip, // Tooltip,
// Badge, // Badge,
// Avatar // Avatar
@@ -78,6 +92,7 @@ import {
// PhoneOutlined, // PhoneOutlined,
// // EditTwoTone, // // EditTwoTone,
DeleteTwoTone, DeleteTwoTone,
EditTwoTone,
CheckCircleOutlined, CheckCircleOutlined,
MoreOutlined MoreOutlined
@@ -353,11 +368,118 @@ const Client = () => {
const [loading1, setLoading1] = useState(false); const [loading1, setLoading1] = useState(false);
const [staffdetaillist, setStaffdetaillist] = useState([]); const [staffdetaillist, setStaffdetaillist] = useState([]);
const [anchorEl, setAnchorEl] = React.useState(null); const [anchorEl, setAnchorEl] = React.useState(null);
const [currentcustomerid, setCurrentcustomerid] = useState('') const [currentcustomerid, setCurrentcustomerid] = useState('');
const [businessname, setBusinessname] = useState('');
const [businessno, setBusinessno] = useState('');
// const [role, setRole] = useState('');
const [mobilenumber, setMobilenumber] = useState('')
const [emailaddress, setEmailaddress] = useState('')
const [city, setCity] = useState('')
const [zipcode, setZipcode] = useState('');
const [address, setAddress] = useState('');
const [state, setState] = useState('');
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 [tenantinfo, setTenantinfo] = useState({});
Geocode.setApiKey(process.env.REACT_APP_GOOGLE_MAPS_API_KEY);
const handleClickAway = () => { const handleClickAway = () => {
setOpen(''); setOpen('');
}; };
useEffect(()=>{
const fetchtenantinfo = async (tid) => {
// setLoading(true)
await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantinfo/?tenantid=${tid}`)
.then((res) => {
console.log(res)
if (res.data.status) {
setTenantinfo(res.data.details);
}
// setLoading(false)
}).catch((err) => {
console.log(err)
// setLoading(false)
})
}
if(localStorage.getItem('tenantid')){
fetchtenantinfo(localStorage.getItem('tenantid'))
}
},[])
useEffect(() => {
try {
Geocode.fromAddress(address).then(
(response) => {
if (response.status == 'OK') {
const { lat, lng } = response.results[0].geometry.location;
setLatlong({
lat, lng
})
console.log(response);
}
}, (error) => {
console.log(error)
}
);
} catch (err) {
console.log(err)
}
}, [address])
const { ref: materialRef } = usePlacesWidget({
apiKey: process.env.REACT_APP_GOOGLE_MAPS_API_KEY,
onPlaceSelected: (place) => {
console.log(place)
setAddress(place.formatted_address)
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]) {
case "locality":
city1 = place.address_components[i].long_name;
break;
case "administrative_area_level_1":
state1 = place.address_components[i].long_name;
break;
case "postal_code":
zipcode1 = place.address_components[i].long_name;
break;
case "sublocality":
suburb1 = place.address_components[i].long_name;
break;
}
}
}
setCity(city1 || '')
setState(state1 || '');
setZipcode(zipcode1 || '');
setSuburb(suburb1 || '')
// setAddress(place.formatted_address)
},
// inputAutocompleteValue: "country",
options: {
// componentRestrictions: 'us',
// types: ["establishment"]
types: ['address' || 'geocode']
},
});
// const fetchstafflog = async (uid, sid) => { // const fetchstafflog = async (uid, sid) => {
// setLoading1(true) // setLoading1(true)
// try { // try {
@@ -494,6 +616,98 @@ const Client = () => {
} }
} }
const updateclient = async (sid) => {
console.log({
"customerid": 1364,
"configid": 1,
"firstname": firstname,
"applocationid":tenantinfo.applolcationid,
"profileimage": "",
"dialcode": "+91",
"contactno": mobilenumber,
"devicetype": "",
"deviceid": "",
// "customertoken": "123",
"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,regno,tenantname
})
setLoading(true)
try {
// await axios.get(`${process.env.REACT_APP_URL2}/orders/getorderprocessbystatus`)
await axios.put(`${process.env.REACT_APP_URL}/staffs/earnings/update12`,
{
"customerid": 1364,
"configid": 1,
"firstname": firstname,
"applocationid":tenantinfo.applolcationid,
"profileimage": "",
"dialcode": "+91",
"contactno": mobilenumber,
"devicetype": "",
"deviceid": "",
// "customertoken": "123",
"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,regno,tenantname
}
)
.then((res) => {
console.log(res)
if (res.data.status) {
// let arr = []
// res.data.Details.map((val, i) => {
// arr = [...arr, { ...val, sno: i + 1 }];
// })
// // setArr(arr)
// setRows(arr)
// console.log(res.data.Details)
// console.log(arr)
// setLoading(false)
enqueueSnackbar("Updated Successfully", {
variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
})
// setTimeout(() => {
// if (localStorage.getItem('appuserid')) {
// fetchtable(localStorage.getItem('appuserid'))
// }
// }, 2000)
}
}).catch((err) => {
console.log(err)
setLoading(false)
})
} catch (err) {
console.log(err);
setLoading(false)
}
}
const handleRequestSort = (event, property) => { const handleRequestSort = (event, property) => {
const isAsc = orderBy === property && order === 'asc'; const isAsc = orderBy === property && order === 'asc';
@@ -1070,6 +1284,25 @@ const Client = () => {
<DeleteTwoTone twoToneColor={theme.palette.error.main} /> <DeleteTwoTone twoToneColor={theme.palette.error.main} />
</IconButton> </IconButton>
</Tooltip> </Tooltip>
{(false) &&
<IconButton onClick={() => {
setFirstname(row.firstname);
setAddress(row.address)
setMobilenumber(row.contactno)
// setEmailaddress(row.)
setSuburb(row.suburb)
setCity(row.city)
setState(row.state)
setZipcode(row.postcode)
setDoorno(row.doorno)
setLandmark(row.landmark)
setExpandopen((expandopen === row.sno) ? '' : row.sno)
}}>
<EditTwoTone />
</IconButton>
}
</TableCell> </TableCell>
</TableRow> </TableRow>
@@ -1078,275 +1311,240 @@ const Client = () => {
<Collapse in={(expandopen === row.sno)} timeout="auto" unmountOnExit > <Collapse in={(expandopen === row.sno)} timeout="auto" unmountOnExit >
<Grid container sx={{ width: '100%' }}> <Grid container sx={{ width: '100%' }}>
<Grid item sx={{ width: '100%', m: 1 }}> <Grid item sx={{ width: '100%', m: 1 }}>
<MainCard title='Staffs'> <MainCard
title="Details"
{/* <TableContainer> sx={{ height: '100%' }}>
<Table sx={{ p: 2 }}> <Grid container spacing={1}>
<TableHead> {/* <Grid item xs={12} sm={6}>
<TableRow> <Stack spacing={1.25}>
<TableCell>Contact Name</TableCell> <InputLabel htmlFor="personal-first-name">Business Name</InputLabel>
<TableCell>Contact No</TableCell> <TextField fullWidth
id="personal-first-name" placeholder="Business Name" autoFocus
</TableRow> onChange={(e) => setBusinessname(e.target.value)}
</TableHead> value={businessname}
autoComplete='off'
<TableBody> />
{(row.ordercontacts.map((val) => {
return <>
<TableRow>
<TableCell>{val.contactname}</TableCell>
<TableCell>{val.contactno}</TableCell>
</TableRow>
</>
}))
}
</TableBody>
</Table>
</TableContainer> */}
{(loading1) ?
<>
<Stack alignItems={'center'}>
<CircularProgress />
</Stack> </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' }}>
<MenuItem value="+1">+91</MenuItem>
<TableContainer> </Select>
<Table> <TextField
<TableHead> type='number'
<TableRow> id='personal-phone'
<TableCell>#</TableCell> // format="##########"
<TableCell>Staff</TableCell> // mask="_"
<TableCell>Start Time</TableCell> fullWidth
<TableCell>End Time</TableCell> // customInput={TextField}
{/* <TableCell>Pay Rate</TableCell> */} placeholder="Phone Number"
// defaultValue="8654239581"
// onBlur={() => { }}
onChange={(e) => {
if (e.target.value.toString().length <= 10) {
setMobilenumber(e.target.value)
}
}}
value={mobilenumber}
autoComplete='off'
// disabled
sx={{ cursor: 'not-allowed' }}
/>
</Stack>
</Stack>
</Grid>
<Grid item xs={12}
sm={6}
>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-email">Email Address</InputLabel>
<TextField type="email" fullWidth
// defaultValue="stebin.ben@gmail.com"
id="personal-email" placeholder="Email Address"
onChange={(e) => setEmailaddress(e.target.value)}
value={emailaddress}
autoComplete='off'
{/* <TableCell>Category</TableCell> */} />
<TableCell align='center'>Clockin</TableCell> </Stack>
<TableCell align='center'>Clockout</TableCell> </Grid>
<TableCell>Actual Hrs</TableCell>
<TableCell>Hrs Worked</TableCell>
<TableCell>OT</TableCell>
<TableCell>Deficit</TableCell>
{/* <TableCell>Experience</TableCell> */}
{/* <TableCell>Level</TableCell> */}
{/* <TableCell>City</TableCell> */}
<TableCell>Status</TableCell>
<TableCell>Action</TableCell>
</TableRow>
</TableHead>
<TableBody>
{/* {row.ordeprocessInfo.map((val, i) => { */}
{staffdetaillist.map((val, i) => {
return <Fragment key={i}>
<TableRow sx={{ <Grid item xs={12}>
// backgroundColor: (staffarr.find((res) => res.userid == val.userid)) ? '#f5f5f5' : '', ':hover': { <Stack spacing={1.25}>
// backgroundColor: (staffarr.find((res) => res.userid == val.userid)) ? '#f5f5f5 !important' : '' <InputLabel htmlFor="personal-address">Address</InputLabel>
// } <Autocomplete
}}> className='automap'
<TableCell component="th" apiKey={process.env.REACT_APP_GOOGLE_MAPS_API_KEY}
scope="row" padding="none"> style={{
{i + 1} width: "100%", height: '40px', borderRadius: '5px',
</TableCell> border: '1px solid #e0e0e0', textIndent: '10px', outline: 'none',
// ':hover': {
// border: '1px solid #00b0ff !important',
// backgroundColor:'blue'
// }
}}
onPlaceSelected={(place) => {
setAddress(place.formatted_address)
let city1, state, zipcode1, 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]) {
case "locality":
city1 = place.address_components[i].long_name;
break;
case "administrative_area_level_1":
state = place.address_components[i].long_name;
break;
case "postal_code":
zipcode1 = place.address_components[i].long_name;
break;
case "sublocality":
suburb1 = place.address_components[i].long_name;
break;
}
}
}
setCity(city1 || '')
setState(state || '');
setZipcode(zipcode1 || '');
setSuburb(suburb1 || '')
}}
options={{
<TableCell align="left"> types: ['address' || 'geocode']
<Stack direction="column">
<Typography variant="caption">
{val.staffname}
</Typography>
<Grid>
<Chip label={val.productname} color="info" variant="light" size="small" />
</Grid>
</Stack>
</TableCell>
<TableCell>
<Stack direction="column">
<Typography variant="body2">{dayjs(val.starttime)
// .utc()
.format('MM/DD/YYYY')}</Typography>
<Typography variant="caption">{dayjs(val.starttime)
// .utc()
.format('hh:mm A')}</Typography>
</Stack>
</TableCell>
<TableCell>
<Stack direction="column">
<Typography variant="body2">{dayjs(val.endtime)
// .utc()
.format('MM/DD/YYYY')}</Typography>
<Typography variant="caption">{dayjs(val.endtime)
// .utc()
.format('hh:mm A')}</Typography>
</Stack>
</TableCell>
{/* <TableCell>{val.rolecost}</TableCell> */}
}}
placeholder='Address'
value={address}
onChange={(e) => setAddress(e.target.value)}
/>
</Stack>
</Grid>
<TableCell> <Grid item xs={12} sm={6}>
<Stack spacing={0.5} <Stack spacing={1.25}>
alignItems="center" <InputLabel htmlFor="personal-location">Suburb</InputLabel>
> <TextField fullWidth
<Chip label={(val.clockin) ? dayjs(val.clockin).format('MM/DD/YYYY') : ''} color="primary" variant="light" size="small" /> // defaultValue="New York"
<Chip label={(val.clockin) ? dayjs(val.clockin).format('hh:mm A') : ''} color="info" variant="light" size="small" /> id="personal-location" placeholder="Location"
onChange={(e) => setSuburb(e.target.value)}
value={suburb}
autoComplete='off'
</Stack> />
</TableCell> </Stack>
<TableCell> </Grid>
<Stack spacing={0.5} <Grid item xs={12} sm={6}>
alignItems="center" <Stack spacing={1.25}>
> <InputLabel htmlFor="personal-zipcode">City</InputLabel>
<Chip label={(val.clockout) ? dayjs(val.clockout).format('MM/DD/YYYY') : ''} color="primary" variant="light" size="small" /> <TextField fullWidth
<Chip label={(val.clockout) ? dayjs(val.clockout).format('hh:mm A') : ''} color="info" variant="light" size="small" /> // defaultValue="956754"
// type='number'
id="personal-zipcode" placeholder="City"
onChange={(e) => setCity(e.target.value)}
value={city}
autoComplete='off'
</Stack> />
</TableCell> </Stack>
<TableCell>{val.workhours}</TableCell> </Grid>
<TableCell>
{val.hoursworked}
</TableCell>
<TableCell>{val.overtime}</TableCell>
<TableCell>{val.shorttime}</TableCell>
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-location">State</InputLabel>
<TextField fullWidth
// defaultValue="New York"
id="personal-location" placeholder="State"
onChange={(e) => setState(e.target.value)}
value={state}
autoComplete='off'
/>
</Stack>
</Grid>
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-zipcode">Post Code</InputLabel>
<TextField fullWidth
// defaultValue="956754"
type='number'
id="personal-zipcode" placeholder="Zipcode"
onChange={(e) => setZipcode(e.target.value)}
value={zipcode}
autoComplete='off'
<TableCell align="left"> />
<Stack direction="row"> </Stack>
</Grid>
{(val.orderstatus === 'pending') && <Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-location">Door No</InputLabel>
<TextField fullWidth
// defaultValue="New York"
id="personal-location" placeholder="Door No"
onChange={(e) => setDoorno(e.target.value)}
value={doorno}
autoComplete='off'
<Chip label="Pending" color="error" size="small" /> />
} </Stack>
{(val.orderstatus === 'cancelled') && </Grid>
<Grid item xs={12} sm={6}>
<Stack spacing={1.25}>
<InputLabel htmlFor="personal-email">Landmark</InputLabel>
<TextField type="email" fullWidth
// defaultValue="stebin.ben@gmail.com"
id="personal-email" placeholder="Landmark"
onChange={(e) => setLandmark(e.target.value)}
value={landmark}
autoComplete='off'
/>
<Chip label="Cancelled" color="secondary" size="small" /> </Stack>
} </Grid>
{(val.orderstatus === 'completed') && <Grid item xs={12}>
<Stack direction={'row'} justifyContent={'flex-end'} sx={{width:'100%'}}>
<Chip label="Completed" color="primary" size="small" /> <Button variant='contained' onClick={()=>{
} updateclient()
{(val.orderstatus === 'processing') && }}>Update</Button>
<Chip label="Processing" color="primary" size="small" /> </Stack>
} </Grid>
{(val.orderstatus === 'assigned') && </Grid>
<Chip label="Assigned" color="warning" size="small" />
}
{(val.orderstatus === 'confirmed') &&
<Chip label="Confirmed" color="success" size="small" />
}
{(val.orderstatus === 'active') &&
<Chip label="Active" color="info" size="small" />
}
{(val.orderstatus === 'closed') &&
<Chip label="Closed" color="info" size="small" />
}
</Stack>
</TableCell>
<TableCell>
<Stack direction='row'>
{((val.verified == 0) && (val.orderstatus === 'completed')) &&
<>
<IconButton
// onClick={(e) => handleClick1(e, row.sno)}
onClick={(e) => {
setOpen(i + 1)
setAnchorEl(e.currentTarget);
}}
aria-describedby={`aria-${row.sno}`}
>
<MoreOutlined />
</IconButton>
<Popper id={`aria-${row.sno}`} open={(open == (i + 1))}
anchorEl={anchorEl}
placement='bottom-end'
sx={{
zIndex: 5000,
p: 0
}}
>
<Box sx={{ backgroundColor: '#fff', px: 2, py: 1, cursor: 'pointer', boxShadow: theme.customShadows.z1 }}
onClick={() => {
// setApproveid(true)
// setDisableid(false)
// setExpandopen('')
// setRolestab(0)
staffearningsverify(val.staffearningsid)
// fetchclientbyid(row.tenantid, row.sno);
// fetchclientpricing(row.tenantid)
// setEditexpandopen(row.sno)
handleClickAway()
}}
>
<ClickAwayListener onClickAway={handleClickAway}>
<Typography>Verify</Typography>
</ClickAwayListener>
</Box>
</Popper>
</>
}
{(val.verified == 1) &&
<>
<Tooltip title='Verified' >
<IconButton
>
<CheckCircleOutlined
style={{ color: '#4caf50' }}
/>
</IconButton>
</Tooltip>
</>
}
</Stack>
</TableCell>
</TableRow>
</Fragment>
})
}
</TableBody>
</Table>
</TableContainer>
}
</MainCard> </MainCard>
</Grid></Grid> </Grid></Grid>
</Collapse> </Collapse>

View File

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