From 467bba2e0af3f60c37a82d9015966341dfa3e547 Mon Sep 17 00:00:00 2001 From: Nora Kauczor Date: Thu, 21 Nov 2024 09:29:10 +0100 Subject: [PATCH] write closeForm function in App.tsx and pass it to form --- frontend/index.html | 2 +- frontend/src/App.tsx | 12 ++- .../components/CalendarDay/CalendarDay.tsx | 80 +++++++++---------- frontend/src/components/Form/Form.tsx | 16 ++-- 4 files changed, 60 insertions(+), 50 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index d45952cb..29861028 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -8,6 +8,6 @@
- + diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 0440b908..ce3a76cc 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -268,6 +268,11 @@ function App() { } } + function closeForm(){ + setVocabToEdit(undefined) + setUseForm(false) + } + function getInactiveVocabs() { return vocabs.filter(vocab => { if (!vocab.datesPerUser) { @@ -294,12 +299,15 @@ function App() { language={language} setLanguage={setLanguage}/> {useForm &&
} - {useForm &&
} + closeForm={closeForm} + />} {userId && } void } export default function CalendarDay(props: Readonly) { + const displayDate: string = props.vocabIdsOfDate?.date?.substring(8, 10) + "." + props.vocabIdsOfDate?.date?.substring(5, 7) + "." + const numberOfVocabs = props.vocabIdsOfDate?.vocabIds ? + props.vocabIdsOfDate?.vocabIds?.length : 0; - return (
- {props.vocabIdsOfDate && } -
) + return (
+ {props.vocabIdsOfDate && } +
) } diff --git a/frontend/src/components/Form/Form.tsx b/frontend/src/components/Form/Form.tsx index 0509c507..49d99296 100644 --- a/frontend/src/components/Form/Form.tsx +++ b/frontend/src/components/Form/Form.tsx @@ -10,7 +10,7 @@ type Props = { editVocab: (vocab: Vocab) => void editAndActivateVocab: (vocab: Vocab) => void userId: string - setUseForm: React.Dispatch> + closeForm: () => void } export default function Form(props: Readonly) { @@ -66,11 +66,15 @@ export default function Form(props: Readonly) { setInfoInput(value) } + const vocabIsAlreadyActive: undefined | boolean = props.vocabToEdit && + props.vocabToEdit?.datesPerUser?.[props.userId] && + props.vocabToEdit?.datesPerUser[props.userId].length > 0 + return (
@@ -102,10 +106,10 @@ export default function Form(props: Readonly) { - + }
) } \ No newline at end of file