-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(18228): add pricing page to atlas app (#770)
* feat(18228): add pricing page --------- Co-authored-by: Natallia Harshunova <[email protected]>
- Loading branch information
1 parent
60b43bb
commit bbfd01b
Showing
19 changed files
with
558 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { apiClient } from '~core/apiClientInstance'; | ||
import { configRepo } from '~core/config'; | ||
|
||
export type CurrentSubscription = { | ||
id: string; | ||
billingPlanId: string; | ||
billingSubscriptionId: string; | ||
}; | ||
|
||
export async function getCurrentUserSubscription() { | ||
return await apiClient.get<CurrentSubscription | null>( | ||
'/users/current_user/billing_subscription', | ||
{ appId: configRepo.get().id }, | ||
true, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/features/subscriptions/components/PaymentPlanButton/PaymentPlanButton.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.paymentPlanButton { | ||
background-color: var(--strong-color); | ||
|
||
--subscribe-btn-hover: #269b00; | ||
|
||
&:global(.premium) { | ||
--subscribe-btn-hover: var(--accent-strong-up); | ||
} | ||
|
||
&:hover { | ||
background-color: var(--subscribe-btn-hover); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/features/subscriptions/components/PaymentPlanButton/PaymentPlanButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Button } from '@konturio/ui-kit'; | ||
import React, { memo } from 'react'; | ||
import clsx from 'clsx'; | ||
import { i18n } from '~core/localization'; | ||
import s from './PaymentPlanButton.module.css'; | ||
import type { CurrentSubscription } from '~core/api/subscription'; | ||
import type { PaymentPlan } from '~features/subscriptions/types'; | ||
|
||
export type PaymentPlanButtonProps = { | ||
plan: PaymentPlan; | ||
isUserAuthorized: boolean; | ||
onUnauthorizedUserClick: () => void; | ||
currentSubscription: CurrentSubscription | null; | ||
style: string; | ||
}; | ||
|
||
const PaymentPlanButton = memo(function PaymentPlanButton({ | ||
plan, | ||
isUserAuthorized, | ||
onUnauthorizedUserClick, | ||
currentSubscription, | ||
style, | ||
}: PaymentPlanButtonProps) { | ||
if (!isUserAuthorized) { | ||
return ( | ||
<Button | ||
className={clsx(s.paymentPlanButton, style)} | ||
onClick={onUnauthorizedUserClick} | ||
> | ||
{i18n.t('subscription.unauthorized_button')} | ||
</Button> | ||
); | ||
} | ||
if (plan.id === currentSubscription?.id) { | ||
return <Button disabled>{i18n.t('subscription.current_plan_button')}</Button>; | ||
} | ||
return <Button className={s.paymentPlanButton}>Subscribe</Button>; | ||
}); | ||
|
||
export default PaymentPlanButton; |
99 changes: 99 additions & 0 deletions
99
src/features/subscriptions/components/PaymentPlanCard/PaymentPlanCard.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
.planCard { | ||
border: 1px solid var(--faint-weak-up, #d2d5d8); | ||
border-radius: var(--double-unit, 16px); | ||
padding: 48px 40px 24px; | ||
height: 578px; | ||
max-width: 400px; | ||
min-width: 220px; | ||
display: flex; | ||
position: relative; | ||
flex-direction: column; | ||
|
||
--strong-color: var(--success-strong); | ||
--plan-type-bg-color: #def5df; | ||
|
||
&:global(.premium) { | ||
--strong-color: var(--accent-strong); | ||
--plan-type-bg-color: #d8effc; | ||
|
||
background-color: var(--accent-weak); | ||
border-color: var(--strong-color); | ||
} | ||
} | ||
|
||
.planIcon { | ||
margin-right: var(--unit); | ||
} | ||
|
||
.planName { | ||
position: absolute; | ||
padding: var(--unit) var(--double-unit); | ||
border-radius: 18px; | ||
right: 40px; | ||
top: -18px; | ||
background-color: var(--plan-type-bg-color); | ||
color: var(--strong-color); | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.initialPrice { | ||
color: var(--faint-strong, #9ea5ab); | ||
text-decoration: line-through; | ||
margin-bottom: var(--double-unit); | ||
} | ||
|
||
.price { | ||
margin-bottom: var(--double-unit); | ||
} | ||
|
||
.perMonth { | ||
font-size: 14px; | ||
color: #888; | ||
margin-left: 5px; | ||
} | ||
|
||
.planDescription { | ||
color: var(--faint-strong); | ||
margin-bottom: var(--double-unit); | ||
} | ||
|
||
.buttonWrapper { | ||
margin-bottom: 24px; | ||
} | ||
|
||
.cancelButton { | ||
position: relative; | ||
bottom: -11px; | ||
} | ||
|
||
.highlights { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
|
||
& li { | ||
margin: 5px 0; | ||
} | ||
} | ||
|
||
.highlight { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.highlightIcon { | ||
margin-right: var(--double-unit); | ||
color: var(--strong-color); | ||
} | ||
|
||
.footerWrapper { | ||
display: flex; | ||
justify-content: flex-end; | ||
margin-top: auto; | ||
color: var(--faint-strong); | ||
|
||
& span { | ||
color: var(--faint-strong-down); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/features/subscriptions/components/PaymentPlanCard/PaymentPlanCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React, { memo, useMemo } from 'react'; | ||
import { Heading, Text } from '@konturio/ui-kit'; | ||
import { Finish24 } from '@konturio/default-icons'; | ||
import clsx from 'clsx'; | ||
import { Price } from '~features/subscriptions/components/Price/Price'; | ||
import PaymentPlanButton from '~features/subscriptions/components/PaymentPlanButton/PaymentPlanButton'; | ||
import PaymentPlanCardFooter from '~features/subscriptions/components/PaymentPlanCardFooter/PaymentPlanCardFooter'; | ||
import s from './PaymentPlanCard.module.css'; | ||
import { PLANS_STYLE_CONFIG } from './contants'; | ||
import type { PaymentPlan } from '~features/subscriptions/types'; | ||
import type { CurrentSubscription } from '~core/api/subscription'; | ||
|
||
export type PaymentPlanCardProps = { | ||
plan: PaymentPlan; | ||
currentBillingCycleId: string; | ||
currentSubscription: CurrentSubscription | null; | ||
isUserAuthorized: boolean; | ||
onUnauthorizedUserClick: () => void; | ||
}; | ||
|
||
const PaymentPlanCard = memo(function PaymentPlanCard({ | ||
plan, | ||
currentBillingCycleId, | ||
currentSubscription, | ||
isUserAuthorized, | ||
onUnauthorizedUserClick, | ||
}: PaymentPlanCardProps) { | ||
const styleConfig = PLANS_STYLE_CONFIG[plan.style]; | ||
|
||
const billingOption = useMemo( | ||
() => plan.billingCycles.find((option) => option.id === currentBillingCycleId), | ||
[plan.billingCycles, currentBillingCycleId], | ||
); | ||
|
||
return ( | ||
<div className={clsx(s.planCard, styleConfig.className)}> | ||
<div className={s.planName}> | ||
{styleConfig.icon()} | ||
<Heading type="heading-04" margins={false}> | ||
{plan.name} | ||
</Heading> | ||
</div> | ||
{billingOption?.initialPricePerMonth && ( | ||
<div className={s.initialPrice}>${billingOption.initialPricePerMonth}</div> | ||
)} | ||
{billingOption?.pricePerMonth && ( | ||
<Price className={s.price} amount={billingOption.pricePerMonth} /> | ||
)} | ||
<Text className={s.planDescription} type="short-m"> | ||
{plan.description} | ||
</Text> | ||
<div className={s.buttonWrapper}> | ||
<PaymentPlanButton | ||
plan={plan} | ||
isUserAuthorized={isUserAuthorized} | ||
onUnauthorizedUserClick={onUnauthorizedUserClick} | ||
currentSubscription={currentSubscription} | ||
style={styleConfig.className} | ||
/> | ||
</div> | ||
<ul className={s.highlights}> | ||
{plan.highlights.map((highlight, index) => ( | ||
<li key={index} className={s.highlight}> | ||
<Finish24 className={s.highlightIcon} /> | ||
<span>{highlight}</span> | ||
</li> | ||
))} | ||
</ul> | ||
|
||
<div className={s.footerWrapper}> | ||
<PaymentPlanCardFooter | ||
plan={plan} | ||
isUserAuthorized={isUserAuthorized} | ||
currentSubscription={currentSubscription} | ||
billingOption={billingOption} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
export default PaymentPlanCard; |
14 changes: 14 additions & 0 deletions
14
src/features/subscriptions/components/PaymentPlanCard/contants.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { FavAdded16 } from '@konturio/default-icons'; | ||
import s from './PaymentPlanCard.module.css'; | ||
|
||
export const PLANS_STYLE_CONFIG = { | ||
basic: { | ||
className: '', // Uses default styles | ||
icon: () => null, | ||
}, | ||
premium: { | ||
className: 'premium', | ||
icon: () => <FavAdded16 className={s.planIcon} />, | ||
}, | ||
}; |
Oops, something went wrong.