import { useAlert } from '@gear-js/react-hooks'; import { Checkbox, FileInput, Textarea, InputWrapper, InputProps } from '@gear-js/ui'; import clsx from 'clsx'; import { useState, useEffect, useRef } from 'react'; import { useFormContext } from 'react-hook-form'; import { useChangeEffect } from '@/hooks'; import { checkFileFormat, readFileAsync } from '@/shared/helpers'; import { FileTypes } from '@/shared/config'; import { formStyles } from '@/shared/ui/form'; import { FormPayloadValues } from '../model/types'; import { PayloadStructure } from './payloadStructure'; import styles from './FormPayload.module.scss'; type Props = { name: string; label: string; direction?: InputProps['direction']; gap?: InputProps['gap']; values?: FormPayloadValues; }; // TODO: temp solution to unregister manual payload on unmount, // since on metadata change it's messing with default payload values function ManualPayloadTextarea({ name }: { name: string }) { const { register, unregister } = useFormContext(); // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(() => () => unregister(name), []); return