-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
chore: app router - /bookings status page #18183
Merged
+35
−89
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
42a6115
chore: app router - /bookings page
hbjORbj 8c117bb
remove env vars
hbjORbj 1fe5d4d
Merge branch 'main' into chore/bookings-app-router
hbjORbj 87f2100
fix
hbjORbj e65a75c
Merge branch 'main' into chore/bookings-app-router
hbjORbj 8ad1adf
Update middleware.ts
hbjORbj 5475638
Merge branch 'main' into chore/bookings-app-router
hbjORbj 88a6b4f
Merge remote-tracking branch 'origin/main' into chore/bookings-app-ro…
hbjORbj adc4a3f
revert unneeded change
hbjORbj ff51b5b
refactor for the better
hbjORbj df50e4a
fix
hbjORbj 91b1416
add generateStaticParams
hbjORbj 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 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 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 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { PageProps } from "app/_types"; | ||
import { _generateMetadata } from "app/_utils"; | ||
import { WithLayout } from "app/layoutHOC"; | ||
import { redirect } from "next/navigation"; | ||
import { z } from "zod"; | ||
|
||
import { validStatuses } from "~/bookings/lib/validStatuses"; | ||
import BookingsList from "~/bookings/views/bookings-listing-view"; | ||
|
||
const querySchema = z.object({ | ||
status: z.enum(validStatuses), | ||
}); | ||
|
||
export const generateMetadata = async () => | ||
await _generateMetadata( | ||
(t) => t("bookings"), | ||
(t) => t("bookings_description") | ||
); | ||
|
||
export const generateStaticParams = async () => { | ||
return validStatuses.map((status) => ({ status })); | ||
}; | ||
|
||
const Page = async ({ params, searchParams }: PageProps) => { | ||
const parsed = querySchema.safeParse({ ...params, ...searchParams }); | ||
if (!parsed.success) { | ||
redirect("/bookings/upcoming"); | ||
} | ||
|
||
return <BookingsList status={parsed.data.status} />; | ||
}; | ||
|
||
export default WithLayout({ ServerPage: Page })<"P">; |
This file was deleted.
Oops, something went wrong.
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
24 changes: 0 additions & 24 deletions
24
apps/web/modules/bookings/views/bookings-listing-view.getStaticProps.tsx
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
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
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.
/bookings/123
because 123 is not a valid status (upcoming, cancelled, etc).export const dynamic = "force-static";
from this route. So I removed it.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.
Now that we don't have
dynamic = "force-static"
, does this mean this page is server rendered every time? Or Next.js still builds it statically because ofgenerateStaticParams
? I'd appreciate your explaination as I'm not familiar enough with these to understand the behavior 👀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.
This is absolutely correct. With
dynamic = "force-static"
, user will get routed to 404 ifstatus
is not one of those returned bygenerateStaticParams
before we have chance to redirect them to/bookings/upcoming
.