-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4081de5
commit ed963d6
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { useState } from "react"; | ||
|
||
import ZModal from "@src/common/ZModal"; | ||
|
||
const NoteModal = ({ | ||
open, | ||
defaultValue, | ||
saveNote, | ||
}: { | ||
open: boolean; | ||
defaultValue?: string; | ||
saveNote: (note?: string) => Promise<void>; | ||
}) => { | ||
const [value, setValue] = useState(defaultValue || ""); | ||
return ( | ||
<ZModal open={open}> | ||
<p style={{ fontWeight: 600, margin: 0 }}>Feeling Note</p> | ||
<form | ||
onSubmit={async () => { | ||
await saveNote(value); | ||
}} | ||
style={{ display: "flex", flexDirection: "column", gap: 12 }} | ||
> | ||
<textarea | ||
className="feeling-note-input simple" | ||
rows={5} | ||
cols={32} | ||
value={value} | ||
onChange={(e) => { | ||
setValue(e.target.value); | ||
}} | ||
/> | ||
<div className="note-modal-actions"> | ||
{defaultValue && ( | ||
<button | ||
type="button" | ||
className="simple bg-sec" | ||
onClick={async () => { | ||
await saveNote(); | ||
}} | ||
> | ||
Delete | ||
</button> | ||
)} | ||
<button type="submit" className="simple bg-primary"> | ||
Save | ||
</button> | ||
</div> | ||
</form> | ||
</ZModal> | ||
); | ||
}; | ||
|
||
export default NoteModal; |