From a411ed02a668f8b750a47d12acce89739362a5cd Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Wed, 29 Mar 2023 17:36:09 +0200 Subject: [PATCH] chore: minor fixes --- apps/api/src/lib/records/upsert-record.ts | 1 + .../leo/modals/manage-record/manage-record-modal.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/api/src/lib/records/upsert-record.ts b/apps/api/src/lib/records/upsert-record.ts index 3eeef20a6..ce70a6c55 100644 --- a/apps/api/src/lib/records/upsert-record.ts +++ b/apps/api/src/lib/records/upsert-record.ts @@ -35,6 +35,7 @@ export async function upsertRecord(options: UpsertRecordOptions) { let citizen; let business; + if ("citizenId" in options.data && options.data.citizenId) { citizen = await prisma.citizen.findUnique({ where: { id: options.data.citizenId }, diff --git a/apps/client/src/components/leo/modals/manage-record/manage-record-modal.tsx b/apps/client/src/components/leo/modals/manage-record/manage-record-modal.tsx index bdd3feb9f..f0c4ae162 100644 --- a/apps/client/src/components/leo/modals/manage-record/manage-record-modal.tsx +++ b/apps/client/src/components/leo/modals/manage-record/manage-record-modal.tsx @@ -76,7 +76,9 @@ interface Props { } export function ManageRecordModal(props: Props) { - const [isBusinessRecord, setIsBusinessRecord] = React.useState(!!props.record?.businessId); + const [isBusinessRecord, setIsBusinessRecord] = React.useState( + Boolean(props.record?.businessId && !props.record.citizenId), + ); const { isOpen, closeModal, openModal, getPayload } = useModal(); const common = useTranslations("Common"); const t = useTranslations("Leo"); @@ -84,8 +86,8 @@ export function ManageRecordModal(props: Props) { const { LEO_BAIL } = useFeatureEnabled(); React.useEffect(() => { - setIsBusinessRecord(!!props.record?.businessId); - }, [props.record?.businessId]); + setIsBusinessRecord(Boolean(props.record?.businessId && !props.record.citizenId)); + }, [props.record?.businessId, props.record?.citizenId]); const data = { [RecordType.TICKET]: {