1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-17 09:59:41 +00:00
Files
browser/libs/common/src/billing/models/response/organization-subscription.response.ts
cyprain-okeke 7989ad7b7c [PM-26682] [Milestone 2d] Display discount on subscription page (#17229)
* The discount badge implementation

* Use existing flag

* Added the top spaces as requested

* refactor: move discount-badge to pricing library and consolidate discount classes

* fix: add CommonModule import to discount-badge component and simplify discounted amount calculation

- Add CommonModule import to discount-badge component for *ngIf directive
- Simplify discountedSubscriptionAmount to use upcomingInvoice.amount from server instead of manual calculation

* Fix the lint errors

* Story update

---------

Co-authored-by: Alex Morask <amorask@bitwarden.com>
2025-11-12 20:38:13 +01:00

55 lines
2.1 KiB
TypeScript

// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { OrganizationResponse } from "../../../admin-console/models/response/organization.response";
import { BaseResponse } from "../../../models/response/base.response";
import {
BillingSubscriptionResponse,
BillingSubscriptionUpcomingInvoiceResponse,
} from "./subscription.response";
export class OrganizationSubscriptionResponse extends OrganizationResponse {
storageName: string;
storageGb: number;
subscription: BillingSubscriptionResponse;
upcomingInvoice: BillingSubscriptionUpcomingInvoiceResponse;
customerDiscount: BillingCustomerDiscount;
expiration: string;
expirationWithoutGracePeriod: string;
constructor(response: any) {
super(response);
this.storageName = this.getResponseProperty("StorageName");
this.storageGb = this.getResponseProperty("StorageGb");
const subscription = this.getResponseProperty("Subscription");
this.subscription = subscription == null ? null : new BillingSubscriptionResponse(subscription);
const upcomingInvoice = this.getResponseProperty("UpcomingInvoice");
this.upcomingInvoice =
upcomingInvoice == null
? null
: new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
const customerDiscount = this.getResponseProperty("CustomerDiscount");
this.customerDiscount =
customerDiscount == null ? null : new BillingCustomerDiscount(customerDiscount);
this.expiration = this.getResponseProperty("Expiration");
this.expirationWithoutGracePeriod = this.getResponseProperty("ExpirationWithoutGracePeriod");
}
}
export class BillingCustomerDiscount extends BaseResponse {
id: string;
active: boolean;
percentOff?: number;
amountOff?: number;
appliesTo: string[];
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.active = this.getResponseProperty("Active");
this.percentOff = this.getResponseProperty("PercentOff");
this.amountOff = this.getResponseProperty("AmountOff");
this.appliesTo = this.getResponseProperty("AppliesTo") || [];
}
}