import { Flex, Textarea } from '@metafam/ds'; import { composeDBProfileFieldDescription } from '@metafam/utils'; import React, { useEffect } from 'react'; import { FormProvider, useForm, useFormContext } from 'react-hook-form'; import { useGetOwnProfileFieldFromComposeDB } from '#lib/hooks/ceramic/useGetOwnProfileFromComposeDB'; import { usePlayerSetupSaveToComposeDB } from '#lib/hooks/ceramic/usePlayerSetupSaveToComposeDB'; import { useShowToastOnQueryError } from './SetupProfile'; import { WizardPane } from './WizardPane'; const field = composeDBProfileFieldDescription; export const SetupDescription: React.FC = () => { const { fetching, error, result: existing, } = useGetOwnProfileFieldFromComposeDB(field); useShowToastOnQueryError(error); const formMethods = useForm<{ [field]: string | undefined }>({ mode: 'onTouched', }); const { watch, setValue, formState: { dirtyFields }, } = formMethods; useEffect(() => { setValue(field, existing); }, [existing, setValue]); const current = watch(field, existing); const dirty = current !== existing || !!dirtyFields[field]; const { onSubmit, status } = usePlayerSetupSaveToComposeDB({ isChanged: dirty, }); return ( ); }; const DescriptionField: React.FC = () => { const { register, formState: { errors }, } = useFormContext(); const { ...props } = register(field, { maxLength: { value: 420, message: 'Maximum length is 420 characters.', }, }); return (