import { useState, useEffect } from "react"; import Card from "../reusableCard/index"; import { addNote, showNotes, hideNotes } from "../../assets/SvgIcons/SvgIcons"; const StickyNote = () => { const [notes, setNotes] = useState([]); const [showNote, setShowNote] = useState(true); useEffect(() => { const savedNotes = JSON?.parse(localStorage?.getItem("stickyNotes")) || []; setNotes(savedNotes); }, []); const handleShowNote = () => { setShowNote(!showNote); }; const handleAddNote = () => { setNotes([...notes, { id: Date.now(), content: "" }]); //Reference }; const handleDeleteNote = (id) => { setNotes(notes?.filter((note) => note?.id !== id)); }; const handleSaveNote = (id, content) => { let notesData = notes?.map((note) => note?.id === id ? { ...note, content } : note ); setNotes(notesData); localStorage?.setItem("stickyNotes", JSON.stringify(notes)); }; return ( <>
Sticky Notes Application