mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 20:10:58 +00:00
- Remove SeamanBookApplicationPage from router and redirect to Seaman Book page. - Add new API endpoints for managing seafarer documents, including listing, reviewing, and issuing documents. - Introduce new SeafarerDocumentQueuePage and SeafarerDocumentReviewPage components for document management. - Update licensing types to accommodate optional applicationId and documentId in ApplicationPayment. - Remove unused claimSeafarerRegistration mutation and related constants. - Update seafarer registration status labels and types to remove 'UNDER_REVIEW'. - Create new constants and types for seafarer documents, including status labels and colors. - Implement document payment initiation and confirmation functionalities. - Enhance UI components for better user experience in document management.
132 lines
4.7 KiB
TypeScript
132 lines
4.7 KiB
TypeScript
import { baseApi } from '../../base-api';
|
|
import type { ApplicationPayment, InitiatePaymentResult } from '../licensing/licensing.types';
|
|
import type {
|
|
SeafarerDocument,
|
|
SeafarerDocumentDetail,
|
|
SeafarerDocumentKind,
|
|
SeafarerDocumentRow,
|
|
SeafarerDocumentStatus,
|
|
} from './seafarer-document.types';
|
|
|
|
const TAG = 'SeafarerDocument' as const;
|
|
const LIST = { type: TAG, id: 'LIST' } as const;
|
|
const item = (id: string) => ({ type: TAG, id }) as const;
|
|
|
|
export interface SeafarerDocumentListFilter {
|
|
kind?: SeafarerDocumentKind;
|
|
status?: SeafarerDocumentStatus;
|
|
search?: string;
|
|
take?: number;
|
|
skip?: number;
|
|
}
|
|
|
|
/**
|
|
* Seaman Book and BTC — own endpoints, not licence applications. Fees settle
|
|
* through the same payment gateway, under `/seafarer-documents/:id/payments`.
|
|
*/
|
|
export const seafarerDocumentApi = baseApi
|
|
.enhanceEndpoints({ addTagTypes: [TAG] })
|
|
.injectEndpoints({
|
|
endpoints: (builder) => ({
|
|
// ------------------------------------------------------------ applicant
|
|
getMySeafarerDocuments: builder.query<
|
|
{ seamanBook: SeafarerDocument | null; btc: SeafarerDocument | null },
|
|
void
|
|
>({
|
|
query: () => ({ url: '/seafarer-documents/mine' }),
|
|
providesTags: () => [LIST],
|
|
}),
|
|
|
|
getMySeafarerDocumentDownload: builder.query<{ url: string }, string>({
|
|
query: (id) => ({ url: `/seafarer-documents/${id}/download` }),
|
|
}),
|
|
|
|
initiateDocumentPayment: builder.mutation<
|
|
InitiatePaymentResult,
|
|
{ id: string; provider?: string; platform?: 'web' | 'mobile'; payerAccount?: string }
|
|
>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/seafarer-documents/${id}/payments/initiate`,
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
getDocumentPayment: builder.query<ApplicationPayment, string>({
|
|
query: (id) => ({ url: `/seafarer-documents/${id}/payments` }),
|
|
providesTags: (_r, _e, id) => [item(id)],
|
|
}),
|
|
|
|
bypassDocumentPayment: builder.mutation<{ status: SeafarerDocumentStatus }, string>({
|
|
query: (id) => ({ url: `/seafarer-documents/${id}/payments/bypass`, method: 'POST' }),
|
|
invalidatesTags: (_r, error, id) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
// --------------------------------------------------------------- review
|
|
listSeafarerDocuments: builder.query<
|
|
{ total: number; items: SeafarerDocumentRow[] },
|
|
SeafarerDocumentListFilter
|
|
>({
|
|
query: (params) => ({ url: '/seafarer-document-review', params }),
|
|
providesTags: () => [LIST],
|
|
}),
|
|
|
|
getSeafarerDocumentReview: builder.query<SeafarerDocumentDetail, string>({
|
|
query: (id) => ({ url: `/seafarer-document-review/${id}` }),
|
|
providesTags: (_r, _e, id) => [item(id)],
|
|
}),
|
|
|
|
getSeafarerDocumentReviewDownload: builder.query<{ url: string }, string>({
|
|
query: (id) => ({ url: `/seafarer-document-review/${id}/download` }),
|
|
}),
|
|
|
|
confirmSeafarerDocumentPayment: builder.mutation<SeafarerDocument, string>({
|
|
query: (id) => ({ url: `/seafarer-document-review/${id}/confirm-payment`, method: 'POST' }),
|
|
invalidatesTags: (_r, error, id) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
scheduleSeafarerDocument: builder.mutation<
|
|
SeafarerDocument,
|
|
{ id: string; scheduledDate: string }
|
|
>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/seafarer-document-review/${id}/schedule-issuance`,
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
issueSeafarerDocument: builder.mutation<SeafarerDocument, string>({
|
|
query: (id) => ({ url: `/seafarer-document-review/${id}/issue`, method: 'POST' }),
|
|
invalidatesTags: (_r, error, id) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
rejectSeafarerDocument: builder.mutation<SeafarerDocument, { id: string; reason: string }>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/seafarer-document-review/${id}/reject`,
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
}),
|
|
overrideExisting: false,
|
|
});
|
|
|
|
export const {
|
|
useGetMySeafarerDocumentsQuery,
|
|
useLazyGetMySeafarerDocumentDownloadQuery,
|
|
useInitiateDocumentPaymentMutation,
|
|
useGetDocumentPaymentQuery,
|
|
useBypassDocumentPaymentMutation,
|
|
useListSeafarerDocumentsQuery,
|
|
useGetSeafarerDocumentReviewQuery,
|
|
useLazyGetSeafarerDocumentReviewDownloadQuery,
|
|
useConfirmSeafarerDocumentPaymentMutation,
|
|
useScheduleSeafarerDocumentMutation,
|
|
useIssueSeafarerDocumentMutation,
|
|
useRejectSeafarerDocumentMutation,
|
|
} = seafarerDocumentApi;
|