forked from rajun/ar-test
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
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>
|
|
);
|
|
}
|