update on the user page regardinga the dispatch and order page and the deliveries page

This commit is contained in:
2026-06-09 16:01:26 +05:30
parent 9f25c5f60a
commit d8c1517239
16 changed files with 14328 additions and 43 deletions

View File

@@ -0,0 +1,124 @@
/**
* @license
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Sample dispatch data for the Dispatch page.
*
* The live Fiesta deliveries feed (getdeliveries) can come back empty for a given
* day/tenant, which leaves the Dispatch cockpit blank. This module provides a
* realistic sample set — shaped exactly like the rows `DispatchView` consumes —
* so the page demonstrates the rider/zone grouping, waves, and planned-route view.
*
* It is a DEV/DEMO fallback only: DispatchView uses it when the live query returns
* no rows, and clearly labels the header "Sample data" so it never masquerades as
* live. Delete this file (and the fallback in DispatchView) once the live feed is
* reliably populated.
*/
import type { Row } from './fiestaApi';
/** Approx zone centroids in Coimbatore — drop pins are jittered around these. */
const ZONE_COORDS: Record<string, [number, number]> = {
'RS Puram': [11.0069, 76.9498],
'Gandhipuram': [11.0183, 76.9725],
'Peelamedu': [11.0259, 77.001],
'Saibaba Colony': [11.0233, 76.943],
'Singanallur': [10.998, 77.029],
};
const HUB: [number, number] = [11.0045, 76.955]; // Ragul Stores hub (pickup)
/** Build one delivery row in the Fiesta shape DispatchView reads. */
function mk(
deliveryid: number,
userid: number,
ridername: string,
zone: string,
status: string,
assign: string,
kms: number,
profit: number,
step: number,
trip: number,
customer: string,
address: string,
expected: string,
delivered: string,
charge: number,
): Row {
const [zlat, zlon] = ZONE_COORDS[zone] ?? [11.0168, 76.9558];
const droplat = zlat + ((deliveryid % 7) - 3) * 0.0016;
const droplon = zlon + ((deliveryid % 5) - 2) * 0.0018;
return {
orderid: `RS-${deliveryid}`,
deliveryid,
orderheaderid: deliveryid,
tenantname: 'Ragul Stores',
orderstatus: status,
userid,
ridername,
username: ridername,
deliverysuburb: zone,
zone_name: zone,
deliverycustomer: customer,
deliverycontactno: '+91 98430 0' + String(1000 + deliveryid).slice(-4),
deliveryaddress: address,
pickupcustomer: 'Ragul Stores Hub',
kms,
cumulativekms: delivered ? kms : 0,
profit,
step,
trip_number: trip,
assigntime: `2026-06-09 ${assign}:00`,
expecteddeliverytime: expected ? `2026-06-09 ${expected}:00` : '',
deliverytime: delivered ? `2026-06-09 ${delivered}:00` : '',
deliverycharge: charge,
deliveryamt: charge,
droplat,
droplon,
deliverylat: droplat,
deliverylong: droplon,
pickuplat: HUB[0],
pickuplong: HUB[1],
locationid: 1097,
};
}
/** ~16 deliveries across 4 riders + 1 unassigned, 5 zones, and all 3 waves. */
export const MOCK_DELIVERIES: Row[] = [
// ── Suresh Kumar · RS Puram · Morning (trip 1) ──
mk(5001, 101, 'Suresh Kumar', 'RS Puram', 'delivered', '06:40', 2.4, 38, 1, 1, 'Arun Prasad', '12, Lawley Rd, RS Puram', '07:00', '06:58', 35),
mk(5002, 101, 'Suresh Kumar', 'RS Puram', 'delivered', '06:45', 3.1, 42, 2, 1, 'Deepa Lakshmi', '45, DB Rd, RS Puram', '07:20', '07:25', 40),
mk(5003, 101, 'Suresh Kumar', 'RS Puram', 'picked', '06:45', 1.8, 30, 3, 1, 'Mohammed Irfan', '8, Bashyakarlu Rd, RS Puram', '07:40', '', 30),
// ── Vignesh R · Gandhipuram / Peelamedu · Afternoon (trip 1) ──
mk(5004, 102, 'Vignesh R', 'Gandhipuram', 'delivered', '09:30', 2.0, 35, 1, 1, 'Sangeetha R', '23, 100 Feet Rd, Gandhipuram', '10:00', '09:58', 35),
mk(5005, 102, 'Vignesh R', 'Gandhipuram', 'delivered', '09:30', 2.6, 40, 2, 1, 'Bala Subramani', '5, Cross Cut Rd, Gandhipuram', '10:25', '10:30', 38),
mk(5006, 102, 'Vignesh R', 'Peelamedu', 'active', '09:35', 4.2, 55, 3, 1, 'Nithya K', '78, Sathy Rd, Peelamedu', '10:55', '', 50),
mk(5007, 102, 'Vignesh R', 'Peelamedu', 'accepted', '09:35', 3.3, 45, 4, 1, 'Ramesh Babu', '16, Avinashi Rd, Peelamedu', '11:20', '', 42),
// ── Karthik M · Saibaba Colony · Afternoon (trips 1 & 2) ──
mk(5008, 103, 'Karthik M', 'Saibaba Colony', 'delivered', '10:40', 2.9, 41, 1, 1, 'Kavya S', '34, NSR Rd, Saibaba Colony', '11:10', '11:05', 40),
mk(5009, 103, 'Karthik M', 'Saibaba Colony', 'arrived', '10:40', 3.6, 48, 2, 1, 'Vijay Anand', '9, Mettupalayam Rd, Saibaba Colony', '11:35', '', 45),
mk(5010, 103, 'Karthik M', 'Saibaba Colony', 'pending', '10:45', 2.2, 33, 3, 1, 'Meena G', '61, Thadagam Rd, Saibaba Colony', '12:00', '', 32),
mk(5011, 103, 'Karthik M', 'Saibaba Colony', 'cancelled', '11:50', 5.1, 0, 1, 2, 'Hariharan', '2, Ganapathy, Saibaba Colony', '12:20', '', 0),
// ── Priya S · Singanallur / Peelamedu · Evening (trip 1) ──
mk(5012, 104, 'Priya S', 'Singanallur', 'delivered', '16:20', 3.0, 44, 1, 1, 'Divya R', '19, Trichy Rd, Singanallur', '16:50', '16:47', 42),
mk(5013, 104, 'Priya S', 'Singanallur', 'active', '16:20', 4.5, 58, 2, 1, 'Senthil Kumar', '88, Singanallur Main Rd', '17:15', '', 55),
mk(5014, 104, 'Priya S', 'Singanallur', 'picked', '16:25', 2.7, 39, 3, 1, 'Anitha M', '7, Ondipudur, Singanallur', '17:40', '', 38),
mk(5015, 104, 'Priya S', 'Peelamedu', 'accepted', '16:25', 3.9, 50, 4, 1, 'Gokul Raj', '52, Hope College, Peelamedu', '18:05', '', 48),
// ── Unassigned · Peelamedu · Evening ──
mk(5016, 0, '', 'Peelamedu', 'pending', '17:25', 2.3, 34, 1, 1, 'Lakshmi Narayanan', '30, Lakshmi Mills, Peelamedu', '18:30', '', 33),
];
/** Sample active rider fleet (DispatchView only reads the count). */
export const MOCK_RIDERS: Row[] = [
{ userid: 101, firstname: 'Suresh', lastname: 'Kumar', contactno: '+91 98430 01101', starttime: '2026-06-09 06:30:00' },
{ userid: 102, firstname: 'Vignesh', lastname: 'R', contactno: '+91 98430 01102', starttime: '2026-06-09 09:15:00' },
{ userid: 103, firstname: 'Karthik', lastname: 'M', contactno: '+91 98430 01103', starttime: '2026-06-09 10:20:00' },
{ userid: 104, firstname: 'Priya', lastname: 'S', contactno: '+91 98430 01104', starttime: '2026-06-09 16:00:00' },
{ userid: 105, firstname: 'Mahesh', lastname: 'V', contactno: '+91 98430 01105', starttime: '' },
];