feat: add ReschedulePickupView component and related seller types and context
All checks were successful
Beta CI/CD Pipeline / build-and-test (push) Successful in 1m38s
Beta CI/CD Pipeline / deploy-beta (push) Successful in 45s

This commit is contained in:
vickytechkey 2026-10-13 19:03:36 +05:30
parent 4471aed9f3
commit 9d1966ea79
4 changed files with 68 additions and 24 deletions

View file

@ -138,7 +138,9 @@ export const ReschedulePickupView: React.FC<ReschedulePickupViewProps> = ({ onBa
<div className="is-flex flex-direction-column md-flex-row md-items-center justify-content-between gap-4 pt-1 mb-4">
<div>
<div className="is-flex is-align-items-center gap-3 mb-1">
<h1 className="title is-size-2 mb-0" style={{ letterSpacing: '-0.02em', color: '#1c1b1b' }}>Schedule Courier Pickup</h1>
<h1 className="title is-size-2 mb-0" style={{ letterSpacing: '-0.02em', color: '#1c1b1b' }}>
{targetOrder?.pickupId ? 'Reschedule Courier Pickup' : 'Schedule Courier Pickup'}
</h1>
{/* Carrier Badge */}
<span className="is-inline-flex is-align-items-center gap-2 px-3 py-1 has-text-weight-bold is-size-7" style={{
borderRadius: '9999px',
@ -147,9 +149,20 @@ export const ReschedulePickupView: React.FC<ReschedulePickupViewProps> = ({ onBa
}}>
<Truck size={14} /> {carrierDisplayName}
</span>
{targetOrder?.pickupId && (
<span className="is-inline-flex is-align-items-center gap-1 px-3 py-1 has-text-weight-bold is-size-7" style={{
borderRadius: '9999px',
backgroundColor: '#dcfce7',
color: '#15803d'
}}>
<CheckCircle2 size={13} /> PR #{targetOrder.pickupId}
</span>
)}
</div>
<p className="is-size-6" style={{ color: '#564243', maxWidth: '42rem' }}>
{isDelhivery && 'Delhivery supports custom pickup date and hour slots. Choose your preferred arrival window.'}
{isDelhivery && (targetOrder?.pickupId
? `Delhivery Pickup Request #${targetOrder.pickupId} is active. You can reschedule the collection date or hour slot below.`
: 'Delhivery supports custom pickup date and hour slots. Choose your preferred arrival window.')}
{isEkart && 'Ekart Logistics allows choosing a preferred dispatch date. Sweeps occur during standard daily runs.'}
{isShadowfax && 'Shadowfax operates automated warehouse sweeps based on registered dispatch cutoff times.'}
</p>
@ -474,6 +487,14 @@ export const ReschedulePickupView: React.FC<ReschedulePickupViewProps> = ({ onBa
</span>
</div>
)}
{targetOrder?.pickupId && (
<div className="is-flex is-align-items-flex-start justify-content-between" style={{ gap: '1rem' }}>
<span style={{ color: '#564243', flexShrink: 0 }}>Active Pickup ID</span>
<span className="has-text-weight-bold has-text-right" style={{ color: '#15803d' }}>
#{targetOrder.pickupId}
</span>
</div>
)}
<div className="is-flex is-align-items-flex-start justify-content-between" style={{ gap: '1rem' }}>
<span style={{ color: '#564243', flexShrink: 0 }}>Pickup Location</span>
<span className="has-text-weight-semibold has-text-right" style={{ color: '#1c1b1b' }}>{locationName}</span>
@ -527,7 +548,7 @@ export const ReschedulePickupView: React.FC<ReschedulePickupViewProps> = ({ onBa
className={`button is-rounded shadow-sm ${isSubmitting ? 'is-loading' : ''}`}
style={{ height: 'auto', minHeight: '48px', whiteSpace: 'normal', padding: '10px 16px', lineHeight: '1.3', backgroundColor: '#791b2c', color: '#ffffff', fontWeight: 600, border: 'none', transition: 'all 0.2s' }}
>
Confirm Scheduled Pickup
{targetOrder?.pickupId ? 'Confirm Rescheduled Pickup' : 'Confirm Scheduled Pickup'}
</button>
<button
onClick={onBack}

View file

@ -242,22 +242,38 @@ export const SellerProvider: React.FC<{ children: React.ReactNode }> = ({ childr
})));
// Map Orders
setOrders(ordersArr.map((o: any) => ({
id: String(o.id),
orderNumber: o.order_id || `ORD-${o.id}`,
date: o.date || 'Today',
customerName: o.customer_name || ((o.customer && typeof o.customer === 'string') ? (o.customer.split(' ')[0] || o.customer) : 'Customer'),
customerCity: o.customer_city || 'Chennai',
customerState: o.customer_state || 'Tamil Nadu',
productTitle: o.item || 'Order Item',
quantity: o.quantity || 1,
amount: parseFloat(o.total) || 0,
status: mapBackendStatusToFrontend(o.status),
courierPartner: o.carrier || 'Shadowfax Logistics',
awbNumber: o.tracking || 'N/A',
pickupSlot: 'Morning Slot (10 AM - 1 PM)',
deliveryDate: o.eta || '2-3 Days'
})));
setOrders(ordersArr.map((o: any) => {
let dynamicSlot = 'Afternoon Slot (2 PM - 5 PM)';
if (o.pickup_payload?.pickup_time) {
const t = String(o.pickup_payload.pickup_time);
if (t.startsWith('10')) dynamicSlot = 'Morning Slot (10 AM - 1 PM)';
else if (t.startsWith('14')) dynamicSlot = 'Afternoon Slot (2 PM - 5 PM)';
else if (t.startsWith('17')) dynamicSlot = 'Evening Slot (5 PM - 7 PM)';
else dynamicSlot = t;
} else if (o.eta && o.eta.includes('(')) {
const m = o.eta.match(/\(([^)]+)\)/);
if (m) dynamicSlot = m[1];
}
return {
id: String(o.id),
orderNumber: o.order_id || `ORD-${o.id}`,
date: o.date || 'Today',
customerName: o.customer_name || ((o.customer && typeof o.customer === 'string') ? (o.customer.split(' ')[0] || o.customer) : 'Customer'),
customerCity: o.customer_city || 'Chennai',
customerState: o.customer_state || 'Tamil Nadu',
productTitle: o.item || 'Order Item',
quantity: o.quantity || 1,
amount: parseFloat(o.total) || 0,
status: mapBackendStatusToFrontend(o.status),
courierPartner: o.carrier || 'Shadowfax Logistics',
awbNumber: o.tracking || 'N/A',
pickupId: o.pickup_id || undefined,
pickupPayload: o.pickup_payload || undefined,
pickupSlot: dynamicSlot,
deliveryDate: o.eta || '2-3 Days'
};
}));
// Map Wallet
setWalletBalance(parseFloat(backendWallet?.outstanding) || 0);

View file

@ -573,15 +573,20 @@ export const OrdersPage: React.FC = () => {
<span className={`tag is-rounded is-small has-text-weight-semibold ${
ord.status === 'new' ? 'is-warning is-light' :
ord.status === 'accepted' ? 'is-success is-light' :
ord.status === 'ready_to_ship' ? 'is-info is-light' :
ord.status === 'ready_to_ship' ? (ord.pickupId ? 'is-success is-light' : 'is-info is-light') :
ord.status === 'dispatched' ? 'is-primary is-light' : 'is-success is-light'
}`}>
{ord.status === 'new' ? 'NEW (PENDING)' :
ord.status === 'accepted' ? 'ACCEPTED' :
ord.status === 'ready_to_ship' ? 'READY TO SHIP' :
ord.status === 'ready_to_ship' ? (ord.pickupId ? 'PICKUP SCHEDULED' : 'READY TO SHIP') :
ord.status === 'dispatched' ? 'SHIPPED (IN TRANSIT)' :
ord.status.replace('_', ' ').toUpperCase()}
</span>
{ord.pickupId && (
<div className="is-size-7 mt-1 has-text-weight-semibold" style={{ color: '#15803d' }}>
PR #{ord.pickupId}
</div>
)}
</td>
<td className="is-vcentered has-text-right">
<div className="is-flex is-align-items-center is-justify-content-flex-end gap-2">
@ -638,11 +643,11 @@ export const OrdersPage: React.FC = () => {
setSelectedOrderForReschedule(ord);
setShowReschedule(true);
}}
className="button is-small is-rounded is-warning is-light"
className={`button is-small is-rounded ${ord.pickupId ? 'is-light' : 'is-warning is-light'}`}
disabled={isLoading}
title="Schedule or adjust courier pickup window"
title={ord.pickupId ? `Pickup booked (#${ord.pickupId}). Click to adjust pickup window.` : "Schedule or adjust courier pickup window"}
>
<Clock size={14} className="mr-1" /> Schedule Pickup
<Clock size={14} className="mr-1" /> {ord.pickupId ? 'Reschedule' : 'Schedule Pickup'}
</button>
<button
onClick={() => handleFetchPrintLabel(ord)}

View file

@ -114,6 +114,8 @@ export interface OrderItem {
deliveryDate?: string;
imageUrl?: string;
shippingAddress?: string;
pickupId?: string;
pickupPayload?: any;
}
export interface PayoutTransaction {