Skip to content

Commit

Permalink
more plan logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Grato committed Dec 19, 2023
1 parent 0a10142 commit 3a97574
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 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,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 @@ -15,7 +15,7 @@ const BookMeeting = () => (
text="Book Now"
label="book meeting with team"
target="_blank"
href="https://calendly.com/mhmorran/onboarding "
href={href}
/>
</div>
</div>
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
23 changes: 19 additions & 4 deletions client/components/modules/side-panel/SupportGrid/SupportGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
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,
useIsBusiness,
useIsProfessional,
} from 'hooks/usePlans';
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';

const SupportGrid = () => {
const isStarter = useIsStarter();
const isProfessionalUp = useIsProfessionalUp();
const isBusiness = useIsBusiness();
const isProfessional = useIsProfessional();
const businessCal = 'https://calendly.com/mhmorran/onboarding/busi';
const professionalCal = 'https://calendly.com/mhmorran/onboarding/pers';

const meetingHref = () => {
let href = '';
if (isBusiness) href = businessCal;
if (isProfessional) href = professionalCal;
return href;
};

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

{isProfessionalUp && <BookMeeting href={meetingHref()} />}
<div className={styles.support_links}>
<SupportLink
title="Message Us"
Expand Down
6 changes: 4 additions & 2 deletions client/services/routeGuard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,16 @@ export function customClientRG(gssp: Function): GetServerSideProps | Redirect {
return async (context: GetServerSidePropsContext) => {
const { req } = context;

// Only these plans can see custom client screen
const approvedPlans = [PlansE.PROFESSIONAL, PlansE.BUSINESS];

// If no errors user is authenticated
try {
const account: AccountT = await getAccount(
req.headers as AxiosRequestHeaders
);

// only b1 can get to this page
if (account.planName !== PlansE.PROFESSIONAL) {
if (!approvedPlans.includes(account.planName as PlansE)) {
return redirectToDashboard();
}

Expand Down
1 change: 0 additions & 1 deletion lib/dash/plan_state_machine.ex
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ defmodule Dash.PlanStateMachine do
end

# BUSINESS PLAN

def handle_event(
nil,
{:subscribe_business, %DateTime{} = subscribed_at},
Expand Down

0 comments on commit 3a97574

Please sign in to comment.