Skip to content

Commit

Permalink
revamped: note modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar-4781 committed Jun 24, 2024
1 parent 4081de5 commit ed963d6
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/pages/ShowFeelingsPage/components/NoteModal.tsx
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;

0 comments on commit ed963d6

Please sign in to comment.