mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 15:18:11 +00:00
add contracts overview tab with KPIs, recent contracts, and charts
- Introduced OverviewContractKpisDto and OverviewRecentContractDto for contract metrics. - Implemented OverviewContractsTabDto to structure the contracts tab response. - Added contract-related constants for status groupings and pipeline stages. - Created OverviewContractsTabPanel and OverviewRecentContractsTable components for UI representation. - Updated OverviewService and OverviewRepository to fetch contract data. - Integrated contracts tab into OverviewController and OverviewTabContent. - Added hooks for fetching contracts data in useOverview. - Updated types in the overview module to include contracts. - Enhanced the contract detail page with a "View contract" button for generated PDFs.
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
export const OVERVIEW_URGENT_PRIORITY_THRESHOLD = 70;
|
||||
|
||||
// ── Booking status groupings ─────────────────────────────────────────────────
|
||||
// Derived from the current BookingStatus enum (@edr/types). "needs action" =
|
||||
// anything sitting on a staff queue; "closed" = terminal states.
|
||||
|
||||
export const OVERVIEW_NEEDS_ACTION_STATUSES = [
|
||||
'SUBMITTED',
|
||||
'PENDING_APPROVAL',
|
||||
'APPROVED_PENDING_SIGNATURE',
|
||||
'AWAITING_DOCUMENTS',
|
||||
'DOCUMENTS_UNDER_REVIEW',
|
||||
'OPERATION_REQUEST_PENDING',
|
||||
'OPERATION_CHANGES_REQUESTED',
|
||||
'OPERATION_PRICE_PENDING_CONFIRM',
|
||||
'PENDING_CONSOLIDATION',
|
||||
] as const;
|
||||
|
||||
export const OVERVIEW_IN_APPROVAL_STATUSES = [
|
||||
@@ -15,8 +25,82 @@ export const OVERVIEW_CLOSED_STATUSES = [
|
||||
'REJECTED',
|
||||
'CANCELLED',
|
||||
'COMPLETED',
|
||||
'DELIVERED',
|
||||
'EXPIRED',
|
||||
'CONTRACT_CLOSED',
|
||||
] as const;
|
||||
|
||||
// ── Contract status groupings ────────────────────────────────────────────────
|
||||
// Derived from CONTRACT_STATUSES (@edr/types). Separate machine from bookings.
|
||||
|
||||
export const OVERVIEW_CONTRACT_NEEDS_ACTION_STATUSES = [
|
||||
'SUBMITTED',
|
||||
'PENDING_APPROVAL',
|
||||
'APPROVED_PENDING_SIGNATURE',
|
||||
'PRICE_CHANGED_PENDING_CONFIRM',
|
||||
'CHANGES_REQUESTED',
|
||||
'RENEWAL_SUBMITTED',
|
||||
'RENEWAL_PENDING_APPROVAL',
|
||||
'AMENDMENTS_PROPOSED',
|
||||
] as const;
|
||||
|
||||
export const OVERVIEW_CONTRACT_IN_APPROVAL_STATUSES = [
|
||||
'PENDING_APPROVAL',
|
||||
'APPROVED_PENDING_SIGNATURE',
|
||||
'RENEWAL_PENDING_APPROVAL',
|
||||
] as const;
|
||||
|
||||
export const OVERVIEW_CONTRACT_IN_CLEARANCE_STATUSES = [
|
||||
'AWAITING_CLEARANCE_DOCUMENTS',
|
||||
'CLEARANCE_UNDER_REVIEW',
|
||||
'CLEARANCE_READY_FOR_BOOKING',
|
||||
] as const;
|
||||
|
||||
export const OVERVIEW_CONTRACT_CLOSED_STATUSES = [
|
||||
'CONTRACT_CLOSED',
|
||||
'EXPIRED',
|
||||
'REJECTED',
|
||||
'CANCELLED',
|
||||
'ARCHIVED',
|
||||
] as const;
|
||||
|
||||
/** Contract pipeline stages for the status chart, in workflow order. */
|
||||
export const OVERVIEW_CONTRACT_PIPELINE: ReadonlyArray<{
|
||||
stage: string;
|
||||
statuses: readonly string[];
|
||||
}> = [
|
||||
{ stage: 'draft', statuses: ['DRAFT', 'RENEWAL_DRAFT'] },
|
||||
{
|
||||
stage: 'intake',
|
||||
statuses: ['SUBMITTED', 'RENEWAL_SUBMITTED', 'PRICE_CHANGED_PENDING_CONFIRM', 'CHANGES_REQUESTED', 'AMENDMENTS_PROPOSED'],
|
||||
},
|
||||
{
|
||||
stage: 'in_approval',
|
||||
statuses: ['PENDING_APPROVAL', 'APPROVED', 'APPROVED_PENDING_SIGNATURE', 'RENEWAL_PENDING_APPROVAL'],
|
||||
},
|
||||
{ stage: 'signing', statuses: ['CONTRACT_READY', 'SIGNED_CUSTOMER'] },
|
||||
{
|
||||
stage: 'clearance',
|
||||
statuses: ['AWAITING_CLEARANCE_DOCUMENTS', 'CLEARANCE_UNDER_REVIEW', 'CLEARANCE_READY_FOR_BOOKING'],
|
||||
},
|
||||
{
|
||||
stage: 'active',
|
||||
statuses: ['FULLY_EXECUTED', 'CONTRACT_ACTIVE', 'ACTIVE_SHIPMENT_IN_PROGRESS'],
|
||||
},
|
||||
{ stage: 'closed', statuses: ['CONTRACT_CLOSED', 'EXPIRED', 'ARCHIVED'] },
|
||||
{ stage: 'cancelled', statuses: ['REJECTED', 'CANCELLED'] },
|
||||
];
|
||||
|
||||
/** Map a raw status→count record onto the contract pipeline stages. */
|
||||
export function mapContractStatusCountsToPipeline(
|
||||
statusCounts: Record<string, number>,
|
||||
): Array<{ stage: string; count: number }> {
|
||||
return OVERVIEW_CONTRACT_PIPELINE.map(({ stage, statuses }) => ({
|
||||
stage,
|
||||
count: statuses.reduce((sum, s) => sum + (statusCounts[s] ?? 0), 0),
|
||||
}));
|
||||
}
|
||||
|
||||
export const OVERVIEW_RANGE_DAYS = {
|
||||
'7d': 7,
|
||||
'30d': 30,
|
||||
|
||||
Reference in New Issue
Block a user