import {useFormContext} from 'react-hook-form'; import {FormSelect, Option} from '@common/ui/forms/select/select'; import {Trans} from '@common/i18n/trans'; import {UpdateChannelPayload} from '@common/admin/channels/requests/use-update-channel'; import {ReactNode} from 'react'; import {ChannelContentConfig} from '@common/admin/channels/channel-editor/channel-content-config'; interface Props { config: ChannelContentConfig; } export function ContentLayoutFields({config}: Props) { return (
} /> } />
); } interface LayoutFieldProps extends Props { name: string; label: ReactNode; } function LayoutField({config, name, label}: LayoutFieldProps) { const {watch} = useFormContext(); const contentModel = watch('config.contentModel'); const modelConfig = config.models[contentModel]; if (!modelConfig.layoutMethods?.length) { return null; } return ( {modelConfig.layoutMethods.map(method => { const label = config.layoutMethods[method].label; return ( ); })} ); }