Skip to content

Commit

Permalink
stache (#432)
Browse files Browse the repository at this point in the history
* stache

* more plan logic

* adding contact grid plan guarding support

---------

Co-authored-by: Nick Grato <[email protected]>
  • Loading branch information
nickgrato and Nick Grato authored Dec 20, 2023
1 parent 85cb969 commit 0c9816b
Show file tree
Hide file tree
Showing 19 changed files with 449 additions and 63 deletions.
6 changes: 3 additions & 3 deletions client/components/modules/hubs/HubFormCard/HubFormCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { StoreContext, SubdomainRetryT } from 'contexts/StoreProvider';
import { RoutesE } from 'types/Routes';
import { useFormik } from 'formik';
import validate, { FormValues } from './validate';
import { useIsProfessional } from 'hooks/usePlans';
import { useIsProfessionalUp } from 'hooks/usePlans';
import Hub from 'classes/Hub';
import { HubT } from 'types/General';
import SecretCopy from '@Shared/SecretCopy/SecretCopy';
Expand All @@ -38,7 +38,7 @@ const HubFormCard = ({ hub: _hub, classProp = '' }: HubFormCardPropsT) => {
useState<string>('');
const [isEditingDomain, setIsEditingDomain] = useState(false);
const router = useRouter();
const isProfessional = useIsProfessional();
const isProfessionalUp = useIsProfessionalUp();
const hub = useMemo(() => new Hub(_hub), [_hub]);

/**
Expand Down Expand Up @@ -281,7 +281,7 @@ const HubFormCard = ({ hub: _hub, classProp = '' }: HubFormCardPropsT) => {
) : null}
</div>

{isProfessional && (
{isProfessionalUp && (
<section className={styles.custom_client_message}>
<div className="flex-justify-between mb-12">
<h1 className="heading-sm">Custom Domain</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

.wrapper {
background-color: $color-background-overlay;
width: 375px;
width: 100%;
border-radius: 20px;
padding: 65px;
padding: 25px;
overflow: hidden;
position: relative;
margin: 0px 17px 24px;
Expand All @@ -24,7 +24,7 @@

h2 {
@include heading-lg;
margin: 0 0 24px;
margin: 0 0 12px;
}

p {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ContactCard = ({ email, subject, classProp = '' }: ContactCardPropsT) => {
return (
<div className={`${styles.wrapper} ${classProp}`}>
<div className={styles.content}>
<h2>Business</h2>
<h2>Enterprise</h2>
<p>Need dedicated infrastructure, custom clients, or something else?</p>
<Button
label="contact us"
Expand Down
59 changes: 59 additions & 0 deletions client/components/modules/plans/plan-cards/BusinessPlanCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { useCallback } from 'react';
import { Button } from '@mozilla/lilypad-ui';
import { BUSINESS_COPY } from '../plan.const';
import BasePlanCard, { Price } from './BasePlanCard';
import { getPricePageData } from 'util/utilities';
import { useSelector } from 'react-redux';
import { selectRegion } from 'store/regionSlice';
import { BillingPeriodE, PlansE } from 'types/General';
import styles from './BasePlanCard.module.scss';

type BusinessPlanCardPropsT = {
billingPeriod: BillingPeriodE;
};

const BusinessPlanCard = ({ billingPeriod }: BusinessPlanCardPropsT) => {
const { regionCode } = useSelector(selectRegion);
const { planPrice, planUrl, taxDescription, currencySymbol } =
getPricePageData(regionCode, PlansE.BUSINESS, billingPeriod);

/**
* Handle routing user to correct payment plan
*/
const handleSubscribeClick = useCallback(() => {
window.open(planUrl);
}, [planUrl]);

return (
<BasePlanCard
plan={PlansE.BUSINESS}
title="Professional"
color="rainbow"
price={
<Price
price={`${currencySymbol}${planPrice}`}
billingPeriod={`per ${
billingPeriod === BillingPeriodE.YEARLY ? 'year' : 'month'
}`}
/>
}
infoCopyList={BUSINESS_COPY}
showDisclaimer={false}
additionalContent={
<div className="flex-align-center my-20">
<span className={styles.circle}></span>
<span>Always on — no pausing</span>
</div>
}
confirmButton={
<Button
label="Subscribe to hubs"
text="Get Started"
onClick={handleSubscribeClick}
/>
}
/>
);
};

export default BusinessPlanCard;
1 change: 1 addition & 0 deletions client/components/modules/plans/plan-cards/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as PersonalPlanCard } from './PersonalPlanCard';
export { default as StarterPlanCard } from './StarterPlanCard';
export { default as ProfessionalPlanCard } from './ProfessionalPlanCard';
export { default as BusinessPlanCard } from './BusinessPlanCard';
35 changes: 34 additions & 1 deletion client/components/modules/plans/plan.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,39 @@ export const PROFESSIONAL_COPY: PlanInfoCopyT[] = [
},
];

export const BUSINESS_COPY: PlanInfoCopyT[] = [
{
label: '400 guest capacity',
description: 'Free for guests to join',
icon: null,
},
{
label: '200GB Asset storage',
description: 'For avatars and scenes',
icon: null,
},
{
label: 'Everything in Professional',
description: '',
icon: null,
},
{
label: 'Support emails answered within 12 business hours',
description: '',
icon: null,
},
{
label: '90 minutes of synchronous support per month',
description: '',
icon: null,
},
{
label: '60 minutes of assisted Hubs Cloud data migration',
description: '',
icon: null,
},
];

export const PLAN_ID_MAP = {
/**
* United Kingdom
Expand Down Expand Up @@ -189,7 +222,7 @@ export const PLAN_ID_MAP = {
business: {
monthly: {
planId: 'TODO',
price: 400.22,
price: 499.0,
},
yearly: {
planId: 'TODO',
Expand Down
16 changes: 9 additions & 7 deletions client/components/modules/side-panel/BookMeeting/BookMeeting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styles from './BookMeeting.module.scss';
import Card from '@Shared/Card/Card';
import { Button } from '@mozilla/lilypad-ui';

const BookMeeting = () => (
const BookMeeting = ({ href }: { href: string }) => (
<Card classProp="mb-16">
<div className={styles.wrapper}>
<div className="mr-20-dt mr-12-mb">
Expand All @@ -11,12 +11,14 @@ const BookMeeting = () => (
</p>
</div>
<div className="mt-12-mb">
<Button
text="Book Now"
label="book meeting with team"
target="_blank"
href="https://calendly.com/mhmorran/onboarding "
/>
{Boolean(href) && (
<Button
text="Book Now"
label="book meeting with team"
target="_blank"
href={href as string}
/>
)}
</div>
</div>
</Card>
Expand Down
6 changes: 3 additions & 3 deletions client/components/modules/side-panel/SidePanel/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import GettingStartedPanel from '../GettingStartedPanel/GettingStartedPanel';
import { useMobileDown } from 'hooks/useMediaQuery';
import { useSelector } from 'react-redux';
import { selectAccount } from 'store/accountSlice';
import { useIsProfessional } from 'hooks/usePlans';
import { useIsBusiness } from 'hooks/usePlans';

export type SidePanelPropsT = {
fullDomain: string;
Expand All @@ -24,7 +24,7 @@ const SidePanel = ({
}: SidePanelPropsT) => {
const account = useSelector(selectAccount);
const isMobile = useMobileDown();
const isProfessional = useIsProfessional();
const isBusiness = useIsBusiness();

return (
<section className={`${classProp} ${styles.wrapper}`}>
Expand Down Expand Up @@ -55,7 +55,7 @@ const SidePanel = ({
{account.hasSubscription && subscription.isCancelled && (
<Resubscribe classProp={styles.subcard} />
)}
{!isProfessional && <UpgradePlan />}
{!isBusiness && <UpgradePlan />}

<GettingStartedPanel />
<SupportGrid />
Expand Down
52 changes: 47 additions & 5 deletions client/components/modules/side-panel/SupportGrid/SupportGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,61 @@
import { useState, useEffect, useMemo } from 'react';
import ExpansionPanel from '@Shared/ExpansionPanel/ExpansionPanel';
import SupportLink from '@Shared/SupportLink/SupportLink';
import styles from './SupportGrid.module.scss';
import { useIsStarter } from 'hooks/usePlans';
import { useIsProfessionalUp } from 'hooks/usePlans';
import { PlansE } from 'types/General';
import mailCircle from 'public/mail_circle.png';
import messageCircle from 'public/message_circle.png';
import questionCircle from 'public/question_circle.png';
import BookMeeting from '../BookMeeting/BookMeeting';
import { selectAccount } from 'store/accountSlice';
import { useSelector } from 'react-redux';

type PlanContactInfoT = {
email: string;
calendar: string;
};

type ContactDataT = {
[key in PlansE]: PlanContactInfoT;
};

const SupportGrid = () => {
const isStarter = useIsStarter();
const account = useSelector(selectAccount);
const isProfessionalUp = useIsProfessionalUp();
const [contactData, setContactData] = useState<PlanContactInfoT>({
email: '',
calendar: '',
});

const contactsData: ContactDataT = useMemo(() => {
const defualtContactData: PlanContactInfoT = {
email: 'mailto:[email protected]',
calendar: '',
};
return {
business: {
email: 'mailto:[email protected]',
calendar: 'https://calendly.com/mhmorran/hubs-subscription-support',
},
professional: {
email: 'mailto:[email protected]',
calendar: 'https://calendly.com/mhmorran/hubs-subscription-support',
},
personal: defualtContactData,
starter: defualtContactData,
standard: defualtContactData,
};
}, []);

useEffect(() => {
setContactData(contactsData[account.planName as PlansE]);
}, [contactsData, account]);

return (
<ExpansionPanel title="Support" expanded={true}>
<section>
{!isStarter && <BookMeeting />}

{isProfessionalUp && <BookMeeting href={contactData.calendar} />}
<div className={styles.support_links}>
<SupportLink
title="Message Us"
Expand All @@ -27,7 +69,7 @@ const SupportGrid = () => {
image={mailCircle}
// Firefox does not honor "_bank" on "mailtos"
onClick={() => {
window.open('mailto:[email protected]');
window.open(contactData.email);
}}
body="Contact us via email with your questions."
/>
Expand Down
14 changes: 4 additions & 10 deletions client/pages/analytics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Card from '@Shared/Card/Card';
import { getAnalytics, HubStat } from 'services/analytics.service';
import { Button, Input, Pill } from '@mozilla/lilypad-ui';
import { useState, ChangeEvent } from 'react';
import { requireAuthenticationAndSubscription } from 'services/routeGuard.service';
import { analyticsRG } from 'services/routeGuard.service';
import type { GetServerSidePropsContext } from 'next';

type SandboxPropsT = {
Expand All @@ -29,7 +29,7 @@ const initTiers = {
b0: 0,
};

const Sandbox = ({ analytics }: SandboxPropsT) => {
const Analytics = ({ analytics }: SandboxPropsT) => {
// Fromat Date Util
const getFormattedDate = () => {
const today = new Date();
Expand Down Expand Up @@ -367,17 +367,11 @@ const Sandbox = ({ analytics }: SandboxPropsT) => {
);
};

export default Sandbox;
export default Analytics;

export async function getS() {}

export const getServerSideProps = requireAuthenticationAndSubscription(
export const getServerSideProps = analyticsRG(
(context: GetServerSidePropsContext) => {
// Your normal `getServerSideProps` code here
if (process.env.ENV === 'production') {
return { notFound: true };
}

return {
props: {},
};
Expand Down
32 changes: 21 additions & 11 deletions client/pages/subscribe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
PersonalPlanCard,
StarterPlanCard,
ProfessionalPlanCard,
BusinessPlanCard,
} from '@Modules/plans/plan-cards';
import { BillingPeriodE } from 'types/General';

Expand All @@ -25,18 +26,27 @@ const Subscribe = () => {

<main>
<div className={styles.wrapper}>
<div className={styles.header}>
<h1>Choose your plan</h1>
</div>
<div>
<div className={styles.header}>
<h1>Choose your plan</h1>
</div>

<div className={styles.cards}>
<StarterPlanCard />
<PersonalPlanCard billingPeriod={billingPeriod} />
<ProfessionalPlanCard billingPeriod={billingPeriod} />
<ContactCard
email="[email protected]"
subject="Subscription inquiries"
/>
<div className="flex-justify-center flex-wrap">
<div className="flex-justify-center flex-wrap">
<StarterPlanCard />
<PersonalPlanCard billingPeriod={billingPeriod} />
</div>
<div className="flex-justify-center flex-wrap">
<ProfessionalPlanCard billingPeriod={billingPeriod} />
<BusinessPlanCard billingPeriod={billingPeriod} />
</div>
</div>
<div className="flex">
<ContactCard
email="[email protected]"
subject="Subscription inquiries"
/>
</div>
</div>
</div>
</main>
Expand Down
Loading

0 comments on commit 0c9816b

Please sign in to comment.