1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00

[PM-18955] Use OrganizationWarningsService on AC Collections Page behind FF (#14437)

* Add getWarnings to OrganizationBillingApiService

* Add OrganizationWarningsService

* Add feature flag

* Add standalone warning components that consume new service

* Add new components to AC collections vault when FF is enabled

* Add OrganizationWarningsService spec

* Run prettier on spec file

* Thomas' feedback
This commit is contained in:
Alex Morask
2025-05-01 17:13:18 -04:00
committed by GitHub
parent 23e7f120fd
commit c8d6e48996
10 changed files with 828 additions and 9 deletions

View File

@@ -0,0 +1,97 @@
import { BaseResponse } from "../../../models/response/base.response";
export class OrganizationWarningsResponse extends BaseResponse {
freeTrial?: FreeTrialWarningResponse;
inactiveSubscription?: InactiveSubscriptionWarningResponse;
resellerRenewal?: ResellerRenewalWarningResponse;
constructor(response: any) {
super(response);
const freeTrialWarning = this.getResponseProperty("FreeTrial");
if (freeTrialWarning) {
this.freeTrial = new FreeTrialWarningResponse(freeTrialWarning);
}
const inactiveSubscriptionWarning = this.getResponseProperty("InactiveSubscription");
if (inactiveSubscriptionWarning) {
this.inactiveSubscription = new InactiveSubscriptionWarningResponse(
inactiveSubscriptionWarning,
);
}
const resellerWarning = this.getResponseProperty("ResellerRenewal");
if (resellerWarning) {
this.resellerRenewal = new ResellerRenewalWarningResponse(resellerWarning);
}
}
}
class FreeTrialWarningResponse extends BaseResponse {
remainingTrialDays: number;
constructor(response: any) {
super(response);
this.remainingTrialDays = this.getResponseProperty("RemainingTrialDays");
}
}
class InactiveSubscriptionWarningResponse extends BaseResponse {
resolution: string;
constructor(response: any) {
super(response);
this.resolution = this.getResponseProperty("Resolution");
}
}
class ResellerRenewalWarningResponse extends BaseResponse {
type: "upcoming" | "issued" | "past_due";
upcoming?: UpcomingRenewal;
issued?: IssuedRenewal;
pastDue?: PastDueRenewal;
constructor(response: any) {
super(response);
this.type = this.getResponseProperty("Type");
switch (this.type) {
case "upcoming": {
this.upcoming = new UpcomingRenewal(this.getResponseProperty("Upcoming"));
break;
}
case "issued": {
this.issued = new IssuedRenewal(this.getResponseProperty("Issued"));
break;
}
case "past_due": {
this.pastDue = new PastDueRenewal(this.getResponseProperty("PastDue"));
}
}
}
}
class UpcomingRenewal extends BaseResponse {
renewalDate: Date;
constructor(response: any) {
super(response);
this.renewalDate = new Date(this.getResponseProperty("RenewalDate"));
}
}
class IssuedRenewal extends BaseResponse {
issuedDate: Date;
dueDate: Date;
constructor(response: any) {
super(response);
this.issuedDate = new Date(this.getResponseProperty("IssuedDate"));
this.dueDate = new Date(this.getResponseProperty("DueDate"));
}
}
class PastDueRenewal extends BaseResponse {
suspensionDate: Date;
constructor(response: any) {
super(response);
this.suspensionDate = new Date(this.getResponseProperty("SuspensionDate"));
}
}