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

Use react router for landing => checkout => thank-you route #5962

Merged
merged 8 commits into from
Apr 29, 2024

Conversation

jamesgorrie
Copy link
Contributor

@jamesgorrie jamesgorrie commented Apr 26, 2024

  • Uses react-router to encapsulate the landing => checkout => thank-you journey
  • Adds the concept GeoIdConfig which is config that is variable on the /{geoId} segment of the URL
  • Changes the checkout name for the route to router in the play app
  • Copy/pastes the values dependant on the geoId in the checkout component into the component

I'm doing this because when setting up a whole new route for the thank you page from Play => rendering, the boilerplate was becoming immense and unwieldy. This replicates the pattern we had setup for /{geoId}/contribution from Play => Router.

This also avoids having to spin up another webpack.entryPoint. A 🚤 performance-point 🚀 here

  • this does mean that the entire journey is built into 1 file, which could also start to get too large. This is how we currently do it, but it made me think that we should be tracking this against the current checkout flow to ensure we're making improvements. I'm tracking that in the Epic.

Part of #5722

Tasks

Preview Give feedback

const router = createBrowserRouter(
geoIds
.map((geoId) => [
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll add the /${geoId} soon as part of the migration from /{geoId}/contribute work as this URL is currently redirected via Fastly and the Play app.

Copy link
Contributor

github-actions bot commented Apr 26, 2024

Size Change: +14.9 kB (+1%)

Total Size: 1.95 MB

Filename Size Change
./public/compiled-assets/javascripts/[countryGroupId]/checkout.js 0 B -143 kB (removed) 🏆
./public/compiled-assets/javascripts/[countryGroupId]/router.js 158 kB +158 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./public/compiled-assets/javascripts/ausMomentMap.js 107 kB -2 B (0%)
./public/compiled-assets/javascripts/contributionsRedirectStyles.js 20 B 0 B
./public/compiled-assets/javascripts/digitalSubscriptionLandingPage.js 217 kB +1 B (0%)
./public/compiled-assets/javascripts/downForMaintenancePage.js 68 kB -1 B (0%)
./public/compiled-assets/javascripts/error404Page.js 68 kB -1 B (0%)
./public/compiled-assets/javascripts/error500Page.js 67.9 kB -1 B (0%)
./public/compiled-assets/javascripts/favicons.js 616 B 0 B
./public/compiled-assets/javascripts/paperSubscriptionCheckoutPage.js 168 kB +10 B (0%)
./public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 84.8 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPage.js 66.5 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPageStyles.js 20 B 0 B
./public/compiled-assets/javascripts/promotionTerms.js 71.2 kB 0 B
./public/compiled-assets/javascripts/subscriptionsLandingPage.js 70.3 kB +1 B (0%)
./public/compiled-assets/javascripts/subscriptionsRedemptionPage.js 124 kB 0 B
./public/compiled-assets/javascripts/supporterPlusLandingPage.js 284 kB 0 B
./public/compiled-assets/javascripts/unsupportedBrowserStyles.js 20 B 0 B
./public/compiled-assets/javascripts/weeklySubscriptionCheckoutPage.js 188 kB 0 B
./public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 85 kB -1 B (0%)
./public/compiled-assets/webpack/363.js 18.2 kB 0 B
./public/compiled-assets/webpack/385.js 81.8 kB 0 B
./public/compiled-assets/webpack/735.js 2 kB 0 B
./public/compiled-assets/webpack/775.js 18 kB 0 B
./public/compiled-assets/webpack/991.js 2.16 kB 0 B

compressed-size-action

ssrPages: 'helpers/rendering/ssrPages.ts',
},
common: {
'[countryGroupId]/router': 'pages/[countryGroupId]/router.tsx',
Copy link
Contributor Author

@jamesgorrie jamesgorrie Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change - the rest is formatting.

@jamesgorrie jamesgorrie requested a review from GHaberis April 26, 2024 10:42
type Props = {
geoId: GeoId;
};
function CheckoutComponent({ geoId }: Props) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ordering of this file has changed - that's provably the most important piece to review.

@jamesgorrie jamesgorrie requested a review from a team April 26, 2024 10:58
@jamesgorrie
Copy link
Contributor Author

jamesgorrie commented Apr 26, 2024

@GHaberis - re: filesize - currently SupporterPlusRouter (AKA supporterPlusLandingPage is 284 kB and router now is +158 kB.

It's not a fair comparison though as supporterPlusLandingPage includes the landing page.

Interestingly - adding react-router adds 15kb - which is significant, I was looking at a more slim router like https://github.com/molefrog/wouter, or a more fully featured, but smaller https://tanstack.com/router

As a point, another reason I am not going to deep on exploring other routers is we have quite a few methods that use react-router with pageviews and the like.

@jamesgorrie jamesgorrie requested a review from rBangay April 29, 2024 13:38
@jamesgorrie jamesgorrie force-pushed the react-router-thank-you branch 2 times, most recently from fd637fd to 498acd7 Compare April 29, 2024 13:40
@jamesgorrie jamesgorrie force-pushed the react-router-thank-you branch from 498acd7 to da2a059 Compare April 29, 2024 13:53
Copy link
Contributor

@rBangay rBangay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Nice work!

@jamesgorrie jamesgorrie merged commit 0756e4d into main Apr 29, 2024
15 checks passed
@jamesgorrie jamesgorrie deleted the react-router-thank-you branch April 29, 2024 14:26
@prout-bot
Copy link

Seen on PROD (merged by @jamesgorrie 9 minutes and 49 seconds ago)

Sentry Release: support-client-side, support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants