Commit 6dc90b4
authored
* fix: respect user and group default currency when creating expenses
Closes #631
The expense form always defaulted to USD regardless of the user's or
group's configured default currency. The user/group defaults were
fetched but never applied to the form's currency field.
Changes:
- src/pages/add.tsx: set currency from user.defaultCurrency for
non-group expenses, and from group.defaultCurrency (falling back to
the user's) when entering a group context. The setCurrentUser effect
is gated on router.isReady so the first render (before Next.js
populates router.query) does not falsely treat a group page as a
non-group page and apply the wrong default.
- src/store/addStore.ts: resetState now restores the user's default
currency on unmount so navigating away and back lands on the correct
default instead of stale state.
Disclaimer: parts of this change were drafted with the help of
Claude Opus 4.7.
* fix: apply full currency preference chain in add expense
Address review feedback on #647: prefer the user's last-used currency
(User.currency) before falling back to the group default and the user's
defaultCurrency setting. Also drop the currency override in resetState
so that resetting the form keeps the last-used currency.
Preference chain when initializing the add-expense page:
1. currentUser.currency (last used)
2. group.defaultCurrency (when in a group context)
3. currentUser.defaultCurrency
Disclaimer: parts of this change were drafted with the help of Claude Opus 4.7.
* fix: keep last-used currency in store across remounts
When picking a currency, also update currentUser.currency in the
add-expense store so the preference chain on the next /add mount sees
the just-picked value without waiting for the async next-auth session
update to settle. On mount, the AddPage effect also preserves the
stored currency for the same user id instead of overwriting it with
potentially stale session data.
Disclaimer: parts of this change were drafted with the help of Claude Opus 4.7.
* fix: await session refresh before navigating after expense submit
Replace the previous remount-time currency preservation with a simpler
fix: in the expense submit handler, await the next-auth session update
(which writes the just-picked currency back into the session) BEFORE
navigating away. This guarantees that any subsequent /add mount reads
the up-to-date currentUser.currency without local-store overrides.
Reverts the in-store overwrite from 49b9778 so currentUser in the
add-expense store keeps mirroring the session user as-is.
Disclaimer: parts of this change were drafted with the help of Claude Opus 4.7.
1 parent 9ed899a commit 6dc90b4
2 files changed
Lines changed: 24 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
176 | 183 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | 184 | | |
187 | 185 | | |
188 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
117 | 123 | | |
118 | 124 | | |
119 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
120 | 131 | | |
121 | 132 | | |
122 | 133 | | |
| |||
131 | 142 | | |
132 | 143 | | |
133 | 144 | | |
| 145 | + | |
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
| |||
0 commit comments