Merge branch 'createNewLicenseType' of https://github.com/Tria-plc/emaui into createNewLicenseType

This commit is contained in:
Estifo77
2026-09-02 14:18:35 +03:00
12 changed files with 784 additions and 43 deletions

View File

@@ -29,6 +29,8 @@ import type {
DocumentDecision,
DocumentReview,
ExportResult,
FamilyKind,
LicenseCategory,
LicenseTemplate,
Paginated,
PickupAppointment,
@@ -111,6 +113,28 @@ const TAGS = [
const listTag = (type: (typeof TAGS)[number]) => ({ type, id: 'LIST' }) as const;
const itemTag = (type: (typeof TAGS)[number], id: string) => ({ type, id }) as const;
/** What `POST /license-types` accepts. Mirrors the server's create DTO. */
export interface CreateLicenseTypeInput {
key: string;
name: { en: string; am: string };
description?: { en: string; am: string };
category?: LicenseCategory;
familyKind?: FamilyKind;
serviceKind?: ServiceKind;
workflowProfile?: WorkflowProfile;
certificatePrefix: string;
feeNewApplication?: number;
feeRenewal?: number;
feeCurrency?: string;
capitalThreshold?: number;
validityMonths?: number;
inspectionRequired?: boolean;
issuesCertificate?: boolean;
renewalEnabled?: boolean;
sortOrder?: number;
isActive?: boolean;
}
/**
* Typed licensing endpoints, shared by the portal and the backoffice.
*
@@ -256,7 +280,6 @@ export const licensingApi = baseApi
id: string;
workflowProfile?: WorkflowProfile;
serviceKind?: ServiceKind;
/** Licence / certificate / document — see `FamilyKind`. */
familyKind?: FamilyKind;
completionEffect?: CompletionEffect | null;
certificateCategory?: CertificateCategory | null;
@@ -288,6 +311,36 @@ export const licensingApi = baseApi
error ? [] : [listTag('LicenseType'), itemTag('LicenseType', id)],
}),
/**
* Creates a licence type. The bare minimum a type needs to exist and
* be classified; its form, documents, fees and behaviour are configured
* afterwards on their own screens. The server upper-cases and trims the
* key, refuses a taken one with 409 `license_type_key_taken`, and lints
* a form schema if one is supplied.
*/
createLicenseType: builder.mutation<LicenseType, CreateLicenseTypeInput>({
query: (body) => ({ url: '/license-types', method: 'POST', body }),
invalidatesTags: (_r, error) => (error ? [] : [listTag('LicenseType')]),
}),
/**
* Opens or closes a type to new applications. Applications already in
* flight hold the type by id and keep running; only the portal
* catalogue changes.
*/
updateLicenseStatus: builder.mutation<
LicenseType,
{ id: string; isActive: boolean }
>({
query: ({ id, isActive }) => ({
url: `/license-types/${id}/status`,
method: 'PATCH',
body: { isActive },
}),
invalidatesTags: (_r, error, { id }) =>
error ? [] : [itemTag('LicenseType', id), listTag('LicenseType')],
}),
/** Validity is edited beside the certificate design, not with the fees. */
updateLicenseValidity: builder.mutation<
LicenseType,
@@ -1419,6 +1472,7 @@ export const {
useUpdateRankMutation,
useDeleteRankMutation,
useUpdateLicenseValidityMutation,
useUpdateLicenseStatusMutation,
useGetLicenseTypeRequirementsQuery,
useCreateApplicationMutation,
useGetExamStateForApplicationQuery,