import type { FC } from 'react'; import React, { useCallback, useEffect } from 'react'; import { useTranslation } from 'next-i18next'; import { useForm } from 'react-hook-form'; import { Card, CardBody } from 'reactstrap'; import { apiv3Put } from '~/client/util/apiv3-client'; import { toastError, toastSuccess } from '~/client/util/toastr'; import { useCustomTitleTemplate } from '~/states/global'; import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow'; export const CustomizeTitle: FC = () => { const { t } = useTranslation('admin'); const customTitleTemplate = useCustomTitleTemplate(); const { register, handleSubmit, reset } = useForm(); // Sync form with store data useEffect(() => { reset({ customizeTitle: customTitleTemplate ?? '', }); }, [customTitleTemplate, reset]); const onSubmit = useCallback( async (data) => { try { await apiv3Put('/customize-setting/customize-title', { customizeTitle: data.customizeTitle, }); toastSuccess( t('toaster.update_successed', { target: t('admin:customize_settings.custom_title'), ns: 'commons', }), ); } catch (err) { toastError(err); } }, [t], ); return (

{t('admin:customize_settings.custom_title')}

{/* eslint-disable react/no-danger */}

{/* eslint-enable react/no-danger */}
{/* TODO i18n */}
Default Value:{' '} {{pagename}} - {{sitename}}
Default Output Example:{' '} <title>Page name - My GROWI</title>
); };