From 4708ece2890b715a727d9ac8793f74d6e465e9a5 Mon Sep 17 00:00:00 2001 From: casperiv0 <53900565+casperiv0@users.noreply.github.com> Date: Sat, 28 Oct 2023 10:30:26 +0200 Subject: [PATCH] chore: improve select unit modals --- .../ems-fd/modals/deputy/select-deputy-modal.tsx | 8 +++----- .../src/components/leo/modals/select-officer-modal.tsx | 6 ++---- packages/schemas/src/ems-fd.ts | 2 +- packages/schemas/src/leo.ts | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/client/src/components/ems-fd/modals/deputy/select-deputy-modal.tsx b/apps/client/src/components/ems-fd/modals/deputy/select-deputy-modal.tsx index f64012afd..7f1e93e80 100644 --- a/apps/client/src/components/ems-fd/modals/deputy/select-deputy-modal.tsx +++ b/apps/client/src/components/ems-fd/modals/deputy/select-deputy-modal.tsx @@ -41,12 +41,10 @@ export function SelectDeputyModal() { if (!onDutyCode) return; const { json } = await execute({ - path: `/dispatch/status/${values.deputy?.id}`, + path: `/dispatch/status/${values.deputyId}`, method: "PUT", data: { - ...values, - deputyId: values.deputy?.id, - deputy: values.deputy?.id, + vehicleId: values.vehicleId, status: onDutyCode.id, userDefinedCallsign: canSetUserDefinedCallsign ? values.userDefinedCallsign : undefined, }, @@ -81,7 +79,7 @@ export function SelectDeputyModal() {
allowsCustomValue - errorMessage={errors.deputy} + errorMessage={errors.deputyId} label={t("Ems.deputy")} localValue={values.deputySearch} onInputChange={(value) => setFieldValue("deputySearch", value)} diff --git a/apps/client/src/components/leo/modals/select-officer-modal.tsx b/apps/client/src/components/leo/modals/select-officer-modal.tsx index 332a41c91..7df00e7a4 100644 --- a/apps/client/src/components/leo/modals/select-officer-modal.tsx +++ b/apps/client/src/components/leo/modals/select-officer-modal.tsx @@ -55,9 +55,8 @@ export function SelectOfficerModal() { ) { if (!onDutyCode) return; - const officerId = values.officer?.id; const { json } = await execute({ - path: `/dispatch/status/${officerId}`, + path: `/dispatch/status/${values.officerId}`, method: "PUT", data: { status: includeStatuses ? values.status : onDutyCode.id, @@ -105,8 +104,7 @@ export function SelectOfficerModal() { ) : null} - allowsCustomValue - errorMessage={errors.officer} + errorMessage={errors.officerId} label={t("officer")} localValue={values.officerSearch} onInputChange={(value) => setFieldValue("officerSearch", value)} diff --git a/packages/schemas/src/ems-fd.ts b/packages/schemas/src/ems-fd.ts index 926d51316..f3396973e 100644 --- a/packages/schemas/src/ems-fd.ts +++ b/packages/schemas/src/ems-fd.ts @@ -2,7 +2,7 @@ import { z } from "zod"; import { CREATE_OFFICER_SCHEMA } from "./leo"; export const SELECT_DEPUTY_SCHEMA = z.object({ - deputy: z.object({ id: z.string().min(2).max(255) }), + deputyId: z.string().min(2), vehicleId: z.string().nullish(), userDefinedCallsign: z.string().max(255).nullish(), }); diff --git a/packages/schemas/src/leo.ts b/packages/schemas/src/leo.ts index 4e25b22b5..1633c9085 100644 --- a/packages/schemas/src/leo.ts +++ b/packages/schemas/src/leo.ts @@ -69,7 +69,7 @@ export const UPDATE_OFFICER_STATUS_SCHEMA = z.object({ }); export const SELECT_OFFICER_SCHEMA = z.object({ - officer: z.object({ id: z.string().min(2).max(255) }), + officerId: z.string().min(2), userDefinedCallsign: z.string().nullish(), });