"use client"; import * as React from "react"; import Link from "next/link"; import { TextFieldRoot, TextFieldInput } from "@seed-design/react"; import { Card } from "@/ds"; import { tugrik } from "@/ds/money"; import { useTransactions } from "@/api/hooks/reads"; import type { Txn } from "@/api/schemas"; import { plannerStrings as s } from "./strings"; export interface CategoryTransactionsProps { category: string; } /** MM.dd from an RFC3339/ISO timestamp — mirrors CategoryTransactionsView's * `shortDate` on iOS. Falls back to an empty string on unparsable input. */ function shortDate(rfc: string): string { const d = new Date(rfc); if (Number.isNaN(d.getTime())) return ""; const mm = String(d.getMonth() + 1).padStart(2, "0"); const dd = String(d.getDate()).padStart(2, "0"); return `${mm}.${dd}`; } /** Every transaction in one category (server expands to sub-categories too) — * opened by tapping a category-limit row on the planner hub. Ports * `CategoryTransactionsView.swift`: header + filter + list, tap-free (the web * port has no transaction detail cover yet). */ export function CategoryTransactions({ category }: CategoryTransactionsProps) { const { data, isLoading } = useTransactions({ category, from: "2020-01-01", to: "2027-12-31", limit: 300, }); const [search, setSearch] = React.useState(""); const rows: Txn[] = React.useMemo(() => { const all = data ?? []; const needle = search.trim().toLowerCase(); if (!needle) return all; return all.filter((t) => t.title.toLowerCase().includes(needle)); }, [data, search]); return (
…
} {!isLoading && rows.length === 0 && ({s.categoryTransactions.empty}
)} {!isLoading && rows.length > 0 && (