- Backend: FastAPI app with all models, services, schemas, routes - Admin Panel: Next.js dashboard with all modules (CRM, POS, repairs, warranties, billing, notifications, etc.) - Ecommerce: storefront (submodule) + product catalog - AI Agents: .agents/ skill library for Antigravity IDE - Docs: architecture, billing, notification gateway markdown - Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
189 lines
7.4 KiB
TypeScript
189 lines
7.4 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { repairService, RepairTicket } from '@/services/api/repairService';
|
|
import { Wrench, Clock, AlertTriangle, Search, Plus, Smartphone, ShieldCheck } from 'lucide-react';
|
|
|
|
const STAGES = ['INTAKE', 'DIAGNOSING', 'REPAIRING', 'COMPLETED', 'DELIVERED'];
|
|
|
|
export default function RepairTicketsPage() {
|
|
const [tickets, setTickets] = useState<RepairTicket[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
const [searchImei, setSearchImei] = useState('');
|
|
|
|
useEffect(() => {
|
|
loadTickets();
|
|
}, []);
|
|
|
|
const loadTickets = async () => {
|
|
try {
|
|
setLoading(true);
|
|
const data = await repairService.getTickets();
|
|
setTickets(data);
|
|
} catch (err) {
|
|
setTickets([
|
|
{
|
|
ticket_id: '1',
|
|
tenant_id: 'tenant_default',
|
|
ticket_number: 'REP-2026-001',
|
|
customer_id: 'c1',
|
|
customer_name: 'Adithiyan E',
|
|
customer_phone: '+91 9876543210',
|
|
imei_serial: '356789123456789',
|
|
brand_name: 'Apple',
|
|
model_name: 'iPhone 14 Pro',
|
|
problem_description: 'Screen shattered, touch un-responsive',
|
|
status: 'REPAIRING',
|
|
priority: 'URGENT',
|
|
sla_due_at: new Date(Date.now() + 3600000 * 3).toISOString(),
|
|
created_at: new Date().toISOString()
|
|
},
|
|
{
|
|
ticket_id: '2',
|
|
tenant_id: 'tenant_default',
|
|
ticket_number: 'REP-2026-002',
|
|
customer_id: 'c2',
|
|
customer_name: 'Suresh Babu',
|
|
customer_phone: '+91 9123456789',
|
|
imei_serial: '864201928374651',
|
|
brand_name: 'Samsung',
|
|
model_name: 'Galaxy S23 Ultra',
|
|
problem_description: 'Battery drain & overheating during charging',
|
|
status: 'DIAGNOSING',
|
|
priority: 'NORMAL',
|
|
sla_due_at: new Date(Date.now() + 3600000 * 12).toISOString(),
|
|
created_at: new Date().toISOString()
|
|
},
|
|
{
|
|
ticket_id: '3',
|
|
tenant_id: 'tenant_default',
|
|
ticket_number: 'REP-2026-003',
|
|
customer_id: 'c3',
|
|
customer_name: 'Meena R',
|
|
customer_phone: '+91 9988776655',
|
|
imei_serial: '990011223344556',
|
|
brand_name: 'OnePlus',
|
|
model_name: 'OnePlus 11',
|
|
problem_description: 'Charging port damaged',
|
|
status: 'INTAKE',
|
|
priority: 'HIGH',
|
|
sla_due_at: new Date(Date.now() + 3600000 * 6).toISOString(),
|
|
created_at: new Date().toISOString()
|
|
}
|
|
]);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const filteredTickets = tickets.filter(
|
|
(t) =>
|
|
t.imei_serial.includes(searchImei) ||
|
|
t.ticket_number.toLowerCase().includes(searchImei.toLowerCase()) ||
|
|
t.customer_name.toLowerCase().includes(searchImei.toLowerCase())
|
|
);
|
|
|
|
return (
|
|
<div className="p-6 space-y-6">
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<h1 className="text-2xl font-bold tracking-tight text-foreground flex items-center gap-2">
|
|
<Wrench className="w-6 h-6 text-primary" />
|
|
5-Stage Repair ERP Ticket Queue
|
|
</h1>
|
|
<p className="text-sm text-muted-foreground">
|
|
Track repair stage workflows, IMEI diagnostics, and SLA timers
|
|
</p>
|
|
</div>
|
|
|
|
<div className="flex items-center gap-3">
|
|
<div className="relative">
|
|
<Search className="w-4 h-4 text-muted-foreground absolute left-3 top-1/2 -translate-y-1/2" />
|
|
<input
|
|
type="text"
|
|
placeholder="Search IMEI, Ticket #, Customer..."
|
|
value={searchImei}
|
|
onChange={(e) => setSearchImei(e.target.value)}
|
|
className="pl-9 pr-4 py-2 bg-card border border-border rounded-lg text-xs w-64 focus:outline-hidden text-foreground"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{loading ? (
|
|
<div className="py-20 text-center text-muted-foreground animate-pulse">Loading Repair Board...</div>
|
|
) : (
|
|
<div className="grid grid-cols-1 md:grid-cols-5 gap-4">
|
|
{STAGES.map((stage) => {
|
|
const stageTickets = filteredTickets.filter((t) => t.status === stage);
|
|
|
|
return (
|
|
<div key={stage} className="bg-card border border-border rounded-xl p-3 flex flex-col min-h-[500px]">
|
|
<div className="flex items-center justify-between border-b border-border pb-2 mb-3">
|
|
<span className="text-xs font-bold uppercase tracking-wider text-foreground">
|
|
{stage}
|
|
</span>
|
|
<span className="text-xs bg-muted text-muted-foreground px-2 py-0.5 rounded-full font-semibold">
|
|
{stageTickets.length}
|
|
</span>
|
|
</div>
|
|
|
|
<div className="space-y-3 overflow-y-auto">
|
|
{stageTickets.map((t) => (
|
|
<div
|
|
key={t.ticket_id}
|
|
className="p-3 bg-background border border-border rounded-lg shadow-2xs hover:border-primary transition-all cursor-pointer"
|
|
>
|
|
<div className="flex items-center justify-between mb-1.5">
|
|
<span className="text-[11px] font-bold text-primary">{t.ticket_number}</span>
|
|
<span
|
|
className={`text-[9px] font-bold px-1.5 py-0.5 rounded-sm ${
|
|
t.priority === 'URGENT'
|
|
? 'bg-rose-500/10 text-rose-600'
|
|
: t.priority === 'HIGH'
|
|
? 'bg-amber-500/10 text-amber-600'
|
|
: 'bg-muted text-muted-foreground'
|
|
}`}
|
|
>
|
|
{t.priority}
|
|
</span>
|
|
</div>
|
|
|
|
<div className="text-xs font-semibold text-foreground flex items-center gap-1 mb-1">
|
|
<Smartphone className="w-3 h-3 text-muted-foreground" />
|
|
{t.brand_name} {t.model_name}
|
|
</div>
|
|
|
|
<p className="text-[11px] text-muted-foreground line-clamp-2 mb-2">
|
|
{t.problem_description}
|
|
</p>
|
|
|
|
<div className="border-t border-border pt-2 flex items-center justify-between text-[10px] text-muted-foreground">
|
|
<div className="flex items-center gap-1">
|
|
<ShieldCheck className="w-3 h-3 text-emerald-600" />
|
|
<span className="font-mono">{t.imei_serial.slice(-6)}</span>
|
|
</div>
|
|
{t.sla_due_at && (
|
|
<div className="flex items-center gap-1 text-amber-600 font-semibold">
|
|
<Clock className="w-3 h-3" />
|
|
<span>SLA Active</span>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
))}
|
|
|
|
{stageTickets.length === 0 && (
|
|
<div className="py-12 text-center text-xs text-muted-foreground border border-dashed border-border rounded-lg">
|
|
No Tickets in {stage}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|