Commit 8998828
authored
❇️ [refactor][frontend] Migrate to React/Vite/TS (#166)
## Goal
Migrate from Next.js + Pages Router to Vite + React + TypeScript with
TanStack Router.
## Architecture changes
| Concern | Before | After |
| -------------- | --------------------------------------------------- |
---------------------------------------------------------------------------------------------------------------------------------
|
| Build tool | Next.js | Vite (with React Compiler via babel preset) |
| Routing | Next.js App Router (file-based) | TanStack Router
(file-based, with typed context) |
| Styling | Tailwind v3 + PostCSS + custom config | Tailwind v4
(CSS-first, `@tailwindcss/vite` plugin) |
| UI primitives | shadcn (old conventions, Radix individual packages) |
shadcn 2025 Nova preset (radix-ui umbrella, neutral oklch palette, Geist
font) |
| Data fetching | TanStack Query + hey-api SDK (manually composed) |
Same pattern, ported as-is |
| HTTP client | `@hey-api/client-axios` (separate package) |
Generator-bundled runtime + plain `axios` |
| Auth | React Context, password stored in localStorage | React Context
+ bridge into router context. **No password stored.** Pathless
`_authenticated` layout route with `beforeLoad` gate |
| Toast | Custom Radix Toast + `use-toast` hook | sonner |
| Forms | shadcn `Form` + react-hook-form | New `Field` / `InputGroup`
primitives + raw react-hook-form |
| Icons | mixed (lucide + iconify) | lucide only |
| Tree component | `@primer/react TreeView` | Custom recursive component
built on shadcn Collapsible |
| Sidebar | Custom Aceternity (framer-motion + iconify) | shadcn sidebar
with collapsible-to-icon mode |
## What got built
**Routes** (file-based, type-safe):
- `/login` — public, with redirect-back search param
- `/logout` — public action route, no UI, clears auth + redirects
- `/_authenticated` — pathless layout, runs `beforeLoad` auth gate,
mounts sidebar + Toaster's parent
- `/` — home (calendar + payments)
- `/account` — accounts list + transactions (resizable panels)
- `/category` — category tree + transactions
**Custom components** (your code, on top of shadcn primitives):
- `<AppSidebar>` — branded nav + user dropdown with logout
- `<DateRangePicker>` — popover + range Calendar
- `<Tree>` — recursive, with chevron-or-row click to expand + select
highlighting
- `<AuthProvider>` / `useAuth()` — React Context, hydrates from
localStorage synchronously
**Tooling:**
- ESLint flat config with prettier integration + scoped overrides for
shadcn-generated paths
- Prettier with sort-imports plugin + tailwindcss plugin
- OpenAPI client regeneration via `pnpm generate-client` +
`postinstall.sh` (auto-runs on Vercel)
- Strict TypeScript, path alias `@/*` via manual `resolve.alias`
## Deliberate departures from the old project
1. **Dropped password storage in localStorage.** Old code stored `{
host, username, password }` and re-called the login API on mount. New
code stores `{ host, username, accessToken }` only. Logout-then-login is
required to switch accounts; no pre-fill from saved password.
2. **Auth-gating moved from `useEffect` redirects in pages to
route-level `beforeLoad`.** No flash of unauthorized content. Single
declaration applies to all protected children.
3. **`/setting` route deleted.** It was a relabeled login/logout form;
functionality moved to `/login` and `/logout`.
4. **`@primer/react`, `framer-motion`, `@iconify-icon/react`,
`styled-components` not ported.** Either replaced (Tree → Collapsible,
sidebar → shadcn) or were unused leftovers.
5. **`shadcn` form component is gone (deprecated in 2025).** Replaced by
`Field` + `InputGroup` primitives + raw react-hook-form usage when
needed.
## Known unfinished work
- **Hardcoded `transactions` arrays** in `/account` and `/category` —
port-faithful placeholder, real backend wiring deferred.
- **`/` payment badge styling** — Income/Expense/Transfer all on red
background (ported as-is from old buggy code).89 files changed
Lines changed: 8348 additions & 6009 deletions
File tree
- .vscode
- frontend
- app
- account
- category
- setting
- components
- ui
- hooks
- lib/context
- public
- scripts
- src
- components
- ui
- hooks
- lib
- routes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
4 | 13 | | |
5 | 14 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | | - | |
11 | | - | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | | - | |
18 | | - | |
| 23 | + | |
| 24 | + | |
19 | 25 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | | - | |
31 | | - | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | | - | |
34 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
35 | 48 | | |
36 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
37 | 53 | | |
38 | | - | |
39 | 54 | | |
40 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
41 | 161 | | |
42 | | - | |
| 162 | + | |
| 163 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
This file was deleted.
0 commit comments