import React from "react"; import { Note } from "../../api/notes"; import { useCreateNote, useDeleteNote } from "../../hooks/useFolders"; import { useUIStore } from "../../stores/uiStore"; interface NoteContextMenuProps { x: number; y: number; note: Note; onClose: () => void; } export const NoteContextMenu: React.FC = ({ x, y, note, onClose, }) => { const { setSelectedNote } = useUIStore(); const deleteNoteMutation = useDeleteNote(); const createNoteMutation = useCreateNote(); const handleDelete = async () => { try { await deleteNoteMutation.mutateAsync(note.id); // Clear selection if this note was selected setSelectedNote(null); onClose(); } catch (error) { console.error("Failed to delete note:", error); } }; const handleDuplicate = async () => { try { await createNoteMutation.mutateAsync({ title: `${note.title} (Copy)`, content: note.content, folder_id: note.folder_id || null, }); onClose(); } catch (error) { console.error("Failed to duplicate note:", error); } }; const handleRename = () => { setSelectedNote(note); onClose(); // Focus will be handled by the editor }; return (
e.stopPropagation()} >
); };