import React from 'react'; import { useTranslation } from 'react-i18next'; import Input from '../components/Input'; import { ActiveState } from '../models/misc'; import ConfirmationModal from './ConfirmationModal'; import WrapperModal from './WrapperModal'; export default function ChunkModal({ type, modalState, setModalState, handleSubmit, originalTitle, originalText, handleDelete, }: { type: 'ADD' | 'EDIT'; modalState: ActiveState; setModalState: (state: ActiveState) => void; handleSubmit: (title: string, text: string) => void; originalTitle?: string; originalText?: string; handleDelete?: () => void; }) { const { t } = useTranslation(); const [title, setTitle] = React.useState(''); const [chunkText, setChunkText] = React.useState(''); const [deleteModal, setDeleteModal] = React.useState('INACTIVE'); React.useEffect(() => { setTitle(originalTitle || ''); setChunkText(originalText || ''); }, [originalTitle, originalText]); const resetForm = () => { setTitle(''); setChunkText(''); }; const handleDeleteConfirmed = () => { if (handleDelete) { handleDelete(); } setDeleteModal('INACTIVE'); setModalState('INACTIVE'); }; if (modalState !== 'ACTIVE') return null; const content = (

{t(`modals.chunk.${type === 'ADD' ? 'add' : 'edit'}`)}

setTitle(e.target.value)} borderVariant="thin" placeholder={t('modals.chunk.title')} labelBgClassName="bg-white dark:bg-charleston-green-2" />
{t('modals.chunk.bodyText')}
{type === 'ADD' ? (
) : (
)}
); return ( <> setModalState('INACTIVE')} className="sm:w-[620px]" isPerformingTask={true} > {content} {type === 'EDIT' && ( )} ); }