fix: save edited note

This commit is contained in:
Artemy 2023-04-29 09:44:42 +03:00
parent 3f705bf8c4
commit 6d17fca352

View file

@ -53,16 +53,16 @@ function NotePage() {
edit ? ( edit ? (
<> <>
<NoteNameInput <NoteNameInput
value={note.name} value={name}
onChange={(e) => setName(e.target.value)} onChange={(e) => setName(e.target.value)}
/> />
<NoteTextArea <NoteTextArea
value={note.text} value={text}
onChange={(e) => setText(e.target.value)} onChange={(e) => setText(e.target.value)}
/> />
<div className="grid grid-cols-1 lg:grid-cols-2 justify-items-center w-full"> <div className="grid grid-cols-1 lg:grid-cols-2 justify-items-center w-full">
<NotesAdditionalSettings <NotesAdditionalSettings
noteText={note.text} noteText={text}
onClick={(text) => { onClick={(text) => {
setText(text); setText(text);
}} }}
@ -80,13 +80,15 @@ function NotePage() {
<div className="justify-self-center lg:justify-self-end"> <div className="justify-self-center lg:justify-self-end">
<ButtonWithIcon <ButtonWithIcon
className="mt-4" className="mt-4"
text={locals.Edit} text={edit ? locals.Save : locals.Edit}
icon={PencilIcon} icon={PencilIcon}
onClick={() => { onClick={() => {
if (edit) {
notes[params.id].name = name; notes[params.id].name = name;
notes[params.id].text = text; notes[params.id].text = text;
localStorage.setObj("Notes", notes); localStorage.setObj("Notes", notes);
}
setEdit(!edit); setEdit(!edit);
}} }}