From ca044349cac7434560f2646bc4ea4c27f5783d47 Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Sat, 30 Sep 2023 18:29:36 +0700 Subject: cursed state management --- src/Entry.jsx | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/Entry.jsx') diff --git a/src/Entry.jsx b/src/Entry.jsx index e554050..c486680 100644 --- a/src/Entry.jsx +++ b/src/Entry.jsx @@ -4,7 +4,7 @@ import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs'; import 'dayjs/locale/id'; -function Entry({propDate, propStart, propFinish}) { +function Entry({propId, propDate, propStart, propFinish, handleEntryChange}) { const [date, setDate] = useState(propDate); const [start, setStart] = useState(propStart); const [finish, setFinish] = useState(propFinish); @@ -12,15 +12,31 @@ function Entry({propDate, propStart, propFinish}) { return (
- setDate(newDate)}/> - { - setStart(newStart) - }}/> - { - setFinish(newFinish); - console.log(newFinish) - }}/> + { + setDate(newDate); + handleEntryChange({id: propId, date: newDate}, 'date') + }} + /> + { + setStart(newStart); + handleEntryChange({id: propId, start: newStart}, 'start') + }} + /> + { + setFinish(newFinish); + handleEntryChange({id: propId, finish: newFinish}, 'finish') + }} + />
) -- cgit v1.2.3-70-g09d2