Files
ProjectE/apps/web/src/lib/undo/use-undo-toast.ts
T
bot-hermes b4d09387ed feat(poweruser): quick capture + inbox keyboard nav + undo toasts
- 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
2026-09-09 01:32:01 +00:00

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");
}
},
},
});
}