Skip to content
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

Refactor/trpc #18

Merged
merged 25 commits into from
Oct 4, 2023
Merged

Refactor/trpc #18

merged 25 commits into from
Oct 4, 2023

Conversation

jthrilly
Copy link
Member

@jthrilly jthrilly commented Sep 29, 2023

This PR contains a fairly significant update to the tRPC implementation, based on things I have learned since the initial attempt.

Specifically:

  • Implements a RedirectWrapper component under the root layout. This client side component calculates if a redirection is needed based on the path (which is now available via useRouter, meaning no middleware header injection is required). This solves the infinite update depth errors, and allows us to use the router for navigation again.
  • Removes all use of window.location in favour of router methods.
  • Reimplements the setup metadata functionality to consolidate all behaviour within the tRPC router. Attempts to force revalidation to trigger root layout re-render.
  • Uses this endpoint to verify the expired status of the setup during the onboarding flow.
  • Significantly improves the SessionProvider by correctly setting the initialData for the client side query, and refreshing the router when the session changes to null from having previously been defined (allowing the app to redirect to login across multiple tabs).

It also makes several other quality of life changes:

  • Removes all use of process.env in favour of our environment helper
  • Adds a useZodForm hook which provides better ergonomics for working with zod + react-hook-form
  • Adds a usePrevious hook, which allows you to track the previous value of a state item or prop, which can be used inside of useEffect for comparing.
  • Adds onDelete: Cascade to several of our models, meaning that relations won't be invalidated by deleting various entities.
  • Updates the seed script to work correctly, including setting a valid default admin password.
  • Refactor the route redirection on the onboarding wizard to work more reliably.

I'm going to branch off of this now and do some refactoring of the current client-side data fetching that is going on.

@jthrilly jthrilly marked this pull request as ready for review September 29, 2023 14:15
@jthrilly jthrilly merged commit d9f0bd2 into main Oct 4, 2023
@jthrilly jthrilly deleted the refactor/trpc branch April 5, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant