From 6c9b80cd65b1f8c9b3e73aa370f469bcfcf79b73 Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:49 +0530 Subject: [PATCH] feat: add branded QR toggle to the asset form --- .../assets/form/branded-qr-field.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/components/assets/form/branded-qr-field.tsx diff --git a/app/components/assets/form/branded-qr-field.tsx b/app/components/assets/form/branded-qr-field.tsx new file mode 100644 index 0000000..1476c87 --- /dev/null +++ b/app/components/assets/form/branded-qr-field.tsx @@ -0,0 +1,25 @@ +import { useFormContext, useWatch } from 'react-hook-form'; +import { SwitchRow } from '~/components/ui/switch-row'; +import { useAdminData } from '~/hooks/admin/use-admin-data'; +import type { AssetFormValues } from '~/schemas/assets/asset-form'; + +// Only offered when the chosen project has a logo to put on the QR code +export function BrandedQrField() { + const { projects } = useAdminData(); + const { control, setValue } = useFormContext(); + const [projectId, brandedQr] = useWatch({ control, name: ['project', 'brandedQr'] }); + const project = projects.find((item) => item.id === projectId); + + if (!project?.logo) return null; + + return ( + setValue('brandedQr', checked, { shouldDirty: true })} + /> + ); +}