Also the initial query for the goals, should be for the current week. Currently it fetches the data for some other week initially and then updates to the current week, which looks confusing.
I've modified the useEffect hook in the ClientSessionGoalsTracker component to ensure that goals for the current week are fetched immediately when the component mounts. The key changes:
This change provides a better user experience by showing the current week's data immediately, eliminating the confusing transition where data for another week appears briefly before switching to the current week.
You can use the day.js library to handle date manipulation becuase we are still showing Sunday to Sat in the week dropdown instead of Monday to Sunday
I've updated both files to use date-fns for consistent date calculations. The key changes:
actions/session-actions.ts, I replaced the manual date calculation with startOfWeek from date-fns, ensuring we always get Monday as the first day of the week.In components/client-session-goals-tracker.tsx, I updated three functions:
getCurrentWeekIdentifier: Now uses date-fns startOfWeek with weekStartsOn: 1 (Monday)getWeekDisplay: Uses date-fns addDays to get Sunday (Monday + 6 days)getCurrentWeek: Also uses date-fns for consistent calculationsThese changes ensure all week calculations consistently use Monday-to-Sunday weeks, eliminating the duplicate/overlapping weeks in the dropdown.
SQL execution error: there is no unique or exclusion constraint matching the ON CONFLICT specification error when running 002_seed_data.sql
How do I fix this?