Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frontend/src/layout/GlobalModals.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { actions, kea, path, reducers, useActions, useValues } from 'kea'
import { useEffect } from 'react'

import { ConfirmUpgradeModal } from 'lib/components/ConfirmUpgradeModal/ConfirmUpgradeModal'
import { ItemSelectModal } from 'lib/components/FileSystem/ItemSelectModal/ItemSelectModal'
import { LinkToModal } from 'lib/components/FileSystem/LinkTo/LinkTo'
import { MoveToModal } from 'lib/components/FileSystem/MoveTo/MoveTo'
Expand Down Expand Up @@ -100,7 +99,6 @@ export function GlobalModals(): JSX.Element {
<CreateProjectModal isVisible={isCreateProjectModalShown} onClose={hideCreateProjectModal} />
<CreateEnvironmentModal isVisible={isCreateEnvironmentModalShown} onClose={hideCreateEnvironmentModal} />
<UpgradeModal />
<ConfirmUpgradeModal />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can remove this because it may be used in onboarding so it needs to be mounted here. You should confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checked, the global ConfirmUpgradeModal is not used anymore.
Upgrade flow in the onboarding goes like this:

  • OnboardingUpgradeStep renders PlanCards
  • "Unlock all features"click on PlanCards calls startPaymentEntryFlow (payment modal)

<TimeSensitiveAuthenticationModal />
<SessionPlayerModal />
<PreviewingCustomCssModal />
Expand Down

This file was deleted.

This file was deleted.

6 changes: 6 additions & 0 deletions frontend/src/scenes/billing/BillingProductAddon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { BillingProductV2AddonType } from '~/types'

import { BillingAddonFeaturesList } from './BillingAddonFeaturesList'
import { BillingProductAddonActions } from './BillingProductAddonActions'
import { ConfirmDowngradeModal } from './ConfirmDowngradeModal'
import { ConfirmUpgradeModal } from './ConfirmUpgradeModal'
import { ProductPricingModal } from './ProductPricingModal'
import { TrialCancellationSurveyModal } from './TrialCancellationSurveyModal'
import { UnsubscribeSurveyModal } from './UnsubscribeSurveyModal'
Expand Down Expand Up @@ -165,6 +167,10 @@ export const BillingProductAddon = ({ addon }: { addon: BillingProductV2AddonTyp
{surveyID === UNSUBSCRIBE_SURVEY_ID && <UnsubscribeSurveyModal product={addon} />}
{/* Trial cancellation survey modal */}
{surveyID === TRIAL_CANCELLATION_SURVEY_ID && <TrialCancellationSurveyModal product={addon} />}
{/* Confirm platform addon subscription upgrade */}
<ConfirmUpgradeModal product={addon} />
{/* Confirm platform addon subscription downgrade */}
<ConfirmDowngradeModal product={addon} />
</div>
)
}
54 changes: 7 additions & 47 deletions frontend/src/scenes/billing/BillingProductAddonActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useActions, useValues } from 'kea'
import { useMemo } from 'react'

import { IconCheckCircle, IconPlus } from '@posthog/icons'
import { LemonButton, LemonButtonProps, LemonTag, Tooltip } from '@posthog/lemon-ui'
Expand All @@ -13,7 +12,6 @@ import { toSentenceCase } from 'lib/utils'
import { BillingProductV2AddonType } from '~/types'

import { formatFlatRate } from './BillingProductAddon'
import { getProration } from './billing-utils'
import { billingLogic } from './billingLogic'
import { billingProductLogic } from './billingProductLogic'
import { DATA_PIPELINES_CUTOFF_DATE } from './constants'
Expand All @@ -31,15 +29,7 @@ export const BillingProductAddonActions = ({
buttonSize,
ctaTextOverride,
}: BillingProductAddonActionsProps): JSX.Element => {
const {
billing,
billingError,
switchPlanLoading,
timeTotalInSeconds,
timeRemainingInSeconds,
currentPlatformAddon,
} = useValues(billingLogic)
const { switchFlatrateSubscriptionPlan } = useActions(billingLogic)
const { billing, billingError, currentPlatformAddon } = useValues(billingLogic)
const { featureFlags } = useValues(featureFlagLogic)
const {
currentAndUpgradePlans,
Expand All @@ -48,21 +38,14 @@ export const BillingProductAddonActions = ({
isSubscribedToAnotherAddon,
isDataPipelinesDeprecated,
isLowerTierThanCurrentAddon,
proratedAmount,
isProrated,
} = useValues(billingProductLogic({ product: addon, productRef }))

const { toggleIsPricingModalOpen, reportSurveyShown, setSurveyResponse, initiateProductUpgrade, activateTrial } =
useActions(billingProductLogic({ product: addon }))
const { showConfirmUpgradeModal, showConfirmDowngradeModal } = useActions(billingProductLogic({ product: addon }))
const upgradePlan = currentAndUpgradePlans?.upgradePlan
const { prorationAmount, isProrated } = useMemo(
() =>
getProration({
timeRemainingInSeconds,
timeTotalInSeconds,
amountUsd: upgradePlan?.unit_amount_usd,
hasActiveSubscription: billing?.has_active_subscription,
}),
[billing?.has_active_subscription, upgradePlan, timeRemainingInSeconds, timeTotalInSeconds]
)
const isTrialEligible = !!addon.trial
const isSwitchPlanEnabled = !!featureFlags[FEATURE_FLAGS.SWITCH_SUBSCRIPTION_PLAN]

Expand Down Expand Up @@ -198,7 +181,7 @@ export const BillingProductAddonActions = ({
if (isProrated && !isSubscribedToAnotherAddon) {
return (
<p className="mt-2 text-xs text-secondary text-right">
Pay ~${prorationAmount} today (prorated) and
Pay ~${proratedAmount.toFixed(2)} today (prorated) and
<br />
{formatFlatRate(Number(upgradePlan?.unit_amount_usd), upgradePlan?.unit)} every month thereafter.
</p>
Expand All @@ -216,19 +199,7 @@ export const BillingProductAddonActions = ({
return (
<More
overlay={
<LemonButton
fullWidth
loading={switchPlanLoading === addon.type}
// TODO: Show confirmation modal with AddonFeatureLossNotice
onClick={() =>
switchFlatrateSubscriptionPlan({
from_product_key: String(currentPlatformAddon?.type),
from_plan_key: String(currentPlatformAddon?.plans[0].plan_key),
to_product_key: addon.type,
to_plan_key: String(upgradePlan?.plan_key),
})
}
>
<LemonButton fullWidth onClick={() => showConfirmDowngradeModal()}>
Downgrade
</LemonButton>
}
Expand All @@ -251,18 +222,7 @@ export const BillingProductAddonActions = ({
</h4>
)}

<LemonButton
type="primary"
loading={switchPlanLoading === addon.type}
onClick={() =>
switchFlatrateSubscriptionPlan({
from_product_key: String(currentPlatformAddon?.type),
from_plan_key: String(currentPlatformAddon?.plans[0].plan_key),
to_product_key: addon.type,
to_plan_key: String(upgradePlan?.plan_key),
})
}
>
<LemonButton type="primary" onClick={() => showConfirmUpgradeModal()}>
Upgrade
</LemonButton>
</>
Expand Down
Loading