From 9c99b4ab15e73ad50764705cf05341c6f1702731 Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:05:55 +0200 Subject: [PATCH] feat: Other license categories --- apps/api/prisma/schema.prisma | 1 + apps/client/locales/en/citizen.json | 6 ++--- .../licenses/ManageLicensesFormFields.tsx | 25 +++++++++++++++++++ .../citizen/licenses/licenses-card.tsx | 2 +- .../licenses/manage-licenses-modal.tsx | 1 + packages/types/src/enums.ts | 1 + 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index fafeac910..1fefcb4f1 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -1822,6 +1822,7 @@ enum DriversLicenseCategoryType { FIREARM HUNTING FISHING + OTHER } enum EmployeeAsEnum { diff --git a/apps/client/locales/en/citizen.json b/apps/client/locales/en/citizen.json index 8d1614470..6de7df233 100644 --- a/apps/client/locales/en/citizen.json +++ b/apps/client/locales/en/citizen.json @@ -67,7 +67,8 @@ "fishingLicenseCategory": "Fishing License Categories", "huntingLicenseCategory": "Hunting License Categories", "huntingLicensePoints": "Hunting License Points", - "fishingLicensePoints": "Fishing License Points" + "fishingLicensePoints": "Fishing License Points", + "otherLicenseCategory": "Other License Categories" }, "Vehicles": { "model": "Model", @@ -156,7 +157,7 @@ "LawBook": { "lawBook": "Law Book", "warningApplicable": "Warning Applicable", - "noPenalCodes": "No penal code has been registered", + "noPenalCodes": "No penal code has been registered", "warningNotApplicable": "Warning Not Applicable", "fines": "Fines", "bail": "Bail", @@ -164,4 +165,3 @@ "isPrimary": "Is Primary" } } - \ No newline at end of file diff --git a/apps/client/src/components/citizen/licenses/ManageLicensesFormFields.tsx b/apps/client/src/components/citizen/licenses/ManageLicensesFormFields.tsx index e59767cfd..80d1a5c46 100644 --- a/apps/client/src/components/citizen/licenses/ManageLicensesFormFields.tsx +++ b/apps/client/src/components/citizen/licenses/ManageLicensesFormFields.tsx @@ -54,6 +54,10 @@ export function createDefaultLicensesValues(citizen: Citizen | null): LicenseIni citizen?.dlCategory .filter((v) => v.type === DriversLicenseCategoryType.HUNTING) .map((v) => v.id) ?? [], + otherLicenseCategory: + citizen?.dlCategory + .filter((v) => v.type === DriversLicenseCategoryType.OTHER) + .map((v) => v.id) ?? [], }; } @@ -483,6 +487,27 @@ export function ManageLicensesFormFields({ isLeo, allowRemoval }: Props) { ) : null} )} + +
+ + setFieldValue("otherLicenseCategory", keys)} + options={driverslicenseCategory.values + .filter((v) => v.type === DriversLicenseCategoryType.OTHER) + .map((value) => ({ + label: value.value.value, + value: value.id, + description: value.description, + }))} + /> + +
); } diff --git a/apps/client/src/components/citizen/licenses/licenses-card.tsx b/apps/client/src/components/citizen/licenses/licenses-card.tsx index 069895e66..27c6d62d3 100644 --- a/apps/client/src/components/citizen/licenses/licenses-card.tsx +++ b/apps/client/src/components/citizen/licenses/licenses-card.tsx @@ -131,6 +131,7 @@ export function CitizenLicenses({ citizen }: Props) { DriversLicenseCategoryType.HUNTING, ["huntingLicense", "huntingLicenseTimeEnd", "huntingLicenseNumber"], ], + // todo: other license categories }; return ( @@ -160,7 +161,6 @@ export function CitizenLicenses({ citizen }: Props) { {t("Leo.suspended")} {typeof suspendedTimeEnd === "string" ? ( - {" "} ({t("Leo.endsOn")} {new Date(suspendedTimeEnd)}) ) : null} diff --git a/apps/client/src/components/citizen/licenses/manage-licenses-modal.tsx b/apps/client/src/components/citizen/licenses/manage-licenses-modal.tsx index 93a67b757..0bb326d13 100644 --- a/apps/client/src/components/citizen/licenses/manage-licenses-modal.tsx +++ b/apps/client/src/components/citizen/licenses/manage-licenses-modal.tsx @@ -32,6 +32,7 @@ export interface LicenseInitialValues { firearmLicenseCategory: string[]; huntingLicenseCategory: string[]; fishingLicenseCategory: string[]; + otherLicenseCategory: string[]; } export function ManageLicensesModal({ diff --git a/packages/types/src/enums.ts b/packages/types/src/enums.ts index 98b867c4d..5e668d2bf 100644 --- a/packages/types/src/enums.ts +++ b/packages/types/src/enums.ts @@ -179,6 +179,7 @@ export const DriversLicenseCategoryType = { FIREARM: "FIREARM", HUNTING: "HUNTING", FISHING: "FISHING", + OTHER: "OTHER", } as const; export type DriversLicenseCategoryType =