mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
/seafarer-registration had a page of its own that wrote the profile directly and created no application at all. A "submitted" registration was therefore never reviewed, never approved and never numbered — there was nothing for an officer to open. The shared wizard, the review queue and the approval side effects all already existed; only the route pointed away from them. The page is deleted rather than repaired. It was a second wizard maintained alongside the config-driven one, and the seed already describes every step it was hand-rolling — including the physical characteristics and medical details added this release, which it would not have known about. /seafarer-registration now redirects, so navigation, deep links and the profile gate keep working. Also adds Configuration -> Number Formats, for the shape of generated seafarer, seaman book and BTC numbers. The sample is rendered by the server rather than formatted here, so the preview cannot drift from what an approval will actually generate, and asking for one never consumes a number. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
import { baseApi } from "@ema-platform/api";
|
|
import type {
|
|
Organization,
|
|
Profession,
|
|
ListResponse,
|
|
CreateProfessionPayload,
|
|
UpdateProfessionPayload,
|
|
NumberFormatConfig,
|
|
NumberFormatPayload,
|
|
} from "../types/configuration";
|
|
|
|
const configurationApi = baseApi.injectEndpoints({
|
|
endpoints: (builder) => ({
|
|
getOrganizations: builder.query<ListResponse<Organization>, void>({
|
|
query: () => "/organizations",
|
|
providesTags: ["Api"],
|
|
}),
|
|
|
|
getProfessions: builder.query<ListResponse<Profession>, string>({
|
|
query: (params) => ({
|
|
url: `/professions?q=${encodeURIComponent(params)}`,
|
|
}),
|
|
providesTags: ["Api", "backOfficeApi", "ProfessionApi"],
|
|
}),
|
|
createProfession: builder.mutation<Profession, CreateProfessionPayload>({
|
|
query: (body) => ({ url: "/professions", method: "POST", body }),
|
|
invalidatesTags: ["Api"],
|
|
}),
|
|
updateProfession: builder.mutation<Profession, UpdateProfessionPayload>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/professions/${id}`,
|
|
method: "PUT",
|
|
body,
|
|
}),
|
|
invalidatesTags: ["Api"],
|
|
}),
|
|
deleteProfession: builder.mutation<void, string>({
|
|
query: (id) => ({ url: `/professions/${id}`, method: "DELETE" }),
|
|
invalidatesTags: ["Api"],
|
|
}),
|
|
|
|
// Number formats — the shape of generated seafarer, seaman book and BTC
|
|
// identifiers. The counter behind each stays server-side; only the
|
|
// rendering is configurable here.
|
|
getNumberFormats: builder.query<NumberFormatConfig[], void>({
|
|
query: () => "/number-format-configs",
|
|
providesTags: ["Api", "NumberFormatApi"],
|
|
}),
|
|
createNumberFormat: builder.mutation<
|
|
NumberFormatConfig,
|
|
NumberFormatPayload
|
|
>({
|
|
query: (body) => ({
|
|
url: "/number-format-configs",
|
|
method: "POST",
|
|
body,
|
|
}),
|
|
invalidatesTags: ["Api", "NumberFormatApi"],
|
|
}),
|
|
updateNumberFormat: builder.mutation<
|
|
NumberFormatConfig,
|
|
{ id: string } & Partial<NumberFormatPayload>
|
|
>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/number-format-configs/${id}`,
|
|
method: "PATCH",
|
|
body,
|
|
}),
|
|
invalidatesTags: ["Api", "NumberFormatApi"],
|
|
}),
|
|
/**
|
|
* Server-rendered sample. Asked of the server rather than formatted in the
|
|
* browser so the preview cannot drift from what approval will actually
|
|
* generate — the two would be the same rule written twice.
|
|
*/
|
|
previewNumberFormat: builder.mutation<
|
|
{ sample: string },
|
|
NumberFormatPayload
|
|
>({
|
|
query: (body) => ({
|
|
url: "/number-format-configs/preview",
|
|
method: "POST",
|
|
body,
|
|
}),
|
|
}),
|
|
}),
|
|
overrideExisting: true,
|
|
});
|
|
|
|
export const {
|
|
useGetOrganizationsQuery,
|
|
useGetProfessionsQuery,
|
|
useCreateProfessionMutation,
|
|
useUpdateProfessionMutation,
|
|
useDeleteProfessionMutation,
|
|
useGetNumberFormatsQuery,
|
|
useCreateNumberFormatMutation,
|
|
useUpdateNumberFormatMutation,
|
|
usePreviewNumberFormatMutation,
|
|
} = configurationApi;
|