createOrder

This commit is contained in:
joshikannan
2024-04-07 01:43:09 +05:30
parent 7999e136ad
commit f5eb2eb201
5 changed files with 2936 additions and 406 deletions

View File

@@ -40,7 +40,7 @@ import { useNavigate } from 'react-router';
// } // }
// }; // };
const Createclient = () => { const CreateCustomer = () => {
const theme = useTheme(); const theme = useTheme();
const [selectedImage, setSelectedImage] = useState(undefined); const [selectedImage, setSelectedImage] = useState(undefined);
const [avatar, setAvatar] = useState(); const [avatar, setAvatar] = useState();
@@ -657,4 +657,4 @@ const Createclient = () => {
); );
}; };
export default Createclient; export default CreateCustomer;

View File

@@ -148,7 +148,7 @@ const BootstrapDialog = styled(Dialog)(({ theme }) => ({
} }
})); }));
const Clients1 = () => { const Customers = () => {
const theme = useTheme(); const theme = useTheme();
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -2211,4 +2211,4 @@ const Clients1 = () => {
); );
}; };
export default Clients1; export default Customers;

View File

@@ -114,6 +114,30 @@ const Createorder1 = () => {
const autocompleteService = useRef(null); const autocompleteService = useRef(null);
const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid')); const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid'));
const [isLocation, setIsLocation] = useState(false); const [isLocation, setIsLocation] = useState(false);
const textFieldRef1 = useRef(null);
const textFieldRef2 = useRef(null);
const handleOkClick1 = () => {
// Set focus back to the text field after clicking the "OK" chip
if (textFieldRef1.current) {
textFieldRef1.current.focus();
}
};
const handleOkClick2 = () => {
// Set focus back to the text field after clicking the "OK" chip
if (textFieldRef2.current) {
textFieldRef2.current.focus();
}
};
const top100Films = [
{ label: 'The Shawshank Redemption', year: 1994 },
{ label: 'The Godfather', year: 1972 },
{ label: 'The Godfather: Part II', year: 1974 },
{ label: 'The Dark Knight', year: 2008 },
{ label: '12 Angry Men', year: 1957 }
];
// // // ====================================================== || address (pick)|| ====================================================== // // // ====================================================== || address (pick)|| ======================================================
// useEffect(() => { // useEffect(() => {
@@ -467,11 +491,6 @@ const Createorder1 = () => {
} }
}; };
useEffect(() => {
clientdetails();
// clientdetailsbusiness();
}, [searchCustList.length > 3, searchCustList == '']);
useEffect(() => { useEffect(() => {
if (timeslotarr[0]) { if (timeslotarr[0]) {
let arr = []; let arr = [];
@@ -912,6 +931,7 @@ const Createorder1 = () => {
} else { } else {
try { try {
const createRes = await axios.post(`${process.env.REACT_APP_URL2}/orders/createorder`, arr); const createRes = await axios.post(`${process.env.REACT_APP_URL2}/orders/createorder`, arr);
// const createRes = await axios.post(`${process.env.REACT_APP_URL}/orders/createorder`, arr);
if (createRes.data.status) { if (createRes.data.status) {
console.log('createRes', createRes); console.log('createRes', createRes);
enqueueSnackbar('Order Created Successfully', { enqueueSnackbar('Order Created Successfully', {
@@ -958,7 +978,7 @@ const Createorder1 = () => {
try { try {
let url = let url =
searchCustList == '' searchCustList == ''
? `${process.env.REACT_APP_URL}/customers/getbytid/?tenantid=${tid}&pageno=1&pagesize=10` ? `${process.env.REACT_APP_URL}/customers/getbytid/?tenantid=${tid}&pageno=1&pagesize=1`
: `${process.env.REACT_APP_URL}/customers/search/?tenantid=${tid}&keyword=${searchCustList}`; : `${process.env.REACT_APP_URL}/customers/search/?tenantid=${tid}&keyword=${searchCustList}`;
await axios await axios
@@ -989,6 +1009,11 @@ const Createorder1 = () => {
setLoading2(false); setLoading2(false);
} }
}; };
useEffect(() => {
console.log('clientdetails, by search');
clientdetails();
// clientdetailsbusiness();
}, [searchCustList.length > 3, searchCustList == '']);
// ========================================================= || clientdetailsbusiness || ========================================================= // ========================================================= || clientdetailsbusiness || =========================================================
const clientdetailsbusiness = async () => { const clientdetailsbusiness = async () => {
setLoading2(true); setLoading2(true);
@@ -1325,7 +1350,9 @@ const Createorder1 = () => {
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid item xs={12}> <Grid item xs={12}>
<Stack direction={'row'} justifyContent={'space-between'}> <Stack direction={'row'} justifyContent={'space-between'}>
<Typography variant="h5">Pickup</Typography> <Typography variant="h5" sx={{ mb: 0 }}>
Pickup Details
</Typography>
<Stack direction={'row'} spacing={1} alignItems={'center'}> <Stack direction={'row'} spacing={1} alignItems={'center'}>
{/* <Typography>Customer</Typography> {/* <Typography>Customer</Typography>
<Switch <Switch
@@ -1344,7 +1371,7 @@ const Createorder1 = () => {
}} }}
/> />
<Typography>Business</Typography> */} <Typography>Business</Typography> */}
<Button {/* <Button
variant="outlined" variant="outlined"
sx={{ sx={{
'&:hover': { '&:hover': {
@@ -1366,111 +1393,128 @@ const Createorder1 = () => {
}} }}
> >
Saved Locations Saved Locations
</Button> </Button> */}
</Stack> </Stack>
</Stack> </Stack>
{/* new1 */}
{/* <Autocomplete <Autocomplete
id="free-solo-demo" disabled={!isLocation}
sx={{ mt: 2 }} fullWidth
// options={tenantlocationlist} disablePortal
options={pickupswitch ? clientdetailbusinessarr : clientdetailarr} id="combo-box-demo"
renderInput={(params) => <TextField {...params} label="Choose Location" />} // options={customerlist}
onChange={(e, val) => { options={clientdetailarr}
console.log(pickupswitch ? 'clientdetailbusinessarr value' : 'clientdetailarr value', val); getOptionLabel={(option) => `${option.firstname} (${option.contactno})`}
sx={{ mt: 2, mb: 1 }}
renderInput={(params) => (
<TextField
{...params}
label="Search"
onChange={(e) => {
setSearchCustList(e.target.value);
}}
InputProps={{
...params.InputProps,
inputProps: {
...params.inputProps,
maxLength: 10
}
}}
/>
)}
onChange={(e, val, reason) => {
if (val) { if (val) {
// clientdetails(val.tenantid) console.log('pickcustNew', val);
if (clientinfo.customerid == val.customerid) {
opentoast('choose different Location', 'warning');
setTenantinfo({});
} else {
setTenantinfo(val);
}
} else {
setTenantinfo({});
}
console.log(val);
setStartPoint({ latitude: val.latitude, longitude: val.longitude }); setStartPoint({ latitude: val.latitude, longitude: val.longitude });
setPickCust(val);
setAddId1(1);
setSearchCustList('');
}
if (reason == 'clear') {
setSearchCustList('');
}
}} }}
noOptionsText={ noOptionsText={
// <Button>ok</Button> /^[0-9]{10}$/.test(searchCustList) ? (
<Stack direction={'row'} justifyContent={'space-between'} alignItems={'center'}> <Stack sx={{ width: '100%', display: 'flex', alignItems: 'end', justifyContent: 'end' }}>
<Typography>No options</Typography> <Chip
{!pickupswitch && ( label={'OK'}
<Button sx={{
variant="outlined" width: 50,
onClick={() => { cursor: 'pointer',
setOpen4(true); '&:hover': { background: theme.palette.primary.main, color: 'white' }
}} }}
color="success" onClick={() => {
startIcon={<PlusOutlined />} setPickCust({ ...pickCust, contactno: searchCustList });
> handleOkClick1();
Create Customer setSearchCustList('');
</Button> }}
)} />
</Stack> </Stack>
) : null
} }
/> */} />
<Stack spacing={1.25} sx={{ mt: 2 }}> </Grid>
{addId1 == 0 ? (
// <Autocomplete
// id="google-map-demo"
// fullWidth
// getOptionLabel={(option) => (typeof option === 'string' ? option : option.description)}
// filterOptions={(x) => x}
// options={options}
// // options={pickCust}
// autoComplete
// includeInputInList
// filterSelectedOptions
// value={value}
// // value={pickCust.address}
// noOptionsText="No locations"
// onChange={(event, newValue, reason) => {
// if (reason == 'clear') {
// setValue(null);
// }
// console.log('pick location', newValue);
// // setOptions(newValue ? [newValue, ...options] : options);
// setValue(newValue);
// setAddress(newValue.description);
// setPickCust({ ...pickCust, address: newValue.description });
// }}
// onInputChange={(event, newInputValue) => {
// setInputValue(newInputValue);
// }}
// renderInput={(params) => <TextField {...params} placeholder="Address" fullWidth />}
// renderOption={(props, option) => {
// const matches = option.structured_formatting.main_text_matched_substrings || [];
// const parts = parse(
// option.structured_formatting.main_text,
// matches.map((match) => [match.offset, match.offset + match.length])
// );
// return ( <Grid item xs={12} sx={{}}>
// <li {...props}> <Grid container spacing={4}>
// <Grid container alignItems="center"> {/* ====================================== ||Contact Number(pick) || ====================================== */}
// <Grid item sx={{ display: 'flex', width: 44 }}> <Grid item xs={6}>
// <LocationOnIcon sx={{ color: 'text.secondary' }} /> <TextField
// </Grid> disabled={!isLocation}
// <Grid item sx={{ width: 'calc(100% - 44px)', wordWrap: 'break-word' }}> fullWidth
// {parts.map((part, index) => ( type="number"
// <Box key={index} component="span" sx={{ fontWeight: part.highlight ? 'bold' : 'regular' }}> InputProps={{
// {part.text} inputProps: {
// </Box> maxLength: 10
// ))} },
// <Typography variant="body2" color="text.secondary"> startAdornment: (
// {option.structured_formatting.secondary_text} <IconButton>
// </Typography> <FaPhoneAlt />
// </Grid> </IconButton>
// </Grid> )
// </li> }}
// ); variant="outlined"
// }} label="Contact Number"
// /> value={pickCust.contactno}
onChange={(e) => {
if (e.target.value.length <= 10) {
setPickCust({ ...pickCust, contactno: e.target.value });
}
}}
/>
</Grid>
{/* ====================================== ||Contact Name (pick) || ====================================== */}
<Grid item xs={6}>
<TextField
inputRef={textFieldRef1}
disabled={!isLocation}
fullWidth
InputProps={{
startAdornment: (
<IconButton>
<FaUser />
</IconButton>
)
}}
variant="outlined"
label="Contact Name"
value={pickCust.firstname}
onChange={(e) => {
setPickCust({ ...pickCust, firstname: e.target.value });
}}
/>
</Grid>
{/* ====================================== || Address (pick) || ====================================== */}
<Grid item xs={12}>
<Stack spacing={1.25} sx={{ mt: 0 }}>
{addId1 == 0 ? (
<div> <div>
<TextField <TextField
variant="outlined"
label="Address"
disabled={!isLocation} disabled={!isLocation}
id="addressAuto1" id="addressAuto1"
placeholder="Search" placeholder="Search"
@@ -1510,8 +1554,8 @@ const Createorder1 = () => {
setAddId1(0); setAddId1(0);
setPickCust({ setPickCust({
...pickCust, ...pickCust,
firstname: '', // firstname: '',
contactno: '', // contactno: '',
doorno: '', doorno: '',
suburb: '', suburb: '',
city: '', city: '',
@@ -1542,57 +1586,6 @@ const Createorder1 = () => {
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={12} sx={{}}>
<Typography variant="h5" sx={{ my: 2 }}>
Pickup Details
</Typography>
<Grid container spacing={4}>
{/* ====================================== ||Contact Name (pick) || ====================================== */}
<Grid item xs={6}>
<TextField
disabled={!isLocation}
fullWidth
InputProps={{
startAdornment: (
<IconButton>
<FaUser />
</IconButton>
)
}}
variant="outlined"
label="Contact Name"
value={pickCust.firstname}
onChange={(e) => {
setPickCust({ ...pickCust, firstname: e.target.value });
}}
/>
</Grid>
{/* ====================================== ||Contact Number(pick) || ====================================== */}
<Grid item xs={6}>
<TextField
disabled={!isLocation}
fullWidth
type="number"
InputProps={{
inputProps: {
maxLength: 10
},
startAdornment: (
<IconButton>
<FaPhoneAlt />
</IconButton>
)
}}
variant="outlined"
label="Contact Number"
value={pickCust.contactno}
onChange={(e) => {
if (e.target.value.length <= 10) {
setPickCust({ ...pickCust, contactno: e.target.value });
}
}}
/>
</Grid>
{/* ====================================== ||Door No (pick) || ====================================== */} {/* ====================================== ||Door No (pick) || ====================================== */}
<Grid item xs={6}> <Grid item xs={6}>
<TextField <TextField
@@ -1724,7 +1717,9 @@ const Createorder1 = () => {
<Grid container spacing={2} sx={{ height: '100%' }}> <Grid container spacing={2} sx={{ height: '100%' }}>
<Grid item xs={12} sx={{ height: '100%' }}> <Grid item xs={12} sx={{ height: '100%' }}>
<Stack direction={'row'} justifyContent={'space-between'}> <Stack direction={'row'} justifyContent={'space-between'}>
<Typography variant="h5">Drop</Typography> <Typography variant="h5" sx={{ mb: 2 }}>
Drop Details
</Typography>
<Stack direction={'row'} alignItems={'center'}> <Stack direction={'row'} alignItems={'center'}>
{/* <Typography>Customer</Typography> */} {/* <Typography>Customer</Typography> */}
{/* <Switch {/* <Switch
@@ -1741,7 +1736,7 @@ const Createorder1 = () => {
size="small" size="small"
/> />
<Typography>Business</Typography> */} <Typography>Business</Typography> */}
<Button {/* <Button
variant="outlined" variant="outlined"
sx={{ sx={{
'&:hover': { '&:hover': {
@@ -1762,102 +1757,123 @@ const Createorder1 = () => {
}} }}
> >
Saved Locations Saved Locations
</Button> </Button> */}
</Stack> </Stack>
</Stack> </Stack>
{/* <Autocomplete {/* new2 */}
id="free-solo-demo" <Autocomplete
sx={{ mt: 2 }} disabled={!isLocation}
// options={clientdetailarr} fullWidth
options={dropswitch ? clientdetailbusinessarr : clientdetailarr} disablePortal
renderInput={(params) => <TextField {...params} label="Choose Location" />} id="combo-box-demo"
onChange={(e, val) => { // options={customerlist}
options={clientdetailarr}
getOptionLabel={(option) => `${option.firstname} (${option.contactno})`}
sx={{ mt: 0, mb: 1 }}
renderInput={(params) => (
<TextField
{...params}
label="Search"
onChange={(e) => {
setSearchCustList(e.target.value);
}}
InputProps={{
...params.InputProps,
inputProps: {
...params.inputProps,
maxLength: 10
}
}}
/>
)}
onChange={(e, val, reason) => {
if (val) { if (val) {
if (tenantinfo.customerid == val.customerid) { if (pickCust.customerid === val.customerid) {
opentoast('choose different Location', 'warning'); opentoast('Select Another Customer', 'error');
setClientinfo({}); setSearchCustList('');
} else { } else {
setClientinfo(val); console.log('DropClient', val);
} setDropCust(val);
} else {
setClientinfo({});
}
console.log(val);
setEndPoint({ latitude: val.latitude, longitude: val.longitude }); setEndPoint({ latitude: val.latitude, longitude: val.longitude });
setAddId2(1);
}
}
if (reason == 'clear') {
setSearchCustList('');
}
}} }}
noOptionsText={ noOptionsText={
// <Button>ok</Button> /^[0-9]{10}$/.test(searchCustList) ? (
<Stack direction={'row'} justifyContent={'space-between'} alignItems={'center'}> <Stack sx={{ width: '100%', display: 'flex', alignItems: 'end', justifyContent: 'end' }}>
<Typography>No options</Typography> <Chip
{!dropswitch && ( label={'OK'}
<Button sx={{
variant="outlined" width: 50,
onClick={() => { cursor: 'pointer',
setOpen4(true); '&:hover': { background: theme.palette.primary.main, color: 'white' }
}} }}
color="success" onClick={() => {
startIcon={<PlusOutlined />} setDropCust({ ...dropCust, contactno: searchCustList });
> handleOkClick2();
Create Customer setSearchCustList('');
</Button> }}
)} />
</Stack> </Stack>
) : null
} }
/> */} />
<Stack spacing={1.25} sx={{ mt: 2 }}> </Grid>
{addId2 == 0 ? (
// <Autocomplete
// id="google-map-demo"
// fullWidth
// getOptionLabel={(option) => (typeof option === 'string' ? option : option.description)}
// filterOptions={(x) => x}
// options={options1}
// autoComplete
// includeInputInList
// filterSelectedOptions
// value={value1}
// // value={dropCust.address}
// noOptionsText="No locations"
// onChange={(event, newValue) => {
// setOptions1(newValue ? [newValue, ...options1] : options1);
// setValue1(newValue);
// console.log(newValue);
// setAddress1(newValue.description);
// setDropCust({ ...dropCust, address: newValue.description });
// }}
// onInputChange={(event, newInputValue) => {
// setInputValue1(newInputValue);
// }}
// renderInput={(params) => <TextField {...params} label="Address" fullWidth />}
// renderOption={(props, option) => {
// const matches = option.structured_formatting.main_text_matched_substrings || [];
// const parts = parse(
// option.structured_formatting.main_text,
// matches.map((match) => [match.offset, match.offset + match.length])
// );
// return ( <Grid item xs={12}>
// <li {...props}> <Grid container spacing={4}>
// <Grid container alignItems="center"> {/* ====================================== ||Contact Number (drop) || ====================================== */}
// <Grid item sx={{ display: 'flex', width: 44 }}> <Grid item xs={6}>
// <LocationOnIcon sx={{ color: 'text.secondary' }} /> <TextField
// </Grid> disabled={!isLocation}
// <Grid item sx={{ width: 'calc(100% - 44px)', wordWrap: 'break-word' }}> fullWidth
// {parts.map((part, index) => ( type="number"
// <Box key={index} component="span" sx={{ fontWeight: part.highlight ? 'bold' : 'regular' }}> variant="outlined"
// {part.text} label="Contact Number"
// </Box> InputProps={{
// ))} startAdornment: (
// <Typography variant="body2" color="text.secondary"> <IconButton>
// {option.structured_formatting.secondary_text} <FaPhoneAlt />
// </Typography> </IconButton>
// </Grid> )
// </Grid> }}
// </li> value={dropCust.contactno}
// ); onChange={(e) => {
// }} if (e.target.value.length <= 10) {
// /> setDropCust({ ...dropCust, contactno: e.target.value });
}
}}
/>
</Grid>
{/* ====================================== ||Contact Name (drop) || ====================================== */}
<Grid item xs={6}>
<TextField
inputRef={textFieldRef2}
disabled={!isLocation}
fullWidth
variant="outlined"
label="Contact Name"
InputProps={{
startAdornment: (
<IconButton>
<FaUser />
</IconButton>
)
}}
value={dropCust.firstname}
onChange={(e) => {
setDropCust({ ...dropCust, firstname: e.target.value });
}}
/>
</Grid>
<Grid item xs={12}>
<Stack spacing={1.25} sx={{ mt: 0 }}>
{addId2 == 0 ? (
<div> <div>
<TextField <TextField
id="addressAuto2" id="addressAuto2"
@@ -1932,54 +1948,6 @@ const Createorder1 = () => {
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={12}>
<Typography variant="h5" sx={{ my: 2 }}>
Drop Details
</Typography>
<Grid container spacing={4}>
{/* ====================================== ||Contact Name (drop) || ====================================== */}
<Grid item xs={6}>
<TextField
disabled={!isLocation}
fullWidth
variant="outlined"
label="Contact Name"
InputProps={{
startAdornment: (
<IconButton>
<FaUser />
</IconButton>
)
}}
value={dropCust.firstname}
onChange={(e) => {
setDropCust({ ...dropCust, firstname: e.target.value });
}}
/>
</Grid>
{/* ====================================== ||Contact Number (drop) || ====================================== */}
<Grid item xs={6}>
<TextField
disabled={!isLocation}
fullWidth
type="number"
variant="outlined"
label="Contact Number"
InputProps={{
startAdornment: (
<IconButton>
<FaPhoneAlt />
</IconButton>
)
}}
value={dropCust.contactno}
onChange={(e) => {
if (e.target.value.length <= 10) {
setDropCust({ ...dropCust, contactno: e.target.value });
}
}}
/>
</Grid>
{/* ====================================== ||Door No (drop) || ====================================== */} {/* ====================================== ||Door No (drop) || ====================================== */}
<Grid item xs={6}> <Grid item xs={6}>
<TextField <TextField
@@ -2286,10 +2254,13 @@ const Createorder1 = () => {
<Grid container> <Grid container>
<Grid item xs={12}> <Grid item xs={12}>
<TextField <TextField
focused
variant="outlined"
id="outlined-multiline-static" id="outlined-multiline-static"
sx={{ width: '100%', height: '100%', mb: 2 }} sx={{ width: '100%', height: '100%', mb: 2 }}
multiline multiline
rows={1} rows={1}
label="Notes"
placeholder="Notes" placeholder="Notes"
value={otherinstructions} value={otherinstructions}
onChange={(e) => setOtherinstructions(e.target.value)} onChange={(e) => setOtherinstructions(e.target.value)}

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@ const SamplePage = Loadable(lazy(() => import('pages/extra-pages/sample-page')))
const Login = Loadable(lazy(() => import('pages/nearle/login'))); const Login = Loadable(lazy(() => import('pages/nearle/login')));
const Dashboard = Loadable(lazy(() => import('pages/nearle/dashboard'))); const Dashboard = Loadable(lazy(() => import('pages/nearle/dashboard')));
const Client1 = Loadable(lazy(() => import('pages/nearle/clients/clients1'))); const Customers = Loadable(lazy(() => import('pages/nearle/clients/customers')));
const Orders = Loadable(lazy(() => import('pages/nearle/orders/orders'))); const Orders = Loadable(lazy(() => import('pages/nearle/orders/orders')));
const Details = Loadable(lazy(() => import('pages/nearle/orders/details'))); const Details = Loadable(lazy(() => import('pages/nearle/orders/details')));
@@ -25,7 +25,7 @@ const Details = Loadable(lazy(() => import('pages/nearle/orders/details')));
const Accountsettings = Loadable(lazy(() => import('pages/nearle/accountsettings'))); const Accountsettings = Loadable(lazy(() => import('pages/nearle/accountsettings')));
// const Createorder = Loadable(lazy(() => import('pages/nearle/orders/createorder'))); // const Createorder = Loadable(lazy(() => import('pages/nearle/orders/createorder')));
const Createclient = Loadable(lazy(() => import('pages/nearle/clients/createclient'))); const Createclient = Loadable(lazy(() => import('pages/nearle/clients/createCustomer')));
const Createorder1 = Loadable(lazy(() => import('pages/nearle/orders/createorder1'))); const Createorder1 = Loadable(lazy(() => import('pages/nearle/orders/createorder1')));
@@ -57,11 +57,11 @@ const MainRoutes = {
}, },
{ {
path: 'customers', path: 'customers',
element: <Client1 /> element: <Customers />
}, },
// { // {
// path: 'clients1', // path: 'clients1',
// element: <Client1 /> // element: <Customers />
// }, // },
{ {
path: 'orders', path: 'orders',