-
Notifications
You must be signed in to change notification settings - Fork 48
Refactor: Templates api layer to trpc #189
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
09e5c0e
add: templates trpc router
ben-fornefeld ee682d5
refactor: templates route to use trpc procedures
ben-fornefeld a2b7fce
improve: default templates caching
ben-fornefeld 611253d
remove: outdated action client functions
ben-fornefeld 1bb987f
finalize: templates refactor
ben-fornefeld 0f248ff
improve: add loading layout for templates refetching
ben-fornefeld 666c396
fix: infra error handling
ben-fornefeld 71b391d
improve: unexpected error handling
ben-fornefeld 7ab0d01
improve: error handling + chore
ben-fornefeld 3f5548b
improve: templates mutation ux
ben-fornefeld 8afcdf5
improve: template U/D prose
ben-fornefeld 26fb160
chore
ben-fornefeld bb321c8
chore: but default templates at beginning
ben-fornefeld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,25 @@ | ||
| import LoadingLayout from '@/features/dashboard/loading-layout' | ||
| import TemplatesTable from '@/features/dashboard/templates/table' | ||
| import { | ||
| getDefaultTemplates, | ||
| getTeamTemplates, | ||
| } from '@/server/templates/get-team-templates' | ||
| import ErrorBoundary from '@/ui/error' | ||
| import { HydrateClient, prefetch, trpc } from '@/trpc/server' | ||
| import { Suspense } from 'react' | ||
|
|
||
| export default async function Page({ | ||
| params, | ||
| }: PageProps<'/dashboard/[teamIdOrSlug]/templates'>) { | ||
| const { teamIdOrSlug } = await params | ||
|
|
||
| const res = await getTeamTemplates({ | ||
| teamIdOrSlug, | ||
| }) | ||
| prefetch( | ||
| trpc.templates.getTemplates.queryOptions({ | ||
| teamIdOrSlug, | ||
| }) | ||
| ) | ||
| prefetch(trpc.templates.getDefaultTemplatesCached.queryOptions()) | ||
|
|
||
| const defaultRes = await getDefaultTemplates() | ||
|
|
||
| if (!res?.data?.templates || res?.serverError) { | ||
| return ( | ||
| <ErrorBoundary | ||
| error={ | ||
| { | ||
| name: 'Templates Error', | ||
| message: res?.serverError ?? 'Unknown error', | ||
| } satisfies Error | ||
| } | ||
| description={'Could not load templates'} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| const templates = [ | ||
| ...res.data.templates, | ||
| ...(defaultRes?.data?.templates ? defaultRes.data.templates : []), | ||
| ] | ||
|
|
||
| return <TemplatesTable templates={templates} /> | ||
| return ( | ||
| <HydrateClient> | ||
| <Suspense fallback={<LoadingLayout />}> | ||
| <TemplatesTable /> | ||
| </Suspense> | ||
| </HydrateClient> | ||
| ) | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Template display order reversed
The templates array now places default templates before team templates, reversing the original order where team templates appeared first. Since there's no default sorting applied, this changes the display order in the UI. The original code had team templates first, then default templates.