mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-09-08 06:35:44 +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.
119 lines
4.2 KiB
TypeScript
119 lines
4.2 KiB
TypeScript
import { baseApi } from '../../base-api';
|
|
import type { Attachment } from '../licensing/licensing.types';
|
|
import type {
|
|
SaveSeafarerRegistration,
|
|
SeafarerRegistration,
|
|
SeafarerRegistrationStatus,
|
|
} from './seafarer-registration.types';
|
|
|
|
const TAG = 'SeafarerRegistration' as const;
|
|
const LIST = { type: TAG, id: 'LIST' } as const;
|
|
const item = (id: string) => ({ type: TAG, id }) as const;
|
|
|
|
export interface SeafarerRegistrationListFilter {
|
|
status?: SeafarerRegistrationStatus;
|
|
search?: string;
|
|
take?: number;
|
|
skip?: number;
|
|
}
|
|
|
|
/**
|
|
* Seafarer registration — its own endpoints, not a licence application.
|
|
* Uploads still go through `/attachments` with ownerType SEAFARER_REGISTRATION.
|
|
*/
|
|
export const seafarerRegistrationApi = baseApi
|
|
.enhanceEndpoints({ addTagTypes: [TAG] })
|
|
.injectEndpoints({
|
|
endpoints: (builder) => ({
|
|
// ------------------------------------------------------------ applicant
|
|
getMySeafarerRegistration: builder.query<{ registration: SeafarerRegistration | null }, void>({
|
|
query: () => ({ url: '/seafarer-registrations/mine' }),
|
|
providesTags: (r) => [LIST, ...(r?.registration ? [item(r.registration.id)] : [])],
|
|
}),
|
|
|
|
startSeafarerRegistration: builder.mutation<SeafarerRegistration, void>({
|
|
query: () => ({ url: '/seafarer-registrations', method: 'POST' }),
|
|
invalidatesTags: (_r, error) => (error ? [] : [LIST]),
|
|
}),
|
|
|
|
saveSeafarerRegistration: builder.mutation<
|
|
SeafarerRegistration,
|
|
{ id: string; body: SaveSeafarerRegistration }
|
|
>({
|
|
query: ({ id, body }) => ({ url: `/seafarer-registrations/${id}`, method: 'PUT', body }),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
submitSeafarerRegistration: builder.mutation<SeafarerRegistration, string>({
|
|
query: (id) => ({ url: `/seafarer-registrations/${id}/submit`, method: 'POST' }),
|
|
invalidatesTags: (_r, error, id) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
// --------------------------------------------------------------- review
|
|
listSeafarerRegistrations: builder.query<
|
|
{ total: number; items: SeafarerRegistration[] },
|
|
SeafarerRegistrationListFilter
|
|
>({
|
|
query: (params) => ({ url: '/seafarer-registration-review', params }),
|
|
providesTags: () => [LIST],
|
|
}),
|
|
|
|
getSeafarerRegistrationReview: builder.query<
|
|
{ registration: SeafarerRegistration; attachments: Attachment[] },
|
|
string
|
|
>({
|
|
query: (id) => ({ url: `/seafarer-registration-review/${id}` }),
|
|
providesTags: (_r, _e, id) => [item(id)],
|
|
}),
|
|
|
|
approveSeafarerRegistration: builder.mutation<
|
|
SeafarerRegistration,
|
|
{ id: string; remark?: string }
|
|
>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/seafarer-registration-review/${id}/approve`,
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
rejectSeafarerRegistration: builder.mutation<
|
|
SeafarerRegistration,
|
|
{ id: string; reason: string }
|
|
>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/seafarer-registration-review/${id}/reject`,
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
|
|
requestSeafarerRegistrationChanges: builder.mutation<
|
|
SeafarerRegistration,
|
|
{ id: string; remark: string }
|
|
>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/seafarer-registration-review/${id}/request-changes`,
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
invalidatesTags: (_r, error, { id }) => (error ? [] : [LIST, item(id)]),
|
|
}),
|
|
}),
|
|
overrideExisting: false,
|
|
});
|
|
|
|
export const {
|
|
useGetMySeafarerRegistrationQuery,
|
|
useStartSeafarerRegistrationMutation,
|
|
useSaveSeafarerRegistrationMutation,
|
|
useSubmitSeafarerRegistrationMutation,
|
|
useListSeafarerRegistrationsQuery,
|
|
useGetSeafarerRegistrationReviewQuery,
|
|
useApproveSeafarerRegistrationMutation,
|
|
useRejectSeafarerRegistrationMutation,
|
|
useRequestSeafarerRegistrationChangesMutation,
|
|
} = seafarerRegistrationApi;
|