'use client'; import { useEffect, useState } from 'react'; import { crmService, CrmCustomer } from '@/services/api/crmService'; import { Wrench, Phone, Mail, Star, RefreshCw } from 'lucide-react'; import { toast } from 'sonner'; export default function ServiceRepairCustomersPage() { const [customers, setCustomers] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { loadCustomers(); }, []); const loadCustomers = async () => { try { setLoading(true); const data = await crmService.getCustomers(); // Filter customers who have repairs or service tier VIP/PRIORITY/STANDARD const svcCusts = data.filter((c) => (c.total_repairs_count || 0) > 0 || c.is_dual_customer || c.service_tier); setCustomers(svcCusts); } catch (err) { toast.error('Failed to load service customers'); } finally { setLoading(false); } }; return (

Service Repair Customers

Customer directory for device repair intake, IMEI service history, and VIP service tiers

{loading ? (
Loading Service Repair Customers...
) : customers.length === 0 ? (

No service customers recorded yet

Customers will appear here when repair tickets or service quotes are registered.

) : (
{customers.map((c) => (

{c.name || c.first_name || 'Service Customer'}

{c.email || 'No email'}

{c.service_tier || 'STANDARD'}
{c.phone}
{c.email && (
{c.email}
)}
{(c.is_dual_customer || ((c.total_orders_count || 0) > 0 && (c.total_repairs_count || 0) > 0)) && (
⭐ Gold Star VIP Dual Customer
)}
Total Repairs: {c.total_repairs_count || 0} Sales Tier: {c.sales_tier || 'BRONZE'}
))}
)}
); }