forked from rajun/ar-test
feat: add branded QR toggle to the asset form
This commit is contained in:
parent
2babc57982
commit
6c9b80cd65
25
app/components/assets/form/branded-qr-field.tsx
Normal file
25
app/components/assets/form/branded-qr-field.tsx
Normal file
@ -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<AssetFormValues>();
|
||||
const [projectId, brandedQr] = useWatch({ control, name: ['project', 'brandedQr'] });
|
||||
const project = projects.find((item) => item.id === projectId);
|
||||
|
||||
if (!project?.logo) return null;
|
||||
|
||||
return (
|
||||
<SwitchRow
|
||||
framed
|
||||
id='asset-branded-qr'
|
||||
label='Client logo on QR code'
|
||||
hint={`Puts the ${project.name} logo in the centre of this asset’s QR code.`}
|
||||
checked={brandedQr}
|
||||
onCheckedChange={(checked) => setValue('brandedQr', checked, { shouldDirty: true })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user