updates on the api integration and the design changes on the whole website
This commit is contained in:
@@ -187,7 +187,6 @@ const OrdersPreview = () => {
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
console.log('location.state', location.state);
|
||||
const [rider, setRider] = useState(null);
|
||||
const [payment, setPayment] = useState(null);
|
||||
const [finaldeliveryList, setFinalDeliveryList] = useState([]);
|
||||
@@ -200,14 +199,6 @@ const OrdersPreview = () => {
|
||||
const aiMode = location.state?.aiMode;
|
||||
const reassignOrders = location.state?.reassignOrders;
|
||||
|
||||
useEffect(() => {
|
||||
console.log('aiMode', aiMode);
|
||||
console.log('riderToken', riderToken);
|
||||
console.log('zoneData', zoneData);
|
||||
console.log('metaData', metaData);
|
||||
console.log('reassignOrders', reassignOrders);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!deliverylist?.length) return;
|
||||
const updateDeliveryAmtList = deliverylist.map((list) => {
|
||||
@@ -228,7 +219,6 @@ const OrdersPreview = () => {
|
||||
});
|
||||
|
||||
setFinalDeliveryList(updateDeliveryAmtList);
|
||||
console.log('finaldeliveryList', updateDeliveryAmtList);
|
||||
}, [deliverylist]);
|
||||
|
||||
// ==============================|| fetchPaymentType ||============================== //
|
||||
@@ -275,16 +265,27 @@ const OrdersPreview = () => {
|
||||
const createNormalDeliveryMutation = useMutation({
|
||||
mutationFn: finalCreatedeliveries, // for optimised delivery create
|
||||
|
||||
onSuccess: (data, variables) => {
|
||||
console.log('data', data);
|
||||
console.log('varialbles', variables);
|
||||
notifyRiderMutation.mutate(rider?.userfcmtoken || riderToken); // Call notifyRider after success
|
||||
onSuccess: (data) => {
|
||||
// notifyRider expects a milerprofileid, not an FCM token — the server
|
||||
// looks the device up itself (see dispatch/Preview.js's identical
|
||||
// fix). rider?.userfcmtoken/riderToken here were always the wrong
|
||||
// type, so every notify call from this page 404'd silently. Notify
|
||||
// every rider actually present across the committed deliveries
|
||||
// instead, keyed by the same `userid` field this page already uses
|
||||
// for rider identity (see the Change Rider handlers below).
|
||||
const notifiedRiderIds = new Set();
|
||||
(finaldeliveryList || []).forEach((order) => {
|
||||
const riderId = order.userid;
|
||||
if (riderId == null || notifiedRiderIds.has(String(riderId))) return;
|
||||
notifiedRiderIds.add(String(riderId));
|
||||
notifyRiderMutation.mutate(riderId);
|
||||
});
|
||||
if (data.status == 'accepted') {
|
||||
OpenToast('Delivery Created Successfully', 'success', 2000);
|
||||
}
|
||||
setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
navigate('/nearle/orders');
|
||||
navigate('/doormile/orders');
|
||||
}, 2000);
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -306,7 +307,7 @@ const OrdersPreview = () => {
|
||||
<Stack direction="row" alignItems="center" spacing={1} sx={{ ml: 1 }}>
|
||||
<Tooltip title="Back to orders" placement="top">
|
||||
<IconButton
|
||||
onClick={() => navigate('/nearle/orders')}
|
||||
onClick={() => navigate('/doormile/orders')}
|
||||
sx={{
|
||||
backgroundColor: 'action.hover',
|
||||
color: 'text.primary',
|
||||
@@ -696,7 +697,6 @@ const OrdersPreview = () => {
|
||||
return;
|
||||
}
|
||||
if (newValue) {
|
||||
console.log('Selected:', newValue);
|
||||
setPayment(newValue);
|
||||
const newList = finaldeliveryList?.map((list) => ({
|
||||
...list,
|
||||
@@ -719,7 +719,6 @@ const OrdersPreview = () => {
|
||||
}
|
||||
if (newValue) {
|
||||
setRider(newValue);
|
||||
console.log('Selected:', newValue);
|
||||
const newList = finaldeliveryList?.map((list) => ({
|
||||
...list,
|
||||
userid: newValue.userid,
|
||||
@@ -747,7 +746,7 @@ const OrdersPreview = () => {
|
||||
color="secondary"
|
||||
startIcon={<ArrowBackIcon />}
|
||||
onClick={() => {
|
||||
navigate('/nearle/orders');
|
||||
navigate('/doormile/orders');
|
||||
}}
|
||||
>
|
||||
Back
|
||||
|
||||
Reference in New Issue
Block a user