diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index d5aa7d85..d2591d46 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -239,6 +239,18 @@ "promptText": "Prompt Text", "save": "Save", "nameExists": "Name already exists" + }, + "chunk": { + "add": "Add Chunk", + "edit": "Edit Chunk", + "title": "Title", + "enterTitle": "Enter title", + "bodyText": "Body text", + "promptText": "Prompt Text", + "update": "Update", + "close": "Close", + "delete": "Delete", + "deleteConfirmation": "Are you sure you want to delete this chunk?" } }, "sharedConv": { diff --git a/frontend/src/modals/ChunkModal.tsx b/frontend/src/modals/ChunkModal.tsx index ab51fdee..4e229980 100644 --- a/frontend/src/modals/ChunkModal.tsx +++ b/frontend/src/modals/ChunkModal.tsx @@ -1,9 +1,10 @@ import React from 'react'; +import { useTranslation } from 'react-i18next'; -import Exit from '../assets/exit.svg'; import Input from '../components/Input'; import { ActiveState } from '../models/misc'; import ConfirmationModal from './ConfirmationModal'; +import WrapperModal from './WrapperModal'; export default function ChunkModal({ type, @@ -22,6 +23,7 @@ export default function ChunkModal({ originalText?: string; handleDelete?: () => void; }) { + const { t } = useTranslation(); const [title, setTitle] = React.useState(''); const [chunkText, setChunkText] = React.useState(''); const [deleteModal, setDeleteModal] = React.useState('INACTIVE'); @@ -30,157 +32,105 @@ export default function ChunkModal({ setTitle(originalTitle || ''); setChunkText(originalText || ''); }, [originalTitle, originalText]); - if (type === 'ADD') { - return ( -
-
-
- -
-

- Add Chunk -

-
- - Title - - setTitle(e.target.value)} - borderVariant="thin" - placeholder={'Enter title'} - labelBgClassName="bg-white dark:bg-charleston-green-2" - > -
-
-
- - Body text - - -
-
-
- - -
-
-
-
+ + 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" + />
- ); - } else { - return ( -
-
-
+
+
+ + {t('modals.chunk.bodyText')} + + +
+
+ + {type === 'ADD' ? ( +
+ + +
+ ) : ( +
+ +
+ -
-

- Edit Chunk -

-
- setTitle(e.target.value)} - borderVariant="thin" - placeholder={'Enter title'} - labelBgClassName="bg-white dark:bg-charleston-green-2" - > -
-
-
- - Body text - - -
-
-
- -
- - -
-
-
-
+
+ )} +
+ ); + + return ( + <> + setModalState('INACTIVE')} + className="sm:w-[620px]" + > + {content} + + + {type === 'EDIT' && ( -
- ); - } + )} + + ); }