From 4fbc6656709e04c8166f526b8d2b28b771b4e661 Mon Sep 17 00:00:00 2001 From: Rishabh Mishra Date: Fri, 26 Jul 2024 15:04:02 +0530 Subject: [PATCH] fix: hide undefined base plan (#687) --- .../core/react/components/organization/plans/index.tsx | 2 +- sdks/js/packages/core/react/contexts/FrontierContext.tsx | 6 +++--- sdks/js/packages/core/react/utils/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdks/js/packages/core/react/components/organization/plans/index.tsx b/sdks/js/packages/core/react/components/organization/plans/index.tsx index 3ffb699a3..55e8ce728 100644 --- a/sdks/js/packages/core/react/components/organization/plans/index.tsx +++ b/sdks/js/packages/core/react/components/organization/plans/index.tsx @@ -153,7 +153,7 @@ export default function Plans() { client?.frontierServiceListFeatures() ]); if (planResp?.data?.plans) { - setPlans([...[basePlan || {}], ...planResp?.data?.plans]); + setPlans([...(basePlan ? [basePlan] : []), ...planResp?.data?.plans]); } if (featuresResp?.data?.features) { setFeatures(featuresResp?.data?.features); diff --git a/sdks/js/packages/core/react/contexts/FrontierContext.tsx b/sdks/js/packages/core/react/contexts/FrontierContext.tsx index 386e888ba..1d790aabd 100644 --- a/sdks/js/packages/core/react/contexts/FrontierContext.tsx +++ b/sdks/js/packages/core/react/contexts/FrontierContext.tsx @@ -34,7 +34,7 @@ import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_SHORT_FORMAT } from '../utils/constants'; -import { BasePlan } from '~/src/types'; + interface FrontierContextProviderProps { config: FrontierClientOptions; client: V1Beta1 | undefined; @@ -93,7 +93,7 @@ interface FrontierContextProviderProps { paymentMethod: V1Beta1PaymentMethod | undefined; - basePlan?: BasePlan; + basePlan?: V1Beta1Plan; } const defaultConfig: FrontierClientOptions = { @@ -205,7 +205,7 @@ export const FrontierContextProvider = ({ const [activePlan, setActivePlan] = useState(); const [isActivePlanLoading, setIsActivePlanLoading] = useState(false); - const [basePlan, setBasePlan] = useState(); + const [basePlan, setBasePlan] = useState(); useEffect(() => { async function getFrontierInformation() { diff --git a/sdks/js/packages/core/react/utils/index.ts b/sdks/js/packages/core/react/utils/index.ts index 3ddef436e..6f11ed067 100644 --- a/sdks/js/packages/core/react/utils/index.ts +++ b/sdks/js/packages/core/react/utils/index.ts @@ -159,7 +159,7 @@ export function getDefaultPaymentMethod( return defaultMethod ? defaultMethod : paymentMethods[0]; } -export const enrichBasePlan = (plan?: BasePlan): BasePlan | undefined => { +export const enrichBasePlan = (plan?: BasePlan): V1Beta1Plan | undefined => { const features = Object.entries(plan?.features || {}).map(([key, value]) => { return { title: key,