fix(repair): fetch full ticket queue, map all 5 stages, and show customer & tech status on cards

This commit is contained in:
iFixKart Dev 2026-11-16 18:54:42 +05:30
parent 6527831bdd
commit 27bb90c0f9
2 changed files with 22 additions and 4 deletions

View file

@ -21,7 +21,7 @@ export default function RepairTicketsPage() {
const loadTickets = async () => { const loadTickets = async () => {
try { try {
setLoading(true); setLoading(true);
const data = await repairService.getTickets(); const data = await repairService.getTickets(undefined, 200);
setTickets(data); setTickets(data);
} catch (err) { } catch (err) {
setTickets([ setTickets([
@ -135,7 +135,8 @@ export default function RepairTicketsPage() {
return currentStage === stage.toUpperCase() || return currentStage === stage.toUpperCase() ||
(stage === 'INTAKE' && (currentStage === 'RECEIVED' || currentStage === 'INTAKE')) || (stage === 'INTAKE' && (currentStage === 'RECEIVED' || currentStage === 'INTAKE')) ||
(stage === 'REPAIRING' && (currentStage === 'UNDER_REPAIR' || currentStage === 'PART_PENDING')) || (stage === 'REPAIRING' && (currentStage === 'UNDER_REPAIR' || currentStage === 'PART_PENDING')) ||
(stage === 'COMPLETED' && (currentStage === 'READY_FOR_DELIVERY' || currentStage === 'QC_TESTING')); (stage === 'COMPLETED' && (currentStage === 'READY_FOR_DELIVERY' || currentStage === 'QC_TESTING')) ||
(stage === 'DELIVERED' && (currentStage === 'CLOSED' || currentStage === 'DELIVERED' || currentStage === 'CANCELLED'));
}); });
return ( return (
@ -170,6 +171,19 @@ export default function RepairTicketsPage() {
</span> </span>
</div> </div>
<div className="flex items-center justify-between gap-1 text-[11px] text-muted-foreground mb-1.5">
<span className="truncate font-medium text-foreground">{t.customer_name || 'Walk-in Customer'}</span>
{t.assigned_technician_name ? (
<span className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-emerald-500/10 text-emerald-600 dark:text-emerald-400">
{t.assigned_technician_name}
</span>
) : (
<span className="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold bg-amber-500/10 text-amber-600 dark:text-amber-400">
Unassigned
</span>
)}
</div>
<div className="text-[13px] font-medium text-foreground flex items-center gap-1.5 mb-1"> <div className="text-[13px] font-medium text-foreground flex items-center gap-1.5 mb-1">
<Smartphone className="w-3.5 h-3.5 text-muted-foreground shrink-0" /> <Smartphone className="w-3.5 h-3.5 text-muted-foreground shrink-0" />
{(t.brand_name || t.model_name) {(t.brand_name || t.model_name)

View file

@ -17,13 +17,17 @@ export interface RepairTicket {
priority?: string; priority?: string;
device_id?: string; device_id?: string;
assigned_technician_id?: string; assigned_technician_id?: string;
assigned_technician_name?: string;
sla_due_at?: string; sla_due_at?: string;
created_at?: string; created_at?: string;
} }
export const repairService = { export const repairService = {
getTickets: async (status?: string) => { getTickets: async (stage?: string, limit = 200) => {
const query = status ? `?status=${encodeURIComponent(status)}` : ''; const params = new URLSearchParams();
if (stage) params.append('stage', stage);
if (limit) params.append('limit', String(limit));
const query = params.toString() ? `?${params.toString()}` : '';
return apiFetch<RepairTicket[]>(`/api/v1/repair/tickets${query}`); return apiFetch<RepairTicket[]>(`/api/v1/repair/tickets${query}`);
}, },