diff --git a/packages/types/src/payment.d.ts b/packages/types/src/payment.d.ts index bbf6d1327c..579c2e37db 100644 --- a/packages/types/src/payment.d.ts +++ b/packages/types/src/payment.d.ts @@ -14,6 +14,7 @@ export type IPaymentProduct = { id: string; name: string; type: Omit; + payment_quantity: number; prices: IPaymentProductPrice[]; }; diff --git a/web/app/upgrade/pro/cloud/[selectedWorkspace]/page.tsx b/web/app/upgrade/pro/cloud/[selectedWorkspace]/page.tsx index b1ba5e2716..966fc602e8 100644 --- a/web/app/upgrade/pro/cloud/[selectedWorkspace]/page.tsx +++ b/web/app/upgrade/pro/cloud/[selectedWorkspace]/page.tsx @@ -12,11 +12,9 @@ import { Button, Loader, setToast, TOAST_TYPE } from "@plane/ui"; // helpers import { cn } from "@/helpers/common.helper"; // services -import { WorkspaceService } from "@/plane-web/services"; import { PaymentService } from "@/plane-web/services/payment.service"; const paymentService = new PaymentService(); -const workspaceService = new WorkspaceService(); const calculateYearlyDiscount = (monthlyPrice: number, yearlyPricePerMonth: number): number => { const monthlyCost = monthlyPrice * 12; @@ -39,13 +37,6 @@ const CloudUpgradePlanPage = observer(() => { const { selectedWorkspace: workspaceSlug } = useParams(); - // fetch workspace members - const { data: workspaceMembers, isLoading: isFetching } = useSWR( - workspaceSlug ? `CLOUD_PRO_WORKSPACE_MEMBER_DETAILS` : null, - workspaceSlug ? () => workspaceService.fetchWorkspaceMembers(workspaceSlug.toString()) : null, - { revalidateIfStale: false, revalidateOnFocus: false } - ); - // fetch products const { data: products, isLoading: isLoadingProduct } = useSWR( workspaceSlug ? `CLOUD_PRO_PRODUCTS_${workspaceSlug?.toString()}` : null, @@ -58,11 +49,10 @@ const CloudUpgradePlanPage = observer(() => { ); // derived values - const totalWorkspaceMembers = (workspaceMembers || [])?.filter((member) => member.role >= 15)?.length; const proProduct = (products || [])?.find((product: IPaymentProduct) => product?.type === "PRO"); - const monthlyPlan = proProduct?.prices?.find((price) => price.recurring === "month"); const yearlyPlan = proProduct?.prices?.find((price) => price.recurring === "year"); + const totalPaidMembers = proProduct?.payment_quantity ?? 1; const monthlyPlanUnitPrice = (monthlyPlan?.unit_amount || 0) / 100; const yearlyPlanUnitPrice = (yearlyPlan?.unit_amount || 0) / 1200; @@ -108,7 +98,7 @@ const CloudUpgradePlanPage = observer(() => { )} - {isFetching || isLoadingProduct ? ( + {isLoadingProduct ? (
@@ -137,13 +127,13 @@ const CloudUpgradePlanPage = observer(() => { {plan.recurring === selectedPlan?.recurring && }
- {totalWorkspaceMembers && ( + {totalPaidMembers && (
${renderPlanPricing(plan.unit_amount, 1, plan.recurring)} - {` per user per ${plan.recurring} x ${totalWorkspaceMembers}`} + {` per user per ${plan.recurring} x ${totalPaidMembers}`}
)} @@ -153,9 +143,9 @@ const CloudUpgradePlanPage = observer(() => {
- {totalWorkspaceMembers && ( + {totalPaidMembers && ( - ${renderPlanPricing(plan.unit_amount, totalWorkspaceMembers, plan.recurring)} + ${renderPlanPricing(plan.unit_amount, totalPaidMembers, plan.recurring)} )} @@ -172,7 +162,7 @@ const CloudUpgradePlanPage = observer(() => { ) : (