diff --git a/src/components/Directory/NoteCardDirectoryEditable.jsx b/src/components/Directory/NoteCardDirectoryEditable.jsx index 4f5bf410..6a6f9be7 100644 --- a/src/components/Directory/NoteCardDirectoryEditable.jsx +++ b/src/components/Directory/NoteCardDirectoryEditable.jsx @@ -5,6 +5,7 @@ import Avatar from "../common/Avatar"; import { DirectoryRepository } from "../../repositories/DirectoryRepository"; import showToast from "../../services/toastService"; import { cacheData, getCachedData } from "../../slices/apiDataManager"; +import ConfirmModal from "../common/ConfirmModal"; // Make sure path is correct import "../common/TextEditor/Editor.css"; const NoteCardDirectoryEditable = ({ @@ -18,6 +19,7 @@ const NoteCardDirectoryEditable = ({ const [isLoading, setIsLoading] = useState(false); const [isDeleting, setIsDeleting] = useState(false); const [isRestoring, setIsRestoring] = useState(false); + const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const handleUpdateNote = async () => { try { @@ -29,7 +31,6 @@ const NoteCardDirectoryEditable = ({ }; const response = await DirectoryRepository.UpdateNote(noteItem.id, payload); - // Optional cache update const cachedContactProfile = getCachedData("Contact Profile"); if (cachedContactProfile?.contactId === contactId) { const updatedCache = { @@ -43,8 +44,7 @@ const NoteCardDirectoryEditable = ({ }; cacheData("Contact Profile", updatedCache); } - - // Notify parent + onNoteUpdate?.(response.data); setEditing(false); showToast("Note updated successfully", "success"); @@ -55,111 +55,156 @@ const NoteCardDirectoryEditable = ({ } }; - const handleDeleteOrRestore = async (shouldRestore) => { + const suspendEmployee = async () => { try { - shouldRestore ? setIsRestoring(true) : setIsDeleting(true); - await DirectoryRepository.DeleteNote(noteItem.id, shouldRestore); + setIsDeleting(true); + await DirectoryRepository.DeleteNote(noteItem.id, false); onNoteDelete?.(noteItem.id); - showToast(`Note ${shouldRestore ? "restored" : "deleted"} successfully`, "success"); + setIsDeleteModalOpen(false); + showToast("Note deleted successfully", "success"); } catch (error) { - showToast("Failed to process note", "error"); + showToast("Failed to delete note", "error"); } finally { setIsDeleting(false); + } + }; + + const handleRestore = async () => { + try { + setIsRestoring(true); + await DirectoryRepository.DeleteNote(noteItem.id, true); + onNoteDelete?.(noteItem.id); + showToast("Note restored successfully", "success"); + } catch (error) { + showToast("Failed to restore note", "error"); + } finally { setIsRestoring(false); } }; return ( -
Loading...
} */} - - {/* Notes View */} - {/* {!loading && viewType === "notes" && notes?.length > 0 && ( -No matching note found
- )} */} - - {/* Contact (card/list) View */} {!loading && (viewType === "card" || viewType === "list") && contacts?.length === 0 && (No contact found
)} @@ -376,7 +371,6 @@ const Directory = ({ IsPage = true, prefernceContacts }) => {Filter by
+Filter by
- {/* Buckets */} -Buckets
-Buckets
+Categories
-Categories
+