From 7abe9fd082e066c897c8bbfcfb1351aa3125168a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Murta?= Date: Sat, 6 Sep 2025 17:50:15 +0100 Subject: [PATCH] fixup! ongoing editable category --- src/main.tsx | 4 +-- src/routes/categories.tsx | 10 ++++-- src/routes/transactions.tsx | 63 ++++++++++++++++++++++++++++++------- 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index a6962a9..9790277 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -12,9 +12,9 @@ const queryClient = new QueryClient(); createRoot(document.getElementById("root")!).render( - + - + ); diff --git a/src/routes/categories.tsx b/src/routes/categories.tsx index 1a43516..c1ae4c2 100644 --- a/src/routes/categories.tsx +++ b/src/routes/categories.tsx @@ -6,9 +6,13 @@ type Category = { }; export async function loader(): Promise { - return fetch(`http://localhost:9000/categories`).then((response) => { - return response.json(); - }); + return [ + { name: "Books", group: { name: "Media" } }, + { name: "Movies", group: { name: "Media" } }, + { name: "Groceries", group: { name: "Shopping" } }, + { name: "Electronics", group: { name: "Shopping" } }, + { name: "Misc", group: undefined } + ]; } export default function Categories() { diff --git a/src/routes/transactions.tsx b/src/routes/transactions.tsx index 76c436a..32b8f5d 100644 --- a/src/routes/transactions.tsx +++ b/src/routes/transactions.tsx @@ -59,9 +59,14 @@ export default function Transactions() { columnHelper.accessor("category", { header: "Category", cell: (props) => { - console.log(props.getValue()); + const [selectedCategory, setSelectedCategory] = useState( + props.getValue() as string + ); return ( - setSelectedCategory(e.target.value)} + > {categories.map((category) => (