updates on the createorder page and preview page as well

This commit is contained in:
2026-08-13 12:26:22 +05:30
parent b1efd14749
commit 498bb7cbc0
2 changed files with 54 additions and 22 deletions

View File

@@ -298,7 +298,6 @@ const Createorder1 = () => {
const [stafflist, setStafflist] = useState([]);
const [loading2, setLoading2] = useState(false);
const [loading, setLoading] = useState(false);
const [btnLoading, setBtnLoading] = useState(false);
const [shiftarr, setShiftarr] = useState([]);
const [shiftarr1, setShiftarr1] = useState([]);
const [orderarr, setOrderarr] = useState([]);
@@ -595,13 +594,18 @@ const Createorder1 = () => {
service_option: 'Normal',
finalprice: +totalCharge.toFixed(2) || 0,
notes: otherinstructions || '',
parcels: [
{
itemcategory: category || 'General',
itemdescription: 'Order',
declaredvalue: +totalCharge.toFixed(2) || 0
}
]
// The parcel object has no numeric quantity field (confirmed against
// express-console-api.md's schema) — "N items" is expressed by sending
// N parcel entries, which is also how the Deliveries page already reads
// it back (fetchDeliveries in api.js: `Quantity: b.parcels?.length`).
// This previously always sent exactly one parcel regardless of what the
// operator typed into the Quantity field, so it silently got dropped —
// matching "I entered 5, deliveries page shows 1".
parcels: Array.from({ length: Math.max(1, Number(quantity) || 1) }, () => ({
itemcategory: category || 'General',
itemdescription: 'Order',
declaredvalue: +totalCharge.toFixed(2) || 0
}))
};
if (!arr.tenantid) {
opentoast('Pick a tenant before creating an order', 'warning', 2000);
@@ -2218,18 +2222,21 @@ const Createorder1 = () => {
)}
<Button
size="medium"
disabled={!showDistance}
// Was `!showDistance` only — `loading` wasn't part of the
// disabled condition at all, and the separate `btnLoading`
// state this button used to drive its spinner got reset by
// a hardcoded 1-second setTimeout regardless of whether
// createExpressBooking had actually returned yet. On a
// slower request the button looked re-enabled well before
// the real submission finished, inviting a second click
// that created a second real booking — createsubmitobj2()
// already tracks `loading` correctly via try/finally, so
// just gate on that directly instead of a second,
// independently-timed loading flag.
disabled={!showDistance || loading}
variant="contained"
startIcon={btnLoading ? null : <MdCheckCircle size={16} />}
onClick={() => {
setLoading(true);
setBtnLoading(true);
createsubmitobj2();
setTimeout(() => {
setLoading(false);
setBtnLoading(false);
}, 1000);
}}
startIcon={loading ? null : <MdCheckCircle size={16} />}
onClick={createsubmitobj2}
sx={{
borderRadius: 999,
px: 3,
@@ -2253,7 +2260,7 @@ const Createorder1 = () => {
}
}}
>
{btnLoading ? <CircularProgress size={18} thickness={5} sx={{ color: '#fff' }} /> : 'Create Order'}
{loading ? <CircularProgress size={18} thickness={5} sx={{ color: '#fff' }} /> : 'Create Order'}
</Button>
</Stack>
</Box>