Skip to content

Commit

Permalink
feat: display membership overlay on posts route for PRO posts (#1498)
Browse files Browse the repository at this point in the history
* feat: add go pro overlay to posts

* refactor: move posts query to function

* refactor: swap display logic
  • Loading branch information
zacjones93 authored Dec 19, 2024
1 parent 04d26bc commit d3f0c21
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 84 deletions.
19 changes: 8 additions & 11 deletions src/components/pages/lessons/overlay/confirm-membership.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type HeaderProps = {
type ConfirmMembershipProps = {
sessionId: string
viewLesson: Function
lesson: LessonResource
lesson: {
slug: string
}
}

const Illustration = () => (
Expand Down Expand Up @@ -101,7 +103,9 @@ const ExistingMemberConfirmation: React.FC<
React.PropsWithChildren<{
session: any
viewLesson: Function
lesson: LessonResource
lesson: {
slug: string
}
}>
> = ({session, viewLesson, lesson}) => {
return (
Expand Down Expand Up @@ -142,10 +146,8 @@ const NewMemberConfirmation: React.FC<
React.PropsWithChildren<{
session: any
currentState: any
viewLesson: Function
lesson: LessonResource
}>
> = ({session, currentState, viewLesson, lesson}) => {
> = ({session, currentState}) => {
return (
<Header
heading={<>Thank you so much for joining egghead! </>}
Expand Down Expand Up @@ -269,12 +271,7 @@ const ConfirmMembership: React.FC<
viewLesson={cleanUrlAndViewLesson}
/>
) : (
<NewMemberConfirmation
lesson={lesson}
session={session}
currentState={currentState}
viewLesson={cleanUrlAndViewLesson}
/>
<NewMemberConfirmation session={session} currentState={currentState} />
)}
</div>
) : (
Expand Down
19 changes: 12 additions & 7 deletions src/components/pages/lessons/overlay/go-pro-cta-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ import ConfirmMembership from './confirm-membership'
import {useRouter} from 'next/router'
import noop from '@/utils/noop'
import OverlayWrapper from '@/components/pages/lessons/overlay/wrapper'
import {usePathname} from 'next/navigation'

type JoinCTAProps = {
lesson: LessonResource
lesson: {
slug: string
collection?: {
title: string
}
}
viewLesson?: Function
}

Expand All @@ -35,9 +41,8 @@ type FormikValues = {
const GoProCtaOverlay: FunctionComponent<
React.PropsWithChildren<JoinCTAProps>
> = ({lesson}) => {
// useRouter's `asPath` can include query params, so using
// `window.location.pathname` instead.
const cleanPath = window?.location?.pathname
const pathname = usePathname()
const {collection} = lesson

const {viewer, authToken} = useViewer()
const {state, send, priceId, quantity, availableCoupons, currentPlan} =
Expand Down Expand Up @@ -165,7 +170,7 @@ const GoProCtaOverlay: FunctionComponent<
authToken,
quantity,
coupon: state.context.couponToApply?.couponCode,
successPath: cleanPath,
successPath: pathname ?? undefined,
})

leaveSpinningForRedirect = true
Expand All @@ -186,8 +191,8 @@ const GoProCtaOverlay: FunctionComponent<
}

switch (true) {
case !isEmpty(lesson.collection):
primaryCtaText = `Level up with ${lesson.collection.title} right now.`
case !isEmpty(collection):
primaryCtaText = `Level up with ${collection?.title} right now.`
break
default:
primaryCtaText = 'Ready to take your career to the next level?'
Expand Down
Loading

0 comments on commit d3f0c21

Please sign in to comment.