Skip to content

Commit

Permalink
Implement agency tier widget on Overview page
Browse files Browse the repository at this point in the history
  • Loading branch information
yashwin committed Oct 17, 2024
1 parent c88ea09 commit 5f18b06
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ import EmergingPartnerLogo from 'calypso/assets/images/a8c-for-agencies/agency-t
import ProAgencyPartnerLogo from 'calypso/assets/images/a8c-for-agencies/agency-tier/pro-agency-partner-logo-small.svg';
import { preventWidows } from 'calypso/lib/formatting';

interface AgencyTierInfo {
title: string;
fullTitle: string;
subtitle: string;
description: string;
logo: string;
includedTiers: string[];
emptyStateMessage?: string;
}

const getAgencyTierInfo = (
agencyTier: 'emerging-partner' | 'agency-partner' | 'pro-agency-partner',
translate: ( key: string, args?: Record< string, unknown > ) => string
) => {
let tierInfo = {
let tierInfo: AgencyTierInfo = {
title: '',
fullTitle: '',
subtitle: '',
description: '',
logo: '',
includedTiers: [] as string[],
emptyStateMessage: '',
};
switch ( agencyTier ) {
case 'emerging-partner':
Expand All @@ -31,8 +43,17 @@ const getAgencyTierInfo = (
'Your next tier milestone is when your influenced revenue exceeds %(amount)s',
{ args: { amount: '$1,200' }, comment: 'Amount of revenue' }
),
description: translate(
'Continue moving towards the next tier to unlock benefits by making more purchases and referrals.'
),
logo: EmergingPartnerLogo,
includedTiers: [ 'emerging-partner' ],
emptyStateMessage: translate(
'Make your first purchase to get started as an {{b}}Emerging Partner!{{/b}}',
{
components: { b: <b /> },
}
),
};
break;
case 'agency-partner':
Expand All @@ -54,6 +75,9 @@ const getAgencyTierInfo = (
comment: 'Amount of revenue',
}
),
description: translate(
"You're well on your way to becoming a Pro Agency Partner and unlocking even more premium benefits!"
),
logo: AgencyPartnerLogo,
includedTiers: [ 'emerging-partner', 'agency-partner' ],
};
Expand All @@ -71,6 +95,9 @@ const getAgencyTierInfo = (
}
),
subtitle: preventWidows( translate( "You've reached the highest tier!" ) ),
description: translate(
"You're the best of the best when it comes to agencies for WordPress! Enjoy your premium benefits!"
),
logo: ProAgencyPartnerLogo,
includedTiers: [ 'emerging-partner', 'agency-partner', 'pro-agency-partner' ],
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Card, FoldableCard } from '@automattic/components';
import { Button } from '@wordpress/components';
import { Icon, arrowRight } from '@wordpress/icons';
import { clsx } from 'clsx';
import { useTranslate } from 'i18n-calypso';
import { A4A_AGENCY_TIER_LINK } from 'calypso/a8c-for-agencies/components/sidebar-menu/lib/constants';
import getAgencyTierInfo from 'calypso/a8c-for-agencies/sections/agency-tier/lib/get-agency-tier-info';
import { useSelector } from 'calypso/state';
import { getActiveAgency } from 'calypso/state/a8c-for-agencies/agency/selectors';

import './style.scss';

export default function OverviewSidebarAgencyTier() {
const translate = useTranslate();

const agency = useSelector( getActiveAgency );

const currentAgencyTierInfo = agency?.tier?.id
? getAgencyTierInfo( agency.tier.id, translate )
: null;

const defaultAgencyTierInfo = getAgencyTierInfo( 'emerging-partner', translate );

return (
<Card className="agency-tier__card">
<FoldableCard
className="foldable-nav"
header={ translate( 'Your Agency Tier' ) }
expanded
compact
iconSize={ 18 }
>
<div className="agency-tier__bottom-content">
<div
className={ clsx( 'agency-tier__current-agency-tier-header', {
'is-default': ! currentAgencyTierInfo,
} ) }
>
{ currentAgencyTierInfo ? (
<>
<span className="agency-tier__current-agency-tier-icon">
<img src={ currentAgencyTierInfo.logo } alt={ currentAgencyTierInfo.id } />
</span>
<span className="agency-tier__current-agency-tier-title">
{ currentAgencyTierInfo.title }
</span>
</>
) : (
<>
<span className="agency-tier__current-agency-tier-icon">
<img src={ defaultAgencyTierInfo.logo } alt={ defaultAgencyTierInfo.id } />
</span>
<span className="agency-tier__current-agency-tier-title">
{ defaultAgencyTierInfo.emptyStateMessage }
</span>
</>
) }
</div>
{ currentAgencyTierInfo && (
<div className="agency-tier__current-agency-tier-description">
{ currentAgencyTierInfo.description }
</div>
) }
<Button href={ A4A_AGENCY_TIER_LINK }>
<Icon icon={ arrowRight } size={ 18 } />
{ translate( 'Explore tiers and benefits' ) }
</Button>
</div>
</FoldableCard>
</Card>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.agency-tier__card {
padding: 8px;
border-radius: 4px;

.foldable-card__header {
padding-inline: 12px;
}

.sidebar-v2__menu-item {
&:hover {
svg.sidebar-v2__external-icon {
color: var(--color-text-inverted);
}
}
}
}

.agency-tier__bottom-content {
padding-inline: 12px;

.agency-tier__current-agency-tier-header {
margin-inline-start: 8px;
padding-block: 16px 12px;
display: flex;
gap: 16px;

.agency-tier__current-agency-tier-icon img {
transform: scale(1.5);
}

.agency-tier__current-agency-tier-title {
@include a4a-font-heading-lg;
}

&.is-default {
margin-inline-start: 14px;
padding-block: 36px;
gap: 24px;

.agency-tier__current-agency-tier-icon {
display: flex;
width: 80px;

img {
transform: scale(1.6);
}
}

.agency-tier__current-agency-tier-title {
@include a4a-font-body-lg;
}
}
}

.agency-tier__current-agency-tier-description {
@include a4a-font-body-md;
padding-block-end: 8px;
}
}

.foldable-nav.foldable-card.card .foldable-card__content .agency-tier__bottom-content a.components-button {
@include a4a-font-body-md;
padding: 0;
color: var(--color-gray-40);

svg {
margin-inline-end: 8px;
}

&:hover {
background: none;
box-shadow: none;
}
}
3 changes: 3 additions & 0 deletions client/a8c-for-agencies/sections/overview/sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { isEnabled } from '@automattic/calypso-config';
import OverviewSidebarAgencyTier from './agency-tier';
import OverviewSidebarContactSupport from './contact-support';
import OverviewSidebarGrowthAccelerator from './growth-accelerator';
import OverviewSidebarQuickLinks from './quick-links';

const OverviewSidebar = () => {
return (
<div className="overview-sidebar">
{ isEnabled( 'a8c-for-agencies-agency-tier' ) && <OverviewSidebarAgencyTier /> }
<OverviewSidebarQuickLinks />
<OverviewSidebarGrowthAccelerator />
<OverviewSidebarContactSupport />
Expand Down

0 comments on commit 5f18b06

Please sign in to comment.