Skip to content

Commit

Permalink
fix: unable to add hunting/fishing license categories (closes #1816)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Oct 3, 2023
1 parent 83631d4 commit 4821f05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type LicenseSchema = Pick<
| "pilotLicenseCategory"
| "waterLicenseCategory"
| "firearmLicenseCategory"
| "huntingLicenseCategory"
| "fishingLicenseCategory"
>;

export async function updateCitizenLicenseCategories(
Expand All @@ -34,6 +36,14 @@ export async function updateCitizenLicenseCategories(
data.firearmLicenseCategory ?? [],
suspendedLicenses?.firearmsLicense,
),
...returnNonSuspendedCategory(
data.huntingLicenseCategory ?? [],
suspendedLicenses?.huntingLicense,
),
...returnNonSuspendedCategory(
data.fishingLicenseCategory ?? [],
suspendedLicenses?.fishingLicense,
),
];
const disconnectConnectArr = manyToManyHelper(
citizen.dlCategory?.map((v) => v.id) ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export function ManageLicensesFormFields({ isLeo, allowRemoval }: Props) {
isClearable={allowRemoval}
onSelectionChange={(keys) => setFieldValue("fishingLicenseCategory", keys)}
options={driverslicenseCategory.values
.filter((v) => v.type === DriversLicenseCategoryType.WATER)
.filter((v) => v.type === DriversLicenseCategoryType.FISHING)
.map((value) => ({
label: value.value.value,
value: value.id,
Expand Down Expand Up @@ -398,7 +398,7 @@ export function ManageLicensesFormFields({ isLeo, allowRemoval }: Props) {
isClearable={allowRemoval}
onSelectionChange={(keys) => setFieldValue("huntingLicenseCategory", keys)}
options={driverslicenseCategory.values
.filter((v) => v.type === DriversLicenseCategoryType.WATER)
.filter((v) => v.type === DriversLicenseCategoryType.HUNTING)
.map((value) => ({
label: value.value.value,
value: value.id,
Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/src/admin/values/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const BUSINESS_ROLE_ARR = z.array(BUSINESS_ROLE_SCHEMA).min(1);
/**
* driverslicense_category
*/
const DLC_TYPE_REGEX = /AUTOMOTIVE|AVIATION|WATER|FIREARM/;
const DLC_TYPE_REGEX = /AUTOMOTIVE|AVIATION|WATER|FIREARM|HUNTING|FISHING/;

export const DLC_SCHEMA = BASE_VALUE_SCHEMA.extend({
type: z.string().regex(DLC_TYPE_REGEX).max(255),
Expand Down

0 comments on commit 4821f05

Please sign in to comment.