Feat/user data persistence - #46
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e7e974bb4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!supabaseUrl || !supabasePublishableKey) { | ||
| throw new Error("Supabase environment variables are not configured."); | ||
| } |
There was a problem hiding this comment.
Keep the application bootable without Supabase credentials
The checked GitHub Pages build in .github/workflows/deploy.yml supplies neither variable, and the README also describes Supabase setup as optional, but this module is imported during application startup and throws before React can render guest mode or an error boundary. Consequently, the deployed bundle and any local checkout without these variables fail immediately for every visitor instead of providing the advertised in-memory guest experience.
Useful? React with 👍 / 👎.
| monthlyConfigService().setUnusedShabbatCreditHours( | ||
| user.id, | ||
| year, | ||
| month, | ||
| allocation.unusedHours, |
There was a problem hiding this comment.
Avoid writing carry-over before persisted work data is loaded
When an authenticated user opens or reloads the monthly-summary route directly, no WorkTableDayStateHydrator is mounted, so workDays and dailyPayMaps remain at their empty Redux defaults. Once the previous-month fetch resolves, this effect treats that empty calculation as authoritative and overwrites the current month's valid unused_shabbat_credit_hours, corrupting the balance that will be carried into the following month.
Useful? React with 👍 / 👎.
|
|
||
| void callEndPoint(monthlyConfigService().fetch(user.id, year, month)).then((result) => { | ||
| if (cancelled) return; | ||
| hydratedKeyRef.current = key; |
There was a problem hiding this comment.
Do not enable config writes after a failed hydration
If the monthly-config read fails transiently, this assignment still marks the user/month as hydrated before the error branch runs. The loading/snackbar state then causes another render, allowing the write-through effect to upsert the current in-memory defaults or the previously selected month's values and overwrite the configuration that could not be read; only a successful fetch, including a successful empty result, should unlock writes.
Useful? React with 👍 / 👎.
| }); | ||
|
|
||
| useEffect(() => { | ||
| if (!user || workDays.length === 0) return; |
There was a problem hiding this comment.
Clear persisted day state when authentication ends
When a user signs out while the daily table remains mounted, this early return leaves the provider's hydrated statuses and shifts unchanged, so the signed-out UI continues displaying the former account's private work data and permits guest edits against it until the table is remounted. Reset the provider state and hydration flag on logout or scope the provider instance to the authenticated user.
Useful? React with 👍 / 👎.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
No description provided.