'use client' import { useEffect, useState } from 'react' import { apiFetch } from '@/lib/api' import { useDashboardI18n } from '@/components/I18nProvider' interface CustomerRow { id: string firstName: string lastName: string email: string phone: string | null flagged: boolean licenseValidationStatus: string licenseImageUrl: string | null } export default function CustomersPage() { const { language } = useDashboardI18n() const [rows, setRows] = useState([]) const [error, setError] = useState(null) const copy = { en: { title: 'Customers', subtitle: 'A company CRM with license validation and risk flags.', customer: 'Customer', contact: 'Contact', license: 'License', flags: 'Flags', imageUploaded: 'Image uploaded', imageMissing: 'No image', noPhone: 'No phone', flagged: 'Flagged', clear: 'Clear', empty: 'No customers yet.', }, fr: { title: 'Clients', subtitle: 'CRM de l’entreprise avec validation des permis et indicateurs de risque.', customer: 'Client', contact: 'Contact', license: 'Permis', flags: 'Signalements', imageUploaded: 'Image téléversée', imageMissing: 'Aucune image', noPhone: 'Pas de téléphone', flagged: 'Signalé', clear: 'Aucun risque', empty: 'Aucun client pour le moment.', }, ar: { title: 'العملاء', subtitle: 'نظام إدارة عملاء خاص بالشركة مع التحقق من الرخص ومؤشرات المخاطر.', customer: 'العميل', contact: 'التواصل', license: 'الرخصة', flags: 'العلامات', imageUploaded: 'تم رفع الصورة', imageMissing: 'لا توجد صورة', noPhone: 'لا يوجد هاتف', flagged: 'تم تمييزه', clear: 'لا توجد مخاطر', empty: 'لا يوجد عملاء حتى الآن.', }, }[language] useEffect(() => { apiFetch('/customers?pageSize=100') .then((result) => setRows(result ?? [])) .catch((err) => setError(err.message)) }, []) return (

{copy.title}

{copy.subtitle}

{error ? (
{error}
) : (
{rows.map((row) => ( ))} {rows.length === 0 && ( )}
{copy.customer} {copy.contact} {copy.license} {copy.flags}
{row.firstName} {row.lastName}

{row.email}

{row.phone ?? copy.noPhone}

{row.licenseValidationStatus} {row.licenseImageUrl ? copy.imageUploaded : copy.imageMissing}
{row.flagged ? {copy.flagged} : {copy.clear}}
{copy.empty}
)}
) }