diff --git a/src/app/transactions/page.tsx b/src/app/transactions/page.tsx index b5c784b..cf1c2f1 100644 --- a/src/app/transactions/page.tsx +++ b/src/app/transactions/page.tsx @@ -507,6 +507,13 @@ function TransactionsContent() { const searchParams = useSearchParams(); const initialStatementId = searchParams.get("statement_id") || ""; + // `?q=` lands the view on a specific row. The Slack order nudge links here, + // and without it the link drops you at the top of an unfiltered ledger and + // the merchant has to be found by hand — which is how a nudge stops getting + // opened. + const initialQuery = searchParams.get("q") || ""; + const initialParsed = parseQuery(initialQuery); + const [filters, setFilters] = useState({ from: "", to: "", @@ -514,7 +521,7 @@ function TransactionsContent() { bank_names: [] as string[], tag_ids: [] as string[], transaction_types: [] as string[], - search: "", + search: initialParsed.text, statement_id: initialStatementId, sort_by: "transaction_date", sort_dir: "desc", @@ -525,8 +532,8 @@ function TransactionsContent() { has_split: "" as string, trip_id: "" as string, }); - const [queryInput, setQueryInput] = useState(""); - const [queryTokens, setQueryTokens] = useState([]); + const [queryInput, setQueryInput] = useState(initialQuery); + const [queryTokens, setQueryTokens] = useState(initialParsed.tokens); function handleQueryChange(val: string) { setQueryInput(val);