web/satellite: show freeze warning banner

This change displays a freeze warning banner if the user has a freeze
warning event.

Change-Id: Ia221dedd885f80ff0b8fd0de80269a94c59eaefb
This commit is contained in:
Wilfred Asomani 2023-04-17 17:10:55 +00:00
parent 9fbad53bbe
commit 8632e28584
5 changed files with 64 additions and 11 deletions

View File

@ -5,6 +5,7 @@ import { ErrorBadRequest } from '@/api/errors/ErrorBadRequest';
import { ErrorMFARequired } from '@/api/errors/ErrorMFARequired';
import { ErrorTooManyRequests } from '@/api/errors/ErrorTooManyRequests';
import {
FreezeStatus,
SetUserSettingsData,
TokenInfo,
UpdatedUser,
@ -233,13 +234,16 @@ export class AuthHttpApi implements UsersApi {
*
* @throws Error
*/
public async getFrozenStatus(): Promise<boolean> {
public async getFrozenStatus(): Promise<FreezeStatus> {
const path = `${this.ROOT_PATH}/account/freezestatus`;
const response = await this.http.get(path);
if (response.ok) {
const responseData = await response.json();
return responseData.frozen;
return new FreezeStatus(
responseData.frozen,
responseData.warned,
);
}
throw new Error('can not get user frozen status');

View File

@ -52,7 +52,7 @@ export const useUsersStore = defineStore('users', () => {
}
async function getFrozenStatus(): Promise<void> {
state.user.isFrozen = await api.getFrozenStatus();
state.user.freezeStatus = await api.getFrozenStatus();
}
async function disableUserMFA(request: DisableMFARequest): Promise<void> {

View File

@ -27,7 +27,7 @@ export interface UsersApi {
* @returns boolean
* @throws Error
*/
getFrozenStatus(): Promise<boolean>;
getFrozenStatus(): Promise<FreezeStatus>;
/**
* Fetches user frozen status.
@ -94,7 +94,7 @@ export class User {
public mfaRecoveryCodeCount: number = 0,
public _createdAt: string | null = null,
public signupPromoCode: string = '',
public isFrozen: boolean = false,
public freezeStatus: FreezeStatus = new FreezeStatus(),
) {}
public get createdAt(): Date | null {
@ -180,3 +180,13 @@ export interface SetUserSettingsData {
onboardingStep?: string | null;
sessionDuration?: number;
}
/**
* FreezeStatus represents a freeze-status endpoint response.
*/
export class FreezeStatus {
public constructor(
public frozen = false,
public warned = false,
) {}
}

View File

@ -38,6 +38,17 @@
</template>
</v-banner>
<v-banner
v-if="isAccountWarned && !isLoading && dashboardContent"
severity="warning"
:dashboard-ref="dashboardContent"
>
<template #text>
<p class="medium">Your account will be frozen soon due to billing issues. Please update your payment information.</p>
<p class="link" @click.stop.self="redirectToBillingPage">To Billing Page</p>
</template>
</v-banner>
<v-banner
v-if="limitState.hundredIsShown && !isLoading && dashboardContent"
severity="critical"
@ -215,7 +226,14 @@ const debugTimerShown = computed((): boolean => {
* Indicates if account was frozen due to billing issues.
*/
const isAccountFrozen = computed((): boolean => {
return usersStore.state.user.isFrozen;
return usersStore.state.user.freezeStatus.frozen;
});
/**
* Indicates if account was warned due to billing issues.
*/
const isAccountWarned = computed((): boolean => {
return usersStore.state.user.freezeStatus.warned;
});
/**
@ -752,6 +770,11 @@ onBeforeUnmount(() => {
}
.banner-container {
padding-top: 0 !important;
&:empty {
display: none;
}
&__bottom {
flex-grow: 1;
@ -761,10 +784,6 @@ onBeforeUnmount(() => {
}
}
.banner-container:empty {
display: none;
}
.dashboard {
height: 100%;
background-color: #f5f6fa;

View File

@ -43,6 +43,18 @@
</template>
</v-banner>
<v-banner
v-if="isAccountWarned && !isLoading && dashboardContent"
class="all-dashboard__banners__warning"
severity="warning"
:dashboard-ref="dashboardContent"
>
<template #text>
<p class="medium">Your account will be frozen soon due to billing issues. Please update your payment information.</p>
<p class="link" @click.stop.self="redirectToBillingPage">To Billing Page</p>
</template>
</v-banner>
<v-banner
v-if="limitState.hundredIsShown && !isLoading && dashboardContent"
class="all-dashboard__banners__hundred-limit"
@ -197,7 +209,14 @@ const debugTimerShown = computed((): boolean => {
* Indicates if account was frozen due to billing issues.
*/
const isAccountFrozen = computed((): boolean => {
return usersStore.state.user.isFrozen;
return usersStore.state.user.freezeStatus.frozen;
});
/**
* Indicates if account was warned due to billing issues.
*/
const isAccountWarned = computed((): boolean => {
return usersStore.state.user.freezeStatus.warned;
});
/**
@ -681,6 +700,7 @@ onBeforeUnmount(() => {
&__upgrade,
&__project-limit,
&__freeze,
&__warning,
&__hundred-limit,
&__eighty-limit {
margin: 20px 0 0;