diff --git a/apps/backoffice/src/app/features/combined-license/pages/CombinedLicenseQueuePage.tsx b/apps/backoffice/src/app/features/combined-license/pages/CombinedLicenseQueuePage.tsx new file mode 100644 index 000000000..e3390ab11 --- /dev/null +++ b/apps/backoffice/src/app/features/combined-license/pages/CombinedLicenseQueuePage.tsx @@ -0,0 +1,419 @@ +import { useEffect, useRef, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { useApiMutation } from '@ema-platform/api'; +import { + ActionIcon, + Badge, + Button, + Card, + Drawer, + Group, + Modal, + Paper, + Select, + SimpleGrid, + Stack, + Table, + Text, + Textarea, + TextInput, + ThemeIcon, + Title, +} from '@mantine/core'; +import { + IconCheck, + IconCircleCheck, + IconEye, + IconSearch, + IconShip, + IconX, + IconAlertCircle, +} from '@tabler/icons-react'; +import { notify } from '@ema-platform/ui'; + +// --------------------------------------------------------------------------- +// Types & constants +// --------------------------------------------------------------------------- +export type LicenseStatus = + | 'Submitted' + | 'Under Review' + | 'Under Evaluation' + | 'Approved' + | 'Resubmit Required' + | 'Rejected' + | 'Payment Pending' + | 'Payment Confirmed' + | 'Certificate Issued'; + +export interface CombinedLicenseApplication { + id: string; + companyName: string; + tinNumber: string; + commercialRegNumber: string; + businessAddress: string; + bankName: string; + capitalAmount: number; + status: LicenseStatus; + submittedDate: string; + approvalDate: string | null; + expiryDate: string | null; + remarks: string; + docsComplete: boolean; +} + +export const MOCK_COMBINED_APPLICATIONS: CombinedLicenseApplication[] = [ + { + id: 'CFS-2024-001', + companyName: 'Blue Nile Shipping & Forwarding PLC', + tinNumber: 'TIN-0098231', + commercialRegNumber: 'CR-902341', + businessAddress: 'Addis Ababa, Bole Sub-city', + bankName: 'Commercial Bank of Ethiopia', + capitalAmount: 2200000, + status: 'Under Evaluation', + submittedDate: '2024-03-14', + approvalDate: null, + expiryDate: null, + remarks: 'Terminal agreement and transit staff certificates under review.', + docsComplete: true, + }, + { + id: 'CFS-2024-002', + companyName: 'Red Sea Gateway Logistics Ltd', + tinNumber: 'TIN-0071122', + commercialRegNumber: 'CR-813457', + businessAddress: 'Dire Dawa', + bankName: 'Dashen Bank', + capitalAmount: 1650000, + status: 'Submitted', + submittedDate: '2024-04-05', + approvalDate: null, + expiryDate: null, + remarks: '', + docsComplete: false, + }, + { + id: 'CFS-2023-017', + companyName: 'Tana Maritime & Forwarding PLC', + tinNumber: 'TIN-0045690', + commercialRegNumber: 'CR-704128', + businessAddress: 'Addis Ababa, Kirkos Sub-city', + bankName: 'Awash Bank', + capitalAmount: 2500000, + status: 'Certificate Issued', + submittedDate: '2023-10-12', + approvalDate: '2023-11-08', + expiryDate: '2024-11-08', + remarks: 'All requirements verified. Certificate issued.', + docsComplete: true, + }, +]; + +export const STATUS_COLOR: Record = { + Draft: 'gray', + Submitted: 'blue', + 'Under Review': 'yellow', + 'Under Evaluation': 'yellow', + Approved: 'teal', + 'Resubmit Required': 'orange', + Rejected: 'red', + 'Payment Pending': 'grape', + 'Payment Confirmed': 'indigo', + 'Certificate Issued': 'green', +}; + +// --------------------------------------------------------------------------- +// Detail drawer +// --------------------------------------------------------------------------- +function ApplicationDrawer({ + app, + opened, + onClose, + onAction, + onFullReview, +}: { + app: CombinedLicenseApplication | null; + opened: boolean; + onClose: () => void; + onAction: (id: string, action: 'approve' | 'reject' | 'resubmit', remarks: string) => void; + onFullReview: (id: string) => void; +}) { + const [remarks, setRemarks] = useState(''); + const [confirmModal, setConfirmModal] = useState<'approve' | 'reject' | 'resubmit' | null>(null); + + if (!app) return null; + + const isTerminal = app.status === 'Rejected' || app.status === 'Certificate Issued'; + + const submit = (action: 'approve' | 'reject' | 'resubmit') => { + onAction(app.id, action, remarks); + setRemarks(''); + setConfirmModal(null); + onClose(); + }; + + return ( + <> + + + + + + Company Information + + {[ + { label: 'Company Name', value: app.companyName }, + { label: 'TIN Number', value: app.tinNumber }, + { label: 'Commercial Reg. No.', value: app.commercialRegNumber }, + { label: 'Business Address', value: app.businessAddress }, + { label: 'Bank Letter Amount', value: `${app.capitalAmount.toLocaleString()} ETB` }, + { label: 'Submitted', value: app.submittedDate }, + ].map((r) => ( +
+ {r.label} + {r.value || '—'} +
+ ))} +
+
+ + + Document Checklist + + {[ + { label: 'Shipping Company Agreement', ok: app.docsComplete }, + { label: 'Bank Letter (≥ 1.5M ETB)', ok: app.docsComplete }, + { label: 'Vehicle Libre / Rental Agreement', ok: app.docsComplete }, + { label: 'Office Title Deed / Rental Agreement', ok: app.docsComplete }, + { label: 'Terminal Agreement / Title Deed', ok: app.docsComplete }, + { label: '2 Qualified Transit Employees (ERB Certificates)', ok: app.docsComplete }, + ].map((item) => ( + + + {item.ok ? : } + + {item.label} + + ))} + + + + + + Current Status + {app.status} + + {app.remarks && {app.remarks}} + + + {!isTerminal && ( + + Officer Remarks +