- Global quick capture modal (Cmd+Shift+C) with NL parse preview - Task/note/event type selector, create with active domain - Toast with undo button after creation - Inbox page: j/k keyboard navigation, Enter to open - Quick capture input at top of inbox - Undo toasts for task/note/habit deletion (recreates via POST) - StatusBar + QuickCapture mounted in _app layout
34 lines
911 B
TypeScript
34 lines
911 B
TypeScript
import { toast } from "sonner";
|
|
import { api } from "@/lib/api";
|
|
|
|
export function showUndoToast(
|
|
entityType: string,
|
|
entityId: string,
|
|
entityData: Record<string, any>,
|
|
queryClient: { invalidateQueries: (opts: { queryKey: string[] }) => void },
|
|
queryKey: string[],
|
|
) {
|
|
toast.success(`${entityType} deleted`, {
|
|
action: {
|
|
label: "Undo",
|
|
onClick: async () => {
|
|
try {
|
|
const endpoint =
|
|
entityType === "task"
|
|
? "/tasks"
|
|
: entityType === "note"
|
|
? "/notes"
|
|
: entityType === "habit"
|
|
? "/habits"
|
|
: "/calendar/events";
|
|
await api.post(endpoint, entityData);
|
|
queryClient.invalidateQueries({ queryKey });
|
|
toast.success(`${entityType} restored`);
|
|
} catch {
|
|
toast.error("Failed to restore");
|
|
}
|
|
},
|
|
},
|
|
});
|
|
}
|