feat(transactions): honour ?q= so a link can land on one row
ci / lint-test (push) Successful in 42s
ci / lint-test (push) Successful in 42s
The Slack order nudge links here. 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 being opened.
This commit is contained in:
@@ -507,6 +507,13 @@ function TransactionsContent() {
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const initialStatementId = searchParams.get("statement_id") || "";
|
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({
|
const [filters, setFilters] = useState({
|
||||||
from: "",
|
from: "",
|
||||||
to: "",
|
to: "",
|
||||||
@@ -514,7 +521,7 @@ function TransactionsContent() {
|
|||||||
bank_names: [] as string[],
|
bank_names: [] as string[],
|
||||||
tag_ids: [] as string[],
|
tag_ids: [] as string[],
|
||||||
transaction_types: [] as string[],
|
transaction_types: [] as string[],
|
||||||
search: "",
|
search: initialParsed.text,
|
||||||
statement_id: initialStatementId,
|
statement_id: initialStatementId,
|
||||||
sort_by: "transaction_date",
|
sort_by: "transaction_date",
|
||||||
sort_dir: "desc",
|
sort_dir: "desc",
|
||||||
@@ -525,8 +532,8 @@ function TransactionsContent() {
|
|||||||
has_split: "" as string,
|
has_split: "" as string,
|
||||||
trip_id: "" as string,
|
trip_id: "" as string,
|
||||||
});
|
});
|
||||||
const [queryInput, setQueryInput] = useState("");
|
const [queryInput, setQueryInput] = useState(initialQuery);
|
||||||
const [queryTokens, setQueryTokens] = useState<QueryToken[]>([]);
|
const [queryTokens, setQueryTokens] = useState<QueryToken[]>(initialParsed.tokens);
|
||||||
|
|
||||||
function handleQueryChange(val: string) {
|
function handleQueryChange(val: string) {
|
||||||
setQueryInput(val);
|
setQueryInput(val);
|
||||||
|
|||||||
Reference in New Issue
Block a user