diff --git a/package.json b/package.json index 1117833..403a7fd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "donetick", "private": true, - "version": "0.1.90", + "version": "0.1.91", "type": "module", "lint-staged": { "*.{js,jsx,ts,tsx}": [ diff --git a/src/utils/Debounce.jsx b/src/utils/Debounce.jsx new file mode 100644 index 0000000..3ef84ab --- /dev/null +++ b/src/utils/Debounce.jsx @@ -0,0 +1,19 @@ +import { useEffect, useState } from 'react' + +function useDebounce(value, delay) { + const [debouncedValue, setDebouncedValue] = useState(value) + + useEffect(() => { + const handler = setTimeout(() => { + setDebouncedValue(value) + }, delay) + + return () => { + clearTimeout(handler) + } + }, [value, delay]) + + return debouncedValue +} + +export default useDebounce diff --git a/src/views/ChoreEdit/ChoreEdit.jsx b/src/views/ChoreEdit/ChoreEdit.jsx index e3eec30..62c39fe 100644 --- a/src/views/ChoreEdit/ChoreEdit.jsx +++ b/src/views/ChoreEdit/ChoreEdit.jsx @@ -22,6 +22,7 @@ import { Snackbar, Stack, Switch, + Textarea, Typography, } from '@mui/joy' import moment from 'moment' @@ -61,6 +62,7 @@ const ChoreEdit = () => { const [userHistory, setUserHistory] = useState({}) const { choreId } = useParams() const [name, setName] = useState('') + const [description, setDescription] = useState('') const [confirmModelConfig, setConfirmModelConfig] = useState({}) const [assignees, setAssignees] = useState([]) const [performers, setPerformers] = useState([]) @@ -186,6 +188,7 @@ const ChoreEdit = () => { const chore = { id: Number(choreId), name: name, + description: description, assignees: assignees, dueDate: dueDate ? new Date(dueDate).toISOString() : null, frequencyType: frequencyType, @@ -241,6 +244,7 @@ const ChoreEdit = () => { .then(data => { setChore(data.res) setName(data.res.name ? data.res.name : '') + setDescription(data.res.description ? data.res.description : '') setAssignees(data.res.assignees ? data.res.assignees : []) setAssignedTo(data.res.assignedTo) setFrequencyType( @@ -379,11 +383,22 @@ const ChoreEdit = () => { Title : - What is this chore about? + What is the name of this chore? setName(e.target.value)} /> {errors.name} + + + Details: + What is this chore about? +