mirror of
https://github.com/bitwarden/browser
synced 2026-02-05 11:13:44 +00:00
fix(billing): update unified upgrade logic
This commit is contained in:
@@ -1,26 +1,28 @@
|
||||
@if (step() == PlanSelectionStep) {
|
||||
@if (hasPremiumPersonally() && premiumToOrganizationUpgradeEnabled()) {
|
||||
<!-- Premium-to-Organization upgrade flow: User already has premium personally and is upgrading to Teams/Enterprise -->
|
||||
@if (showPremiumOrgFlow()) {
|
||||
@if (step() == PlanSelectionStep) {
|
||||
<app-premium-org-upgrade
|
||||
(planSelected)="onPlanSelected($event)"
|
||||
(closeClicked)="onCloseClicked()"
|
||||
/>
|
||||
} @else {
|
||||
<app-upgrade-account
|
||||
[dialogTitleMessageOverride]="planSelectionStepTitleOverride()"
|
||||
[hideContinueWithoutUpgradingButton]="hideContinueWithoutUpgradingButton()"
|
||||
(planSelected)="onPlanSelected($event)"
|
||||
(closeClicked)="onCloseClicked()"
|
||||
/>
|
||||
}
|
||||
} @else if (step() == PaymentStep && selectedPlan() !== null && account() !== null) {
|
||||
@if (hasPremiumPersonally()) {
|
||||
} @else if (step() == PaymentStep && selectedPlan() !== null && account() !== null) {
|
||||
<app-premium-org-upgrade-payment
|
||||
[selectedPlanId]="selectedPlan()"
|
||||
[account]="account()"
|
||||
(goBack)="previousStep()"
|
||||
(complete)="onComplete($event)"
|
||||
/>
|
||||
} @else {
|
||||
}
|
||||
} @else {
|
||||
<!-- Standard upgrade flow: User upgrading from free to Premium or Families -->
|
||||
@if (step() == PlanSelectionStep) {
|
||||
<app-upgrade-account
|
||||
[dialogTitleMessageOverride]="planSelectionStepTitleOverride()"
|
||||
[hideContinueWithoutUpgradingButton]="hideContinueWithoutUpgradingButton()"
|
||||
(planSelected)="onPlanSelected($event)"
|
||||
(closeClicked)="onCloseClicked()"
|
||||
/>
|
||||
} @else if (step() == PaymentStep && selectedPlan() !== null && account() !== null) {
|
||||
<app-upgrade-payment
|
||||
[selectedPlanId]="selectedPersonalPlanId()"
|
||||
[account]="account()"
|
||||
|
||||
@@ -544,6 +544,7 @@ describe("UnifiedUpgradeDialogComponent", () => {
|
||||
|
||||
it("should display app-premium-org-upgrade-payment when user has premium personally", async () => {
|
||||
mockBillingAccountProfileStateService.hasPremiumPersonally$.mockReturnValue(of(true));
|
||||
mockConfigService.getFeatureFlag$.mockReturnValue(of(true));
|
||||
|
||||
const customDialogData: UnifiedUpgradeDialogParams = {
|
||||
account: mockAccount,
|
||||
|
||||
@@ -116,12 +116,13 @@ export class UnifiedUpgradeDialogComponent implements OnInit {
|
||||
this.billingAccountProfileStateService.hasPremiumPersonally$(this.params.account.id),
|
||||
{ initialValue: false },
|
||||
);
|
||||
|
||||
readonly premiumToOrganizationUpgradeEnabled = toSignal(
|
||||
protected readonly premiumToOrganizationUpgradeEnabled = toSignal(
|
||||
this.configService.getFeatureFlag$(FeatureFlag.PM29593_PremiumToOrganizationUpgrade),
|
||||
{ initialValue: false },
|
||||
);
|
||||
|
||||
protected readonly showPremiumOrgFlow = computed(
|
||||
() => this.hasPremiumPersonally() && this.premiumToOrganizationUpgradeEnabled(),
|
||||
);
|
||||
// Type-narrowed computed signal for app-upgrade-payment
|
||||
// When hasPremiumPersonally is false, selectedPlan will only contain PersonalSubscriptionPricingTierId
|
||||
protected readonly selectedPersonalPlanId = computed<PersonalSubscriptionPricingTierId | null>(
|
||||
|
||||
Reference in New Issue
Block a user