-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor upgrade details to separate concerns between different…
… upgrade plan options (#2376)
- Loading branch information
1 parent
da495ce
commit 094c204
Showing
11 changed files
with
959 additions
and
643 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...pages/PlanPage/subRoutes/UpgradePlanPage/UpgradeDetails/ProPlanDetails/ProPlanDetails.jsx
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,67 @@ | ||
import { useParams } from 'react-router-dom' | ||
|
||
import { | ||
useAccountDetails, | ||
useAvailablePlans, | ||
usePlanData, | ||
} from 'services/account' | ||
import BenefitList from 'shared/plan/BenefitList' | ||
import ScheduledPlanDetails from 'shared/plan/ScheduledPlanDetails' | ||
import { useProPlans } from 'shared/utils/billing' | ||
import { shouldRenderCancelLink } from 'shared/utils/upgradeForm' | ||
import A from 'ui/A' | ||
import Icon from 'ui/Icon' | ||
|
||
function ProPlanDetails() { | ||
const { provider, owner } = useParams() | ||
const { data: planData } = usePlanData({ provider, owner }) | ||
const { data: accountDetails } = useAccountDetails({ provider, owner }) | ||
const { data: plans } = useAvailablePlans({ provider, owner }) | ||
const { proPlanMonth, proPlanYear } = useProPlans({ plans }) | ||
|
||
const plan = accountDetails?.rootOrganization?.plan ?? accountDetails?.plan | ||
const scheduledPhase = accountDetails?.scheduleDetail?.scheduledPhase | ||
|
||
const cancelAtPeriodEnd = | ||
accountDetails?.subscriptionDetail?.cancelAtPeriodEnd | ||
const trialStatus = planData?.plan?.trialStatus | ||
|
||
return ( | ||
<div className="h-fit border"> | ||
<h3 className="p-4 font-semibold">{proPlanYear?.marketingName} plan</h3> | ||
<hr /> | ||
<div className="flex flex-col gap-4 p-4"> | ||
<BenefitList | ||
iconName="check" | ||
iconColor="text-ds-pink-quinary" | ||
benefits={proPlanYear?.benefits} | ||
/> | ||
<div> | ||
<p className="text-xs font-semibold"> | ||
<span className="text-2xl">${proPlanYear?.baseUnitPrice}</span> | ||
/per user, per month | ||
</p> | ||
<p className="text-xs text-ds-gray-quaternary"> | ||
billed annually or ${proPlanMonth?.baseUnitPrice} for monthly | ||
billing | ||
</p> | ||
</div> | ||
{scheduledPhase && ( | ||
<ScheduledPlanDetails scheduledPhase={scheduledPhase} /> | ||
)} | ||
{shouldRenderCancelLink(cancelAtPeriodEnd, plan, trialStatus) && ( | ||
<A | ||
to={{ pageName: 'cancelOrgPlan' }} | ||
variant="black" | ||
hook="cancel-plan" | ||
> | ||
Cancel | ||
<Icon name="chevronRight" size="sm" variant="solid" /> | ||
</A> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ProPlanDetails |
Oops, something went wrong.