Skip to content

Commit

Permalink
upsell top bar for email confirm and account convert
Browse files Browse the repository at this point in the history
  • Loading branch information
k2xl committed May 12, 2024
1 parent 7cd066c commit 7a2e699
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
11 changes: 2 additions & 9 deletions components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import LoadingCard from '../cards/loadingCard';
import FormattedReview from '../level/reviews/formattedReview';
import LoadingSpinner from '../page/loadingSpinner';
import MultiSelectUser from '../page/multiSelectUser';
import UpsellConvertOrConfirmTopBar from './upsellConvertOrConfirm';

interface HomeProps {
lastLevelPlayed?: EnrichedLevel;
Expand Down Expand Up @@ -151,15 +152,7 @@ export default function Home({

return (<>
{tour}
{user && !isFullAccount(user) &&
<div className='bg-yellow-200 w-full text-black text-center text-sm p-2 shadow-lg'>
{`${isGuest(user) ? 'Convert to a regular account' : 'Confirm your email'} in your `}
<Link className='font-semibold text-blue-600 hover:underline' href='/settings'>
Account Settings
</Link>
{' to unlock all basic features!'}
</div>
}
<UpsellConvertOrConfirmTopBar user={user} />
<div className='flex justify-center m-6 text-center'>
<div className='flex flex-col items-center gap-8 w-full max-w-screen-2xl'>
<div className='flex flex-wrap justify-center gap-8 items-center max-w-full'>
Expand Down
16 changes: 16 additions & 0 deletions components/home/upsellConvertOrConfirm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import isFullAccount from '@root/helpers/isFullAccount';
import isGuest from '@root/helpers/isGuest';
import User from '@root/models/db/user';
import Link from 'next/link';
import React from 'react';

export default function UpsellConvertOrConfirmTopBar({ user }: {user: User | null}) {
return user && !isFullAccount(user) && ( <div className='bg-yellow-200 w-full text-black text-center text-sm p-2 shadow-lg'>
{`${isGuest(user) ? 'Convert to a regular account' : 'Confirm your email'} in your `}
<Link className='font-semibold text-blue-600 hover:underline' href='/settings'>
Account Settings
</Link>
{' to unlock all basic features!'}
</div>
);
}
2 changes: 2 additions & 0 deletions pages/[subdomain]/chapter1/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UpsellConvertOrConfirmTopBar from '@root/components/home/upsellConvertOrConfirm';
import { getGameIdFromReq } from '@root/helpers/getGameIdFromReq';
import { GetServerSidePropsContext, NextApiRequest } from 'next';
import Link from 'next/link';
Expand Down Expand Up @@ -29,6 +30,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
export default function Chapter1Page({ enrichedCollections, reqUser, solvedLevels, totalLevels }: CampaignProps) {
return (
<Page folders={[new LinkInfo('Play', '/play')]} title={'Chapter 1'}>
<UpsellConvertOrConfirmTopBar user={reqUser} />
<FormattedCampaign
enrichedCollections={enrichedCollections}
levelHrefQuery={'chapter=1'}
Expand Down
2 changes: 2 additions & 0 deletions pages/[subdomain]/chapter2/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UpsellConvertOrConfirmTopBar from '@root/components/home/upsellConvertOrConfirm';
import { getGameIdFromReq } from '@root/helpers/getGameIdFromReq';
import { GetServerSidePropsContext, NextApiRequest } from 'next';
import Link from 'next/link';
Expand Down Expand Up @@ -60,6 +61,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
export default function Chapter2Page({ enrichedCollections, reqUser, solvedLevels, totalLevels }: CampaignProps) {
return (
<Page folders={[new LinkInfo('Play', '/play')]} title={'Chapter 2'}>
<UpsellConvertOrConfirmTopBar user={reqUser} />
<FormattedCampaign
enrichedCollections={enrichedCollections}
levelHrefQuery={'chapter=2'}
Expand Down
4 changes: 3 additions & 1 deletion pages/[subdomain]/chapter3/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UpsellConvertOrConfirmTopBar from '@root/components/home/upsellConvertOrConfirm';
import { AppContext } from '@root/contexts/appContext';
import { getGameIdFromReq } from '@root/helpers/getGameIdFromReq';
import { GetServerSidePropsContext, NextApiRequest } from 'next';
Expand Down Expand Up @@ -85,11 +86,12 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
}

/* istanbul ignore next */
export default function Chapter3Page({ enrichedCollections, solvedLevels, totalLevels }: CampaignProps) {
export default function Chapter3Page({ reqUser, enrichedCollections, solvedLevels, totalLevels }: CampaignProps) {
const { game } = useContext(AppContext);

return (
<Page folders={[new LinkInfo('Play', '/play')]} title={'Chapter 3'}>
<UpsellConvertOrConfirmTopBar user={reqUser} />
<FormattedCampaign
enrichedCollections={enrichedCollections}
hideUnlockRequirements={true}
Expand Down
2 changes: 2 additions & 0 deletions pages/[subdomain]/play/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import UpsellConvertOrConfirmTopBar from '@root/components/home/upsellConvertOrConfirm';
import { AppContext } from '@root/contexts/appContext';
import { getGameFromId, getGameIdFromReq } from '@root/helpers/getGameIdFromReq';
import { GetServerSidePropsContext, NextApiRequest } from 'next';
Expand Down Expand Up @@ -40,6 +41,7 @@ export default function PlayPage({ reqUser }: PlayPageProps) {

return (
<Page title={'Play'}>
<UpsellConvertOrConfirmTopBar user={reqUser} />
<div className='flex flex-col items-center gap-8 p-4'>
<div className='font-bold text-3xl text-center' id='title'>
{game.displayName} Official Campaign
Expand Down

0 comments on commit 7a2e699

Please sign in to comment.