mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
feat(console): add token exceed tag (#6904)
add token exceed tag to tenant drop down item
This commit is contained in:
parent
ea5a62bf8a
commit
c6495fcdda
2 changed files with 24 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
import { type TenantResponse } from '@/cloud/types/router';
|
||||
import DynamicT from '@/ds-components/DynamicT';
|
||||
import Tag from '@/ds-components/Tag';
|
||||
import { isPaidPlan } from '@/utils/subscription';
|
||||
|
||||
type Props = {
|
||||
readonly tenantData: TenantResponse;
|
||||
|
@ -8,13 +9,20 @@ type Props = {
|
|||
};
|
||||
|
||||
function TenantStatusTag({ tenantData, className }: Props) {
|
||||
const { usage, quota, openInvoices, isSuspended } = tenantData;
|
||||
const {
|
||||
usage,
|
||||
quota,
|
||||
openInvoices,
|
||||
isSuspended,
|
||||
subscription: { planId, isEnterprisePlan },
|
||||
} = tenantData;
|
||||
|
||||
/**
|
||||
* Tenant status priority:
|
||||
* 1. suspend
|
||||
* 2. overdue
|
||||
* 3. mau exceeded
|
||||
* 4. token exceeded
|
||||
*/
|
||||
|
||||
if (isSuspended) {
|
||||
|
@ -33,11 +41,14 @@ function TenantStatusTag({ tenantData, className }: Props) {
|
|||
);
|
||||
}
|
||||
|
||||
const { activeUsers } = usage;
|
||||
const isPaidTenant = isPaidPlan(planId, isEnterprisePlan);
|
||||
|
||||
const { mauLimit } = quota;
|
||||
const { activeUsers, tokenUsage } = usage;
|
||||
|
||||
const { mauLimit, tokenLimit } = quota;
|
||||
|
||||
const isMauExceeded = mauLimit !== null && activeUsers >= mauLimit;
|
||||
const isTokenExceeded = tokenLimit !== null && !isPaidTenant && tokenUsage >= tokenLimit;
|
||||
|
||||
if (isMauExceeded) {
|
||||
return (
|
||||
|
@ -47,6 +58,14 @@ function TenantStatusTag({ tenantData, className }: Props) {
|
|||
);
|
||||
}
|
||||
|
||||
if (isTokenExceeded) {
|
||||
return (
|
||||
<Tag className={className}>
|
||||
<DynamicT forKey="tenants.status.token_exceeded" />
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,8 @@ const tenants = {
|
|||
create_tenant_button: 'Create tenant',
|
||||
},
|
||||
status: {
|
||||
mau_exceeded: 'MAU Exceeded',
|
||||
mau_exceeded: 'MAU exceeded',
|
||||
token_exceeded: 'Token exceeded',
|
||||
suspended: 'Suspended',
|
||||
overdue: 'Overdue',
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue