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

feat: redeem 100% off coupons #171

Merged
merged 3 commits into from May 4, 2024
Merged

Conversation

joelhooks
Copy link
Collaborator

@joelhooks joelhooks commented May 4, 2024

Course Builder POC 2024-05-04 at 10 21 13@2x

golden ticket

Copy link

vercel bot commented May 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
course-builder-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2024 5:29pm
course-builder-poc 🛑 Canceled (Inspect) May 4, 2024 5:29pm
pro-aws ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2024 5:29pm

@@ -54,7 +55,7 @@ export default function RootLayout({
*/
routerConfig={extractRouterConfig(ourFileRouter)}
/>
{children}
<CouponProvider>{children}</CouponProvider>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this makes it global, so any page will pop the redeem dialog if it's a golden ticket

Comment on lines +20 to +27
React.useEffect(() => {
const searchParams = new URLSearchParams(window.location.search)

const codeParam = searchParams.get('code')
const couponParam = searchParams.get('coupon')

setCouponLoader(getCouponForCode(codeParam || couponParam))
}, [])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this effect inspects the search params for a code/coupon and sets the LOADER (server action)

setCouponLoader(getCouponForCode(codeParam || couponParam))
}, [])

const coupon = couponLoader ? use(couponLoader) : undefined
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if we have a LOADER, we can use it here 🫦

Comment on lines +32 to +38
React.useEffect(() => {
if (coupon?.isValid) {
setProductLoader(getProduct(coupon.restrictedToProductId as string))
}
}, [coupon?.restrictedToProductId, coupon?.isValid])

const product = productLoader ? use(productLoader) : undefined
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if there's a coupon loaded, and it's restricted to a product id and is valid, we set a product loader and use it 🦦

Comment on lines +46 to +52
{isRedeemable && (
<RedeemDialog
open={validCoupon}
couponId={coupon?.id}
product={product}
/>
)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if there is a redeemable coupon we add the dialog

@joelhooks joelhooks merged commit 78d8536 into main May 4, 2024
15 checks passed
@joelhooks joelhooks deleted the joel/golden-ticket-redemptions branch May 4, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant