feat: implement applicant name fallback logic in licensing helpers and update MyApplicationsPage

This commit is contained in:
estifanos
2026-08-12 07:18:43 +00:00
parent 829dfed999
commit 0633ecc165
3 changed files with 28 additions and 23 deletions

View File

@@ -33,8 +33,10 @@ import {
import { notifications } from "@mantine/notifications";
import { useTranslation } from "react-i18next";
import {
APPLICANT_NAME_TYPE_KEYS,
STATUS_COLORS,
STATUS_LABELS,
applicantOrCompanyName,
extractErrorMessage,
useClaimApplicationMutation,
useGetAllApplicationsQuery,
@@ -89,27 +91,6 @@ const ALL_STATUSES: LicenseStatus[] = [
"REJECTED",
];
/** Licence types with no `companyName` — the queue's "company" column falls
* back to the applicant name captured in the form instead. */
const APPLICANT_NAME_TYPE_KEYS = [
"SEAFARER_REGISTRATION",
"CERTIFICATE_OF_COMPETENCY",
"CERTIFICATE_OF_PROFICIENCY",
"VESSEL_REGISTRATION",
"VESSEL_OWNERSHIP_TRANSFER",
"ENDORSEMENT_COC",
"ENDORSEMENT_GOC",
];
function applicantOrCompanyName(app: LicenseApplication): string | undefined {
if (!app.licenseType?.key || !APPLICANT_NAME_TYPE_KEYS.includes(app.licenseType.key)) {
return app.companyName ?? undefined;
}
const applicantName = (app.formData?.account as Record<string, unknown> | undefined)
?.applicantName;
return typeof applicantName === "string" && applicantName ? applicantName : undefined;
}
/**
* The officer work pool.
*

View File

@@ -21,6 +21,7 @@ import { notifications } from '@mantine/notifications';
import {
STATUS_COLORS,
STATUS_LABELS,
applicantOrCompanyName,
extractErrorMessage,
localized,
useBypassPaymentMutation,
@@ -120,7 +121,7 @@ export function MyApplicationsPage() {
const q = search.trim().toLowerCase();
return allItems.filter((app) => {
if (q) {
const haystack = `${app.applicationNumber} ${app.companyName ?? ''}`.toLowerCase();
const haystack = `${app.applicationNumber} ${applicantOrCompanyName(app) ?? ''}`.toLowerCase();
if (!haystack.includes(q)) return false;
}
if (statusFilter && app.status !== statusFilter) return false;
@@ -201,7 +202,7 @@ export function MyApplicationsPage() {
},
{
header: 'Company',
cell: ({ row }) => <Text size="sm">{row.original.companyName ?? '—'}</Text>,
cell: ({ row }) => <Text size="sm">{applicantOrCompanyName(row.original) ?? '—'}</Text>,
},
{
header: 'Status',