forked from rajun/ar-test
feat: add AR page layout switches to the project form
This commit is contained in:
parent
8f06ed3043
commit
f852782c6c
32
app/components/projects/form/ar-page-fields.tsx
Normal file
32
app/components/projects/form/ar-page-fields.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { useId } from 'react';
|
||||||
|
import { useFormContext, useWatch } from 'react-hook-form';
|
||||||
|
import { SwitchRow } from '~/components/ui/switch-row';
|
||||||
|
import { Text } from '~/components/ui/text';
|
||||||
|
import { AR_PAGE_TOGGLES } from '~/data/projects/constants';
|
||||||
|
import type { ProjectFormValues } from '~/schemas/projects/project-form';
|
||||||
|
|
||||||
|
// What the client's AR page shows around the model
|
||||||
|
export function ArPageFields() {
|
||||||
|
const headingId = useId();
|
||||||
|
const { control, setValue } = useFormContext<ProjectFormValues>();
|
||||||
|
const arPage = useWatch({ control, name: 'arPage' });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div role='group' aria-labelledby={headingId} className='flex flex-col gap-2'>
|
||||||
|
<Text as='span' id={headingId} variant='label'>
|
||||||
|
AR page
|
||||||
|
</Text>
|
||||||
|
{AR_PAGE_TOGGLES.map(({ key, label, hint }) => (
|
||||||
|
<SwitchRow
|
||||||
|
key={key}
|
||||||
|
framed
|
||||||
|
id={`ar-page-${key}`}
|
||||||
|
label={label}
|
||||||
|
hint={hint}
|
||||||
|
checked={arPage[key]}
|
||||||
|
onCheckedChange={(checked) => setValue(`arPage.${key}`, checked, { shouldDirty: true })}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user