The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix: standardize billing price display to integers when necessary (#17445)
Praise3188fb5295e2
diff --git a/packages/twenty-front/src/modules/billing/components/SubscriptionPrice.tsx b/packages/twenty-front/src/modules/billing/components/SubscriptionPrice.tsxindex bfe183ded5b..f2eaa95eb73 100644--- a/packages/twenty-front/src/modules/billing/components/SubscriptionPrice.tsx+++ b/packages/twenty-front/src/modules/billing/components/SubscriptionPrice.tsx@@ -20,10 +20,20 @@ const StyledPriceUnitSpan = styled.span`font-weight: ${({ theme }) => theme.font.weight.medium};`;+const formatYearlyPriceToMonthly = (price: number): number => {+ const monthlyPrice = price / 12;++ return Number.isInteger(monthlyPrice)+ ? monthlyPrice+ : Number(monthlyPrice.toFixed(2));+};+export const SubscriptionPrice = ({ type, price }: SubscriptionPriceProps) => {const { t } = useLingui();const pricePerSeat =- type === SubscriptionInterval.Year ? (price / 12).toFixed(2) : price;+ type === SubscriptionInterval.Year+ ? formatYearlyPriceToMonthly(price)+ : price;let priceUnit = '';switch (type) {diff --git a/packages/twenty-front/src/pages/onboarding/internal/ChooseYourPlanContent.tsx b/packages/twenty-front/src/pages/onboarding/internal/ChooseYourPlanContent.tsxindex d37ef5b2cc4..a227986e437 100644--- a/packages/twenty-front/src/pages/onboarding/internal/ChooseYourPlanContent.tsx+++ b/packages/twenty-front/src/pages/onboarding/internal/ChooseYourPlanContent.tsx@@ -6,11 +6,14 @@ import { billingCheckoutSessionState } from '@/auth/states/billingCheckoutSessioimport { SubscriptionBenefit } from '@/billing/components/SubscriptionBenefit';import { SubscriptionPrice } from '@/billing/components/SubscriptionPrice';import { TrialCard } from '@/billing/components/TrialCard';+import { useBaseLicensedPriceByPlanKeyAndInterval } from '@/billing/hooks/useBaseLicensedPriceByPlanKeyAndInterval';+import { useBaseProductByPlanKey } from '@/billing/hooks/useBaseProductByPlanKey';import { useHandleCheckoutSession } from '@/billing/hooks/useHandleCheckoutSession';import { calendarBookingPageIdState } from '@/client-config/states/calendarBookingPageIdState';import styled from '@emotion/styled';import { Trans, useLingui } from '@lingui/react/macro';import { useRecoilState, useRecoilValue } from 'recoil';+import { AppPath } from 'twenty-shared/types';import { isDefined } from 'twenty-shared/utils';import { Loader } from 'twenty-ui/feedback';import { CardPicker, MainButton } from 'twenty-ui/input';@@ -21,9 +24,6 @@ import {} from 'twenty-ui/navigation';import { BillingPlanKey } from '~/generated-metadata/graphql';import { type Billing } from '~/generated/graphql';-import { AppPath } from 'twenty-shared/types';-import { useBaseProductByPlanKey } from '@/billing/hooks/useBaseProductByPlanKey';-import { useBaseLicensedPriceByPlanKeyAndInterval } from '@/billing/hooks/useBaseLicensedPriceByPlanKeyAndInterval';const StyledSubscriptionContainer = styled.div<{withLongerMarginBottom: boolean;