import { useEffect } from 'react'; import { Controller, useForm } from 'react-hook-form'; import { Alert, AlertDescription, AlertIcon, Button, Input, Switch } from '@chakra-ui/react'; import { ViewSettings } from 'ontime-types'; import { maybeAxiosError } from '../../../../common/api/utils'; import { postViewSettings } from '../../../../common/api/viewSettings'; import ExternalLink from '../../../../common/components/external-link/ExternalLink'; import { PopoverPickerRHF } from '../../../../common/components/input/popover-picker/PopoverPicker'; import useInfo from '../../../../common/hooks-query/useInfo'; import useViewSettings from '../../../../common/hooks-query/useViewSettings'; import * as Panel from '../PanelUtils'; import style from './GeneralPanel.module.scss'; const cssOverrideDocsUrl = 'https://docs.getontime.no/features/custom-styling/'; export default function ViewSettingsForm() { const { data, status, refetch } = useViewSettings(); const { data: info, status: infoStatus } = useInfo(); const { control, handleSubmit, register, reset, setError, formState: { isSubmitting, isDirty }, } = useForm({ defaultValues: data, values: data, resetOptions: { keepDirtyValues: true, }, }); // update form if we get new data from server useEffect(() => { if (data) { reset(data); } }, [data, reset]); const onSubmit = async (formData: ViewSettings) => { const newData = { ...formData, }; try { await postViewSettings(newData); } catch (error) { const message = maybeAxiosError(error); setError('root', { message }); } finally { await refetch(); } }; const onReset = () => { reset(data); }; if (!control) { return null; } const isLoading = status === 'pending' || infoStatus === 'pending'; return ( View settings
You can override the styles of the viewers with a custom CSS file.
{info?.cssOverride && `In your installation the file is at ${info?.cssOverride}`}

See the docs
( )} /> ( )} />
); }