Skip to content

Commit

Permalink
chore: improve select unit modals
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Oct 28, 2023
1 parent 8166b46 commit 4708ece
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ export function SelectDeputyModal() {
if (!onDutyCode) return;

const { json } = await execute<PutDispatchStatusByUnitId, typeof INITIAL_VALUES>({
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,
},
Expand Down Expand Up @@ -81,7 +79,7 @@ export function SelectDeputyModal() {
<Form>
<AsyncListSearchField<GetMyDeputiesData["deputies"][number]>
allowsCustomValue
errorMessage={errors.deputy}
errorMessage={errors.deputyId}
label={t("Ems.deputy")}
localValue={values.deputySearch}
onInputChange={(value) => setFieldValue("deputySearch", value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ export function SelectOfficerModal() {
) {
if (!onDutyCode) return;

const officerId = values.officer?.id;
const { json } = await execute<PutDispatchStatusByUnitId, typeof INITIAL_VALUES>({
path: `/dispatch/status/${officerId}`,
path: `/dispatch/status/${values.officerId}`,
method: "PUT",
data: {
status: includeStatuses ? values.status : onDutyCode.id,
Expand Down Expand Up @@ -105,8 +104,7 @@ export function SelectOfficerModal() {
) : null}

<AsyncListSearchField<GetMyOfficersData["officers"][number]>
allowsCustomValue
errorMessage={errors.officer}
errorMessage={errors.officerId}
label={t("officer")}
localValue={values.officerSearch}
onInputChange={(value) => setFieldValue("officerSearch", value)}
Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/src/ems-fd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/src/leo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});

Expand Down

0 comments on commit 4708ece

Please sign in to comment.