import {useFormContext} from 'react-hook-form'; import {FormSelect, Option} from '@common/ui/forms/select/select'; import {Trans} from '@common/i18n/trans'; import {InfoDialogTrigger} from '@common/ui/overlays/dialog/info-dialog-trigger/info-dialog-trigger'; import {Fragment, ReactNode} from 'react'; import {LearnMoreLink} from '@common/admin/settings/learn-more-link'; import {UpdateChannelPayload} from '@common/admin/channels/requests/use-update-channel'; import {ChannelContentConfig} from '@common/admin/channels/channel-editor/channel-content-config'; import {FormTextField} from '@common/ui/forms/input-field/text-field/text-field'; interface Props { children?: ReactNode; config: ChannelContentConfig; } export function ContentAutoUpdateField({children, config}: Props) { const {watch, setValue} = useFormContext(); const modelConfig = config.models[watch('config.contentModel')]; const selectedMethodConfig = config.autoUpdateMethods[watch('config.autoUpdateMethod')!]; if ( watch('config.contentType') !== 'autoUpdate' || !modelConfig.autoUpdateMethods?.length ) { return null; } return (
{ if (config.autoUpdateMethods[value].provider) { setValue( 'config.autoUpdateProvider', config.autoUpdateMethods[value].provider, ); } }} label={
} /> } > {modelConfig.autoUpdateMethods.map(method => ( ))}
{selectedMethodConfig?.value ? ( } type={selectedMethodConfig?.value.inputType} /> ) : null} {children}
); }