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
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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");
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user