import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Box, Button, Card, Stack, Typography } from '@mui/material'; import { DataGrid, type GridColDef } from '@mui/x-data-grid'; import { useCustomers } from '../../../hooks/useCustomers'; import { useBranchStore } from '../../../store/branchStore'; import { useAuth } from '../../../hooks/useAuth'; import { StatusChip } from '../../../components/common/StatusChip'; import { MoneyCell } from '../../../components/common/MoneyCell'; import type { Customer } from '../../../types/api'; import { CustomerDialog } from './CustomerDialog'; export function CustomersListPage() { const navigate = useNavigate(); const selected = useBranchStore((state) => state.selected); const { data: customers, isLoading } = useCustomers(selected); const { hasPermission } = useAuth(); const [dialogOpen, setDialogOpen] = useState(false); const columns: GridColDef[] = [ { field: 'code', headerName: 'Code', width: 140 }, { field: 'name', headerName: 'Name', flex: 1 }, { field: 'email', headerName: 'Email', flex: 1 }, { field: 'phone', headerName: 'Phone', width: 160 }, { field: 'creditLimit', headerName: 'Credit Limit', width: 140, align: 'right', headerAlign: 'right', renderCell: (params) => , }, { field: 'paymentTermsDays', headerName: 'Terms (days)', width: 130 }, { field: 'isActive', headerName: 'Status', width: 100, renderCell: (params) => , }, ]; return ( Customers {hasPermission('ar.customer.manage') && ( )} navigate(`/ar/customers/${params.row.id}`)} sx={{ border: 'none', '& .MuiDataGrid-row': { cursor: 'pointer' } }} /> setDialogOpen(false)} /> ); }