-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
148 add exercise entry #671
Draft
Clumsy-Coder
wants to merge
26
commits into
development
Choose a base branch
from
148-add-exercise-entry
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## what - add script to generate ENV for `DATABASE_URL` ## how ## why - this will be used to generate ENV `DATABASE_URL` for the nextjs app ## where - ./generateEnvs.sh ## usage - this will be used for connecting to the postgreSQL database - uses the connection string from - postgresql://user:password@url:port/databaseName ## issue or pull request
## what - add schema for `/api/exercises/id/[exerciseId]/activity` - add schema - properties - exercise id - date - reps - weight - weight unit - distance - distance unit - duration - validation - if no data is provided - if one of `reps`, `weight` or `weight unit` is missing - if one of `distance` or `distance unit` is missing ## how - using zod - using property validation - using `superRefine` to validate grouped exercise entries - reps based - reps - weight - weight unit - distance based - distance - distance unit ## why - this will be used for validating POST request data received from the front end - will be used on page `/exercises/id/[exerciseId]` ## where - ./src/schema/index.ts ## usage ## commit id, issue or pull request ## notes - the code needs to be cleaned up to work with the server and client side - needs better documentation - add better error handling. ex: `duration` - add validation handling.
…ivities` table ## what - add types for selecting and inserting data from `activities` table ## how ## why - used for providing type definitions of the data ## where - ./src/db/schema.ts ## usage ## commit id, issue or pull request ## notes - will be used in `/api/exercises/id/[exerciseId]/activity` POST endpoint
… exercise data into the database ## what - add endpoint for inserting exercise data into the database - get the request data - validate the data using zod - return code 400 if validation fails - insert the provided data into the database ## how - use drizzle to insert into the database ## why - used for adding a record of an exercise performed ## where - ./src/app/api/exercises/id/[exerciseId]/activity/route.ts ## usage ## commit id, issue or pull request ## notes - uses schema validation from `src/schema/index.ts` - check 5364a54
## what - add component `Form` ## how - run command - pnpm dlx shadcn@latest add form ## why ## where - ./package.json - ./pnpm-lock.yaml - ./src/components/ui/form.tsx - ./src/components/ui/label.tsx ## usage ## commit id, issue or pull request ## notes
## what - add component `Select` ## how - run command - pnpm dlx shadcn@latest add select ## why ## where - ./package.json - ./pnpm-lock.yaml - ./src/components/ui/select.tsx ## usage ## commit id, issue or pull request ## notes
## what - add component `Popover` ## how - run command - pnpm dlx shadcn@latest add popover ## why ## where - ./package.json - ./pnpm-lock.yaml - ./src/components/ui/popover.tsx ## usage ## commit id, issue or pull request ## notes
## what - add component `Calendar` ## how - run command - pnpm dlx shadcn@latest add calendar ## why ## where - ./package.json - ./pnpm-lock.yaml - ./src/components/ui/calendar.tsx ## usage ## commit id, issue or pull request ## notes
…entry ## what - add component for adding exercise entry - display in a dialog - display - exercise name - exercise id - input - date - reps - weight - weight unit - distance - distance unit - duration ## how - uses - react hook form - zod - shadcn `Form` component ## why - this component will be used for adding a new exercise entry to the database ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
…()` to `optional()` ## what - change properties in `exerciseEntry` from `.nullish` to `optional` ## how ## why - using `.nullish()` was causing typescript to through errors ## where - ./src/schema/index.ts ## usage ## commit id, issue or pull request ## notes
## what - add server action for adding an exercise activity entry ## how - send a POST request to the URL `/api/exercises/id/[exerciseId]/activity` ## why - this will be used as a server action for adding an exercise activity entry - will be used in react query hooks ## where - ./src/server/actions.ts ## usage ## commit id, issue or pull request ## notes
… exercise activity entry ## what - add react-query hook to send POST request for adding an exercise activity entry ## how - uses react query `mutation` hook - check - https://tanstack.com/query/latest/docs/framework/react/guides/mutations - uses server action `postExerciseEntry` ## why - this will be used to send a POST request to add an entry in the database ## where - ./src/hooks/index.ts ## usage ## commit id, issue or pull request ## notes - after implementing fetching exercise entries, invalidate the exercise entry data to force fetch new data
…losing dialog box ## what - use state to manage opening and closing dialog box - clear the form when closing the dialog box ## how - use react `useState` to track whether the dialog box is open or not - check - shadcn-ui/ui#709 (comment) - shadcn-ui/ui#386 (comment) ## why - to perform extra when closing the dialog box - ex: clear the form data when closing ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
…request to add exercise activity entry ## what - use react query hook to send POST request to add exercise activity entry - clear the form after the request is successful - close dialog box after the request is successful - show loading icon and disable submit button when the request is pending ## how - use react query mutation hook to send the POST request to add exercise entry ## why - this will allow the user to add an exercise entry ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
…en the user's logged in ## what - display add exercise entry button when the user's logged in ## how - check the `session` from using `useSession` - if the user's logged in, then the `session` will be NOT be undefined ## why - to prevent adding an entry without the user being logged in - even if it did, it would redirect the to the login page ## where - ./src/app/exercises/id/[exerciseId]/page.tsx ## usage ## commit id, issue or pull request ## notes
…ted endpoints ## what - add middleware and use next-auth to redirect protected endpoints ## how - check - https://next-auth.js.org/configuration/nextjs#middleware ## why - the middleware will be used to protect endpoints - mainly ones that use authentication ## where - ./src/middleware.ts ## usage ## commit id, issue or pull request ## notes
## what - use regex to validate the `duration` property ## how - using regex ## why - the regex allows the user to enter `99:00:00`, while using the date object limits to `23:59:59` ## where - ./src/schema/index.ts ## usage ## commit id, issue or pull request ## notes - there might be edge cases where the regex might not pickup - ex: `00:00:00`
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
## what - add component `date-time-picker` - update package `react-day-picker` to `v9.2.1` ## how - obtained from - https://shadcnui-expansions.typeart.cc/docs/datetime-picker ## why - this component has more controls over the calendar component from `shadcn` - has option to set the time - has option to pick year easily - has option to change month easily ## where - ./package.json - ./pnpm-lock.yaml - ./src/components/ui/date-time-picker.tsx ## usage ## commit id, issue or pull request ## notes - upgrading package `react-day-picker` to `v9.2.1` causes issues with shadcn `calendar` component - check - shadcn-ui/ui#5417 - remove component `calendar.tsx` since `date-time-picker` is replacing it
## what - update component `Calendar` props ## how ## why - when upgrading package `react-day-picker` to `v9.2.1` it had some breaking changes that needed to be addressed - check - https://daypicker.dev/upgrading - the reason for upgrading `react-day-picker` is due to installing component `date-time-picker` - 327b05b ## where - ./src/components/ui/calendar.tsx ## usage ## commit id, issue or pull request - 327b05b ## notes
… and `TimePicker` for setting date and time ## what - use component `DateTimePicker` and `TimePicker` for setting date and time ## how ## why - the shadcn component `Calendar` is limited - can't set the time - can't jump to different year - can't jump to different year. have to use the arrows ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
…ng dialog ## problem - the date doesn't update when opening the dialog ## fix - set the date ONLY when opening the dialog ## how - run the code in dialog `onOpenChange` function ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
…stance` ## what - set min requirement for input `distance` ## how ## why - doesn't makes sense to travel negative distance ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
## what - remove unused code - remove console logs ## how ## why ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
…and `distance unit` dropdown ## what - add placeholder in `weight unit` and `distance unit` dropdown - increase the width of dialog; to view the placeholder of the two dropdown with being cut of ## how ## why - for more clarity on what the form element is for ## where - ./src/components/addExerciseEntry.tsx ## usage ## commit id, issue or pull request ## notes
Clumsy-Coder
force-pushed
the
148-add-exercise-entry
branch
2 times, most recently
from
November 4, 2024 17:42
bbfecbe
to
ded9c93
Compare
Clumsy-Coder
force-pushed
the
148-add-exercise-entry
branch
from
November 5, 2024 00:31
ded9c93
to
f36069c
Compare
Clumsy-Coder
force-pushed
the
148-add-exercise-entry
branch
from
November 5, 2024 00:33
f36069c
to
31d3da2
Compare
## what - add github action for deleting data from remote database - run every hour - install `psql` client - delete the data on table `activities` - reset auto increment for `activities.id` to 1 ## how ## why - the database is being used by public with limited space - don't want to go overboard in using the database ## where - ./.github/workflows/remoteDatabaseReset.yaml ## usage ## commit id, issue or pull request ## notes
## what - display a demo `badge` when ENV `DEMO` is set ## how - use shadcn component `badge` and `tooltip` - display badge when ENV `DEMO` is set ## why - this to notify the user that this a demo app - mainly used for hosting the app on vercel as a demo - the data on the database will be erased at a schedule - check `.github/workflows/remoteDatabaseReset.yaml` ## where - ./src/app/layout.tsx ## usage ## commit id, issue or pull request ## notes
Clumsy-Coder
force-pushed
the
148-add-exercise-entry
branch
from
November 5, 2024 02:36
31d3da2
to
e81ca97
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add an exercise entry
Description
/api/exercises/id/[exerciseId]/activity
to add an exercise entry/api/exercises/id/[exerciseId]/activity
endpoint as protected endpointsAddExerciseEntry
dialog to enter exercise entry dataactivities
tableactivities
tableRelated Issue
#148
Motivation and Context
To be able to add an exercise entry
How Has This Been Tested?
Screenshots (if appropriate)
Types of changes
Does this Pull Request introduce a breaking change?
Checklist