diff --git a/package-lock.json b/package-lock.json index 451ab6d..2c9c45c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "taskflow2", - "version": "0.1.1", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "taskflow2", - "version": "0.1.1", + "version": "0.1.2", "license": "MIT", "dependencies": { "@emotion/react": "^11.13.3", diff --git a/package.json b/package.json index 1e48b71..5a69346 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "taskflow2", - "version": "0.1.1", + "version": "0.1.2", "description": "a little task manager", "main": ".vite/build/main/index.js", "author": "@audrey-yang", diff --git a/src/renderer/components/EditComponents.tsx b/src/renderer/components/EditComponents.tsx index 79925cf..73b9c13 100644 --- a/src/renderer/components/EditComponents.tsx +++ b/src/renderer/components/EditComponents.tsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import Select, { SelectChangeEvent } from "@mui/material/Select"; import MenuItem from "@mui/material/MenuItem"; import TextField from "@mui/material/TextField"; @@ -50,18 +51,24 @@ export const titleEditor = ( ); export const notesEditor = ( - note: string, - setNote: (newNote: string) => void, + originalNote: string, + changeNote: (newNote: string) => Promise, disabled: boolean, -) => ( - setNote(event.target.value)} - className="w-10/12" - label={disabled ? "Note" : "Edit note"} - multiline - variant="filled" - disabled={disabled} - /> -); +) => { + const [note, setNote] = useState(originalNote); + return ( + setNote(event.target.value)} + onBlur={async () => { + await changeNote(note); + }} + className="w-10/12" + label={disabled ? "Note" : "Edit note"} + multiline + variant="filled" + disabled={disabled} + /> + ); +}; diff --git a/src/renderer/components/Task.tsx b/src/renderer/components/Task.tsx index 406c6f7..6d98538 100644 --- a/src/renderer/components/Task.tsx +++ b/src/renderer/components/Task.tsx @@ -37,9 +37,6 @@ const Task = ({ const [newTitle, setNewTitle] = useState(title); const [taskPriority, setTaskPriority] = useState(priority); const [taskStatus, setTaskStatus] = useState(status); - const [taskNote, setTaskNote] = useState(note); - const [isEditingNote, setIsEditingNote] = useState(false); - const [newNote, setNewNote] = useState(note); // Change handlers const changePriority = async (event: SelectChangeEvent) => { @@ -61,8 +58,6 @@ const Task = ({ }; const changeNote = async (note: string) => { await window.api.changeTaskNote(_id, note); - setTaskNote(note); - setIsEditingNote(false); }; const deleteTask = async () => { await window.api.deleteTask(_id); @@ -133,27 +128,7 @@ const Task = ({
- {notesEditor(newNote, setNewNote, !isEditingNote)} - {isEditingNote ? ( - - changeNote(newNote)}> - - - { - setNewNote(taskNote); - setIsEditingNote(false); - }} - > - - - - ) : ( - setIsEditingNote(true)}> - - - )} + {notesEditor(note, changeNote, taskStatus === STATUS.COMPLETED)}