From 26c6ac7163f8e08e795c1f521fb565afda627af4 Mon Sep 17 00:00:00 2001 From: casperiv0 <53900565+casperiv0@users.noreply.github.com> Date: Fri, 29 Sep 2023 20:39:25 +0200 Subject: [PATCH] feat: able to configure licenses --- .../admin/manage/cad-settings/CadSettings.ts | 6 ++++++ .../api/src/lib/citizen/citizen-create-data-obj.ts | 10 ++++++++++ apps/client/locales/en/cad-settings.json | 4 ++++ packages/schemas/src/admin/index.ts | 14 ++++++++++---- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/apps/api/src/controllers/admin/manage/cad-settings/CadSettings.ts b/apps/api/src/controllers/admin/manage/cad-settings/CadSettings.ts index 5d029fa5a..20cdbb3de 100644 --- a/apps/api/src/controllers/admin/manage/cad-settings/CadSettings.ts +++ b/apps/api/src/controllers/admin/manage/cad-settings/CadSettings.ts @@ -276,6 +276,12 @@ export class CADSettingsController { waterLicenseNumberLength: data.waterLicenseNumberLength, signal100RepeatAmount: data.signal100RepeatAmount, signal100RepeatIntervalMs: data.signal100RepeatIntervalMs, + huntingLicenseTemplate: data.huntingLicenseTemplate, + huntingLicenseMaxPoints: data.huntingLicenseMaxPoints, + huntingLicenseNumberLength: data.huntingLicenseNumberLength, + fishingLicenseTemplate: data.fishingLicenseTemplate, + fishingLicenseMaxPoints: data.fishingLicenseMaxPoints, + fishingLicenseNumberLength: data.fishingLicenseNumberLength, }, include: { webhooks: true }, }); diff --git a/apps/api/src/lib/citizen/citizen-create-data-obj.ts b/apps/api/src/lib/citizen/citizen-create-data-obj.ts index b762501d4..d78f55f60 100644 --- a/apps/api/src/lib/citizen/citizen-create-data-obj.ts +++ b/apps/api/src/lib/citizen/citizen-create-data-obj.ts @@ -63,6 +63,16 @@ export async function citizenObjectFromData(options: Options) { template: miscCadSettings?.waterLicenseTemplate, length: miscCadSettings?.waterLicenseNumberLength ?? 8, }), + + huntingLicenseNumber: generateLicenseNumber({ + template: miscCadSettings?.huntingLicenseTemplate, + length: miscCadSettings?.huntingLicenseNumberLength ?? 8, + }), + + fishingLicenseNumber: generateLicenseNumber({ + template: miscCadSettings?.fishingLicenseTemplate, + length: miscCadSettings?.fishingLicenseNumberLength ?? 8, + }), }; if (typeof options.defaultLicenseValueId !== "undefined") { diff --git a/apps/client/locales/en/cad-settings.json b/apps/client/locales/en/cad-settings.json index 760fb64ae..76d7935f6 100644 --- a/apps/client/locales/en/cad-settings.json +++ b/apps/client/locales/en/cad-settings.json @@ -133,6 +133,10 @@ "weaponLicenseTemplateInfo": "This is the template for weapon license numbers. You can use the following variables: {variables}. Note: this will only apply to newly created citizens.", "waterLicenseTemplate": "Water license number template", "waterLicenseTemplateInfo": "This is the template for water license numbers. You can use the following variables: {variables}. Note: this will only apply to newly created citizens.", + "huntingLicenseTemplate": "Hunting license number template", + "huntingLicenseTemplateInfo": "This is the template for hunting license numbers. You can use the following variables: {variables}. Note: this will only apply to newly created citizens.", + "fishingLicenseTemplate": "Fishing license number template", + "fishingLicenseTemplateInfo": "This is the template for fishing license numbers. You can use the following variables: {variables}. Note: this will only apply to newly created citizens.", "miscSettings": "Miscellaneous Settings", "cadRelated": "CAD Related", "inactivityTimeouts": "Inactivity Timeouts", diff --git a/packages/schemas/src/admin/index.ts b/packages/schemas/src/admin/index.ts index 8126d0f44..ba9b57c1a 100644 --- a/packages/schemas/src/admin/index.ts +++ b/packages/schemas/src/admin/index.ts @@ -59,14 +59,20 @@ export const CAD_MISC_SETTINGS_SCHEMA = z.object({ driversLicenseNumberLength: z.number().finite().nullable(), pilotLicenseTemplate: z.string().nullable(), pilotLicenseNumberLength: z.number().finite().nullable(), - weaponLicenseTemplate: z.string().nullable(), - weaponLicenseNumberLength: z.number().finite().nullable(), + pilotLicenseMaxPoints: z.number().finite().nullable(), + fishingLicenseTemplate: z.string().nullable(), + fishingLicenseNumberLength: z.number().finite().nullable(), + fishingLicenseMaxPoints: z.number().finite().nullable(), waterLicenseTemplate: z.string().nullable(), + waterLicenseMaxPoints: z.number().finite().nullable(), waterLicenseNumberLength: z.number().finite().nullable(), + huntingLicenseTemplate: z.string().nullable(), + huntingLicenseNumberLength: z.number().finite().nullable(), + huntingLicenseMaxPoints: z.number().finite().nullable(), driversLicenseMaxPoints: z.number().finite().nullable(), - pilotLicenseMaxPoints: z.number().finite().nullable(), weaponLicenseMaxPoints: z.number().finite().nullable(), - waterLicenseMaxPoints: z.number().finite().nullable(), + weaponLicenseTemplate: z.string().nullable(), + weaponLicenseNumberLength: z.number().finite().nullable(), signal100RepeatAmount: z.number().finite().nullable(), signal100RepeatIntervalMs: z.number().finite().nullable(), });