mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
feat: Refactor medical and sea service verification pages
- Split MedicalVerificationPage into MedicalVerificationPage and SeaServiceVerificationPage for better separation of concerns. - Update navigation to include separate entries for Sea Service Verification and Medical Verification. - Enhance sea service columns to display additional vessel information and days served. - Add translations for new and updated labels in both English and Amharic. - Introduce seaServiceDays helper function to calculate days served based on engagement and discharge dates. - Remove deprecated MedicalCertificatePage from the portal. - Update routing to direct to the new sea service and medical pages.
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
export * from './seafarer.types';
|
||||
export * from './seafarer-api';
|
||||
export * from './seafarer.helpers';
|
||||
|
||||
23
libs/api/src/lib/features/seafarer/seafarer.helpers.ts
Normal file
23
libs/api/src/lib/features/seafarer/seafarer.helpers.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Days served on one engagement, counted inclusively — embarkation and
|
||||
* discharge days both count. The same arithmetic the API uses for approved
|
||||
* sea time (`SeafarerRecordService.approvedSeaTime`), so the figure a seafarer
|
||||
* sees while typing is the figure the eligibility gate will credit.
|
||||
*
|
||||
* `null` until both dates are set or while they are out of order.
|
||||
*/
|
||||
export function seaServiceDays(
|
||||
engagementDate: string | null | undefined,
|
||||
dischargeDate: string | null | undefined,
|
||||
): number | null {
|
||||
if (!engagementDate || !dischargeDate) return null;
|
||||
const from = Date.UTC(...dateParts(engagementDate));
|
||||
const to = Date.UTC(...dateParts(dischargeDate));
|
||||
if (Number.isNaN(from) || Number.isNaN(to) || to < from) return null;
|
||||
return Math.round((to - from) / 86_400_000) + 1;
|
||||
}
|
||||
|
||||
function dateParts(value: string): [number, number, number] {
|
||||
const [y, m, d] = value.slice(0, 10).split('-').map(Number);
|
||||
return [y, (m || 1) - 1, d || 1];
|
||||
}
|
||||
Reference in New Issue
Block a user