import React from 'react'; import Exit from '../assets/exit.svg'; import Input from '../components/Input'; import { ActiveState } from '../models/misc'; import ConfirmationModal from './ConfirmationModal'; 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 [title, setTitle] = React.useState(''); const [chunkText, setChunkText] = React.useState(''); const [deleteModal, setDeleteModal] = React.useState('INACTIVE'); React.useEffect(() => { setTitle(originalTitle || ''); setChunkText(originalText || ''); }, [originalTitle, originalText]); if (type === 'ADD') { return (

Add Chunk

Title setTitle(e.target.value)} borderVariant="thin" placeholder={'Enter title'} >
Body text
); } else { return (

Edit Chunk

Title setTitle(e.target.value)} borderVariant="thin" placeholder={'Enter title'} >
Body text
{ /* no-op */ } } submitLabel="Delete" />
); } }