-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add mobile pricing plan (#3509)
- Loading branch information
Showing
10 changed files
with
318 additions
and
179 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
156 changes: 0 additions & 156 deletions
156
packages/frontend-2/components/settings/workspaces/billing/PricingTable.vue
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue
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 @@ | ||
<template> | ||
<table class="w-full flex flex-col"> | ||
<thead> | ||
<tr class="w-full flex"> | ||
<th class="w-1/4 flex pl-5 pr-6 pt-4 pb-2 font-medium"> | ||
<h4>Compare plans</h4> | ||
</th> | ||
<th | ||
v-for="plan in plans" | ||
:key="`desktop-${plan.name}`" | ||
class="w-1/4 px-6 pt-4 pb-2" | ||
:class="[ | ||
plan.name === WorkspacePlans.Team | ||
? 'border border-b-0 border-outline-3 bg-foundation-2 rounded-t-lg' | ||
: '' | ||
]" | ||
scope="col" | ||
> | ||
<SettingsWorkspacesBillingPricingTableHeader | ||
:plan="plan" | ||
:is-yearly-plan="isYearlyPlan" | ||
:current-plan="currentPlan" | ||
:workspace-id="workspaceId" | ||
:is-admin="isAdmin" | ||
/> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody class="w-full flex flex-col"> | ||
<tr v-for="(feature, key, index) in features" :key="key" class="flex"> | ||
<th | ||
class="font-normal text-foreground text-body-xs w-1/4 pr-3 pt-1" | ||
scope="row" | ||
> | ||
<div class="border-b border-outline-3 min-h-[42px] pl-5 flex items-center"> | ||
{{ feature.name }} | ||
</div> | ||
</th> | ||
<td | ||
v-for="plan in plans" | ||
:key="plan.name" | ||
class="px-3 w-1/4 pt-1" | ||
:class="[ | ||
plan.name === WorkspacePlans.Team | ||
? 'border-l border-r border-outline-3 bg-foundation-2' | ||
: '', | ||
plan.name === WorkspacePlans.Team && | ||
index === Object.values(features).length - 1 | ||
? 'pb-6 border-b rounded-b-lg' | ||
: '' | ||
]" | ||
> | ||
<div class="border-b border-outline-3 flex items-center px-3 min-h-[42px]"> | ||
<CheckIcon | ||
v-if="plan.features.includes(feature.name as PlanFeaturesList)" | ||
class="w-3 h-3 text-foreground" | ||
/> | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { WorkspacePlan } from '~/lib/common/generated/gql/graphql' | ||
import { WorkspacePlans } from '~/lib/common/generated/gql/graphql' | ||
import { pricingPlansConfig } from '~/lib/billing/helpers/constants' | ||
import type { PlanFeaturesList } from '~/lib/billing/helpers/types' | ||
import { CheckIcon } from '@heroicons/vue/24/outline' | ||
import type { MaybeNullOrUndefined } from '@speckle/shared' | ||
defineProps<{ | ||
isYearlyPlan: boolean | ||
currentPlan: MaybeNullOrUndefined<WorkspacePlan> | ||
workspaceId: string | ||
isAdmin: boolean | ||
}>() | ||
const plans = ref(pricingPlansConfig.plans) | ||
const features = ref(pricingPlansConfig.features) | ||
</script> |
79 changes: 79 additions & 0 deletions
79
packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue
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,79 @@ | ||
<template> | ||
<div class="flex flex-col gap-y-1 font-normal"> | ||
<h4 class="text-foreground text-body-xs"> | ||
Workspace | ||
<span class="capitalize">{{ plan.name }}</span> | ||
</h4> | ||
<p class="text-foreground text-heading"> | ||
£{{ | ||
isYearlyPlan | ||
? plan.cost.yearly[Roles.Workspace.Member] | ||
: plan.cost.monthly[Roles.Workspace.Member] | ||
}} | ||
per seat/month | ||
</p> | ||
<p class="text-foreground-2 text-body-2xs pt-1"> | ||
Billed {{ isYearlyPlan ? 'annually' : 'monthly' }} | ||
</p> | ||
<div class="w-full"> | ||
<FormButton | ||
:color="plan.name === WorkspacePlans.Team ? 'primary' : 'outline'" | ||
:disabled="(!hasTrialPlan && !canUpgradeToPlan) || !isAdmin" | ||
class="mt-3" | ||
full-width | ||
@click="onUpgradePlanClick(plan.name)" | ||
> | ||
{{ hasTrialPlan ? 'Subscribe' : 'Upgrade' }} to | ||
<span class="capitalize">{{ plan.name }}</span> | ||
</FormButton> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { type PricingPlan } from '@/lib/billing/helpers/types' | ||
import { Roles } from '@speckle/shared' | ||
import { | ||
type WorkspacePlan, | ||
WorkspacePlanStatuses, | ||
WorkspacePlans, | ||
BillingInterval | ||
} from '~/lib/common/generated/gql/graphql' | ||
import { useBillingActions } from '~/lib/billing/composables/actions' | ||
import type { MaybeNullOrUndefined } from '@speckle/shared' | ||
const props = defineProps<{ | ||
plan: PricingPlan | ||
isYearlyPlan: boolean | ||
currentPlan: MaybeNullOrUndefined<WorkspacePlan> | ||
workspaceId: string | ||
isAdmin: boolean | ||
}>() | ||
const { upgradePlanRedirect } = useBillingActions() | ||
const canUpgradeToPlan = computed(() => { | ||
if (!props.currentPlan) return false | ||
const allowedUpgrades: Record<WorkspacePlans, WorkspacePlans[]> = { | ||
[WorkspacePlans.Team]: [WorkspacePlans.Pro, WorkspacePlans.Business], | ||
[WorkspacePlans.Pro]: [WorkspacePlans.Business], | ||
[WorkspacePlans.Business]: [], | ||
[WorkspacePlans.Academia]: [], | ||
[WorkspacePlans.Unlimited]: [] | ||
} | ||
return allowedUpgrades[props.currentPlan.name].includes(props.plan.name) | ||
}) | ||
const hasTrialPlan = computed( | ||
() => props.currentPlan?.status === WorkspacePlanStatuses.Trial || !props.currentPlan | ||
) | ||
const onUpgradePlanClick = (plan: WorkspacePlans) => { | ||
upgradePlanRedirect({ | ||
plan, | ||
cycle: props.isYearlyPlan ? BillingInterval.Yearly : BillingInterval.Monthly, | ||
workspaceId: props.workspaceId | ||
}) | ||
} | ||
</script> |
Oops, something went wrong.