multiple orders solved
This commit is contained in:
1657
src/pages/nearle/orders/miltiUploadBackup.js
Normal file
1657
src/pages/nearle/orders/miltiUploadBackup.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -71,7 +71,7 @@ const MultipleOrders = () => {
|
|||||||
const [appId, setAppId] = useState(0);
|
const [appId, setAppId] = useState(0);
|
||||||
const [tenantLocations, setTenantlocations] = useState([]);
|
const [tenantLocations, setTenantlocations] = useState([]);
|
||||||
// const [tenantid, setTenantid] = useState(0);
|
// const [tenantid, setTenantid] = useState(0);
|
||||||
const tenantid = localStorage.getItem('tenantid') || 0;
|
const tenantid = localStorage.getItem('tenantid');
|
||||||
const [locationid, setLocationid] = useState(0);
|
const [locationid, setLocationid] = useState(0);
|
||||||
const [basePrice, setBasePrice] = useState(0);
|
const [basePrice, setBasePrice] = useState(0);
|
||||||
const [pricePerKm, setPricePerKm] = useState(0);
|
const [pricePerKm, setPricePerKm] = useState(0);
|
||||||
@@ -193,6 +193,9 @@ const MultipleOrders = () => {
|
|||||||
console.log('fetchTenantPricing error', error);
|
console.log('fetchTenantPricing error', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
fetchTenantPricing(tenantid);
|
||||||
|
}, [tenantid]);
|
||||||
// ============================================= || gettenantlocations (branches) || =============================================
|
// ============================================= || gettenantlocations (branches) || =============================================
|
||||||
const gettenantlocations = async (id) => {
|
const gettenantlocations = async (id) => {
|
||||||
try {
|
try {
|
||||||
@@ -989,83 +992,74 @@ const MultipleOrders = () => {
|
|||||||
spacing: 5
|
spacing: 5
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* ===================================================== ||Business Location || ===================================================== */}
|
|
||||||
<Grid item xs={12} sx={{ width: '100%', mt: -1 }}>
|
<Grid item xs={12} sx={{ width: '100%', mt: -1 }}>
|
||||||
<Stack
|
<Stack>
|
||||||
direction={{ xs: 'column', sm: 'row' }}
|
<Typography variant="h3"> Create Multiple Order</Typography>
|
||||||
spacing={2}
|
|
||||||
sx={{
|
|
||||||
width: '100%',
|
|
||||||
alignItems: { xs: 'stretch', sm: 'center' },
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
mb: 2
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="h3">Create Multiple Order</Typography>
|
|
||||||
|
|
||||||
<Stack sx={{ width: { xs: '100%', sm: 400 } }}>
|
|
||||||
{tenantLocations?.length === 1 ? (
|
|
||||||
<TextField
|
|
||||||
variant="outlined"
|
|
||||||
fullWidth
|
|
||||||
label="Business Location"
|
|
||||||
value={tenantLocations[0]?.locationname || ''}
|
|
||||||
focused
|
|
||||||
InputProps={{
|
|
||||||
style: {
|
|
||||||
color: theme.palette.primary.main
|
|
||||||
},
|
|
||||||
startAdornment: (
|
|
||||||
<InputAdornment position="start">
|
|
||||||
<MyLocationIcon color="primary" />
|
|
||||||
</InputAdornment>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Autocomplete
|
|
||||||
fullWidth
|
|
||||||
options={tenantLocations || []}
|
|
||||||
getOptionLabel={(option) => `${option.locationname} (${option.suburb})`}
|
|
||||||
value={locationValue}
|
|
||||||
onOpen={(event) => {
|
|
||||||
if (!appId && !tenantid) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
OpenToast('Please select Location and Tenant first!', 'warning', 3000);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
locationRef.current?.focus();
|
|
||||||
}, 0);
|
|
||||||
} else if (!tenantid) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
OpenToast('Please select Tenant first!', 'warning', 3000);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
tenantRef.current?.focus();
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onChange={(event, value, reason) => {
|
|
||||||
if (reason === 'clear') {
|
|
||||||
setLocationid(0);
|
|
||||||
setLocationValue(null);
|
|
||||||
setPickCust(null);
|
|
||||||
} else {
|
|
||||||
setLocationid(value?.locationid || 0);
|
|
||||||
setLocationValue(value);
|
|
||||||
setPickCust(value);
|
|
||||||
setPickupSlotsList(value?.slots);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
renderInput={(params) => <TextField {...params} label="Select Business Location" color="primary" />}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid item xs={12} sx={{ width: '100%', mt: -2 }}>
|
||||||
|
<MainCard sx={{ height: '100%' }}>
|
||||||
|
<Grid container spacing={3} sx={{}}>
|
||||||
|
{/* ===================================================== || Choose App location || ===================================================== */}
|
||||||
|
|
||||||
|
{/* ===================================================== ||Business Location || ===================================================== */}
|
||||||
|
<Grid item xs={12} sm={4}>
|
||||||
|
{tenantLocations?.length == 1 ? (
|
||||||
|
<TextField
|
||||||
|
variant="outlined"
|
||||||
|
fullWidth
|
||||||
|
label={'Business Location'}
|
||||||
|
value={tenantLocations[0]?.locationname || ''}
|
||||||
|
focused
|
||||||
|
InputProps={{
|
||||||
|
style: { color: theme.palette.primary.main },
|
||||||
|
startAdornment: (
|
||||||
|
<InputAdornment position="start">
|
||||||
|
<MyLocationIcon color="primary" />
|
||||||
|
</InputAdornment>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Autocomplete
|
||||||
|
fullWidth
|
||||||
|
options={tenantLocations || []}
|
||||||
|
getOptionLabel={(option) => `${option.locationname} (${option.suburb})` || ''}
|
||||||
|
value={locationValue}
|
||||||
|
onOpen={(event) => {
|
||||||
|
if (!appId && !tenantid) {
|
||||||
|
event.preventDefault();
|
||||||
|
OpenToast('Please select Location and Tenant first!', 'warning', 3000);
|
||||||
|
setTimeout(() => {
|
||||||
|
locationRef.current?.focus();
|
||||||
|
}, 0);
|
||||||
|
} else if (!tenantid) {
|
||||||
|
event.preventDefault();
|
||||||
|
OpenToast('Please select Tenant first!', 'warning', 3000);
|
||||||
|
setTimeout(() => {
|
||||||
|
tenantRef.current?.focus();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onChange={(event, value, reason) => {
|
||||||
|
if (reason === 'clear') {
|
||||||
|
setLocationid(0);
|
||||||
|
setLocationValue(null);
|
||||||
|
setPickCust(null);
|
||||||
|
} else {
|
||||||
|
setLocationid(value.locationid || 0);
|
||||||
|
setLocationValue(value);
|
||||||
|
setPickCust(value);
|
||||||
|
setPickupSlotsList(value?.slots);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Select Business Locations" color="primary" />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</MainCard>
|
||||||
|
</Grid>
|
||||||
{/* ===================================================== || Pickup || ===================================================== */}
|
{/* ===================================================== || Pickup || ===================================================== */}
|
||||||
<Grid item xs={12} sx={{ width: '100%', mt: 0 }}>
|
<Grid item xs={12} sx={{ width: '100%', mt: 0 }}>
|
||||||
<Grid container xs={12} spacing={3}>
|
<Grid container xs={12} spacing={3}>
|
||||||
@@ -1337,7 +1331,7 @@ const MultipleOrders = () => {
|
|||||||
value={uploadType}
|
value={uploadType}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
if (!locationid) {
|
if (!locationid) {
|
||||||
OpenToast('Please select Business Location!', 'warning', 3000);
|
OpenToast('Please select Business Location !', 'warning', 3000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setUploadType(Number(e.target.value));
|
setUploadType(Number(e.target.value));
|
||||||
@@ -1521,8 +1515,7 @@ const MultipleOrders = () => {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Stack direction="row" justifyContent={'end'} sx={{ mt: 2, width: '100%' }}>
|
<Stack direction="row" justifyContent={'end'} sx={{ mt: 2, width: '100%' }}>
|
||||||
<Button
|
<Button
|
||||||
// disabled={dropCust.length == 0 || !pickupSlot}
|
disabled={dropCust.length == 0 || !pickupSlot}
|
||||||
disabled={dropCust.length == 0}
|
|
||||||
size="medium"
|
size="medium"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user