diff --git a/src/components/Directory/NoteCardDirectory.jsx b/src/components/Directory/NoteCardDirectory.jsx index 6fe7b144..2b5c0868 100644 --- a/src/components/Directory/NoteCardDirectory.jsx +++ b/src/components/Directory/NoteCardDirectory.jsx @@ -7,11 +7,12 @@ import showToast from "../../services/toastService"; import { cacheData, getCachedData } from "../../slices/apiDataManager"; import "../common/TextEditor/Editor.css"; -const NoteCardDirectory = ({ IsActive,noteItem, contactId, setProfileContact }) => { +const NoteCardDirectory = ({refetchProfile,refetchNotes, noteItem, contactId, setProfileContact, }) => { const [editing, setEditing] = useState(false); const [editorValue, setEditorValue] = useState(noteItem.note); const [isLoading, setIsLoading] = useState(false); - const [isDeleting, setIsDeleting] = useState(false); + const [ isDeleting, setIsDeleting ] = useState( false ); + const [isActivProcess,setActiveProcessing]= useState(false) const handleUpdateNote = async () => { try { setIsLoading(true); @@ -63,10 +64,10 @@ const NoteCardDirectory = ({ IsActive,noteItem, contactId, setProfileContact }) } }; - const handleDeleteNote = async () => { + const handleDeleteNote = async (activeStatue) => { try { - setIsDeleting(true); - const resp = await DirectoryRepository.DeleteNote(noteItem.id); + activeStatue ? setActiveProcessing(true) : setIsDeleting(true) + const resp = await DirectoryRepository.DeleteNote(noteItem.id,activeStatue); setProfileContact((prev) => ({ ...prev, notes: prev.notes.filter((note) => note.id !== noteItem.id), @@ -90,8 +91,11 @@ const NoteCardDirectory = ({ IsActive,noteItem, contactId, setProfileContact }) cacheData("Contact Profile", updatedCache); } - setIsDeleting(false); - showToast("Note Deleted Successfully", "success"); + setIsDeleting( false ); + setActiveProcessing( false ) + refetchNotes( contactId, false ) + refetchProfile(contactId) + showToast(`Note ${activeStatue ? "Restored":"Deleted"} Successfully`, "success"); } catch (error) { setIsDeleting(false); const msg = @@ -101,13 +105,13 @@ const NoteCardDirectory = ({ IsActive,noteItem, contactId, setProfileContact }) showToast(msg, "error"); } }; - return (