diff --git a/client/components/CommandPalette.jsx b/client/components/CommandPalette.jsx index e53d73d..29a63c9 100644 --- a/client/components/CommandPalette.jsx +++ b/client/components/CommandPalette.jsx @@ -1,6 +1,9 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; -import { Loader2, Receipt, Search, X } from 'lucide-react'; +import { + BarChart2, Calendar, CreditCard, Loader2, Navigation, Plus, + Receipt, Search, Settings, Snowflake, Tag, Upload, User, X, +} from 'lucide-react'; import { toast } from 'sonner'; import { api } from '@/api'; import { cn, fmt } from '@/lib/utils'; @@ -8,6 +11,48 @@ import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; +// ─── Navigation commands ────────────────────────────────────────────────────── + +const MONTHS = [ + 'January','February','March','April','May','June', + 'July','August','September','October','November','December', +]; + +const NAV_COMMANDS = [ + { id: 'nav-tracker', label: 'Go to Tracker', icon: Receipt, path: '/', group: 'Navigate' }, + { id: 'nav-bills', label: 'Go to Bills', icon: CreditCard, path: '/bills', group: 'Navigate' }, + { id: 'nav-calendar', label: 'Go to Calendar', icon: Calendar, path: '/calendar', group: 'Navigate' }, + { id: 'nav-summary', label: 'Go to Summary', icon: BarChart2, path: '/summary', group: 'Navigate' }, + { id: 'nav-analytics', label: 'Go to Analytics', icon: BarChart2, path: '/analytics', group: 'Navigate' }, + { id: 'nav-snowball', label: 'Go to Snowball', icon: Snowflake, path: '/snowball', group: 'Navigate' }, + { id: 'nav-categories', label: 'Go to Categories', icon: Tag, path: '/categories', group: 'Navigate' }, + { id: 'nav-data', label: 'Go to Data', icon: Upload, path: '/data', group: 'Navigate' }, + { id: 'nav-settings', label: 'Go to Settings', icon: Settings, path: '/settings', group: 'Navigate' }, + { id: 'nav-profile', label: 'Go to Profile', icon: User, path: '/profile', group: 'Navigate' }, + { id: 'action-new-bill', label: 'Add a new bill', icon: Plus, path: '/bills?new=1', group: 'Actions' }, +]; + +// Generate jump-to-month commands for the current year ± 1 +function buildMonthCommands() { + const now = new Date(); + const year = now.getFullYear(); + const commands = []; + for (let y = year - 1; y <= year + 1; y++) { + for (let m = 1; m <= 12; m++) { + commands.push({ + id: `jump-${y}-${m}`, + label: `Jump to ${MONTHS[m - 1]} ${y}`, + icon: Calendar, + path: `/?year=${y}&month=${m}`, + group: 'Jump to Month', + }); + } + } + return commands; +} + +// ─── Helpers ────────────────────────────────────────────────────────────────── + function amountSearchText(...values) { return values .filter(value => value !== null && value !== undefined && Number.isFinite(Number(value))) @@ -42,6 +87,76 @@ function shortcutLabel() { return 'Ctrl K'; } +// ─── Result item components ─────────────────────────────────────────────────── + +function BillResult({ bill, onOpenBills, onOpenTracker }) { + return ( +