import React, { useState, useMemo } from "react"; import { View, Pressable, TextInput, useColorScheme, Modal, ScrollView } from "react-native"; import { useSirouRouter } from "@sirou/react-native"; import { AppRoutes } from "@/lib/routes"; import { Text } from "@/components/ui/text"; import { X, Search, FileText, ShieldCheck, Wallet, Receipt, Settings, User, HelpCircle, Briefcase, FolderOpen, BarChart3, DraftingCompass, Scan, Lock, Globe, History } from "@/lib/icons"; const ICON_COLOR = "#E46212"; interface Flow { label: string; keywords: string[]; route: string; icon: React.ReactNode; } const FLOWS: Flow[] = [ { label: "Add Invoice", keywords: ["invoice", "create", "new", "bill"], route: "invoices/create", icon: }, { label: "Verify Payment", keywords: ["verify", "payment", "reference", "ft"], route: "verify-payment", icon: }, { label: "Create Payment", keywords: ["payment", "create", "new", "pay"], route: "payments/create", icon: }, { label: "Add Receipt", keywords: ["receipt", "scan", "upload"], route: "add-receipt", icon: }, { label: "Settings", keywords: ["settings", "preferences", "theme"], route: "settings", icon: }, { label: "Profile", keywords: ["profile", "account", "user"], route: "profile", icon: }, { label: "Help & Support", keywords: ["help", "support", "ticket"], route: "help", icon: }, { label: "FAQ", keywords: ["faq", "questions", "answers"], route: "faq", icon: }, { label: "Company", keywords: ["company", "business", "workers", "employees"], route: "company", icon: }, { label: "Documents", keywords: ["documents", "files", "docs"], route: "documents/index", icon: }, { label: "Reports", keywords: ["reports", "analytics", "stats"], route: "reports/index", icon: }, { label: "Scan Receipt", keywords: ["scan", "camera", "receipt", "ocr"], route: "(tabs)/scan", icon: }, { label: "Proforma", keywords: ["proforma", "estimate", "quote"], route: "(tabs)/proforma", icon: }, { label: "News", keywords: ["news", "updates", "announcements"], route: "news/index", icon: }, { label: "Change PIN", keywords: ["pin", "password", "security", "change"], route: "set-pin", icon: }, { label: "Payment History", keywords: ["payments", "history", "transactions"], route: "history", icon: }, { label: "Invoices", keywords: ["invoices", "bills", "list"], route: "(tabs)", icon: }, ]; interface CommandPaletteProps { visible: boolean; onClose: () => void; } export function CommandPalette({ visible, onClose }: CommandPaletteProps) { const nav = useSirouRouter(); const { colorScheme } = useColorScheme(); const isDark = colorScheme === "dark"; const [query, setQuery] = useState(""); const results = useMemo(() => { if (!query.trim()) return FLOWS; const q = query.toLowerCase(); return FLOWS.filter( (f) => f.label.toLowerCase().includes(q) || f.keywords.some((k) => k.includes(q)), ); }, [query]); const handleSelect = (flow: Flow) => { nav.go(flow.route as any); onClose(); setQuery(""); }; return ( {}} > {results.map((flow) => ( handleSelect(flow)} className="flex-row items-center px-3 py-3 rounded-xl active:bg-card" > {flow.icon} {flow.label} ))} {results.length === 0 && ( No results found )} ); }