mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -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 { type TenantResponse } from '@/cloud/types/router';
|
||||||
import DynamicT from '@/ds-components/DynamicT';
|
import DynamicT from '@/ds-components/DynamicT';
|
||||||
import Tag from '@/ds-components/Tag';
|
import Tag from '@/ds-components/Tag';
|
||||||
|
import { isPaidPlan } from '@/utils/subscription';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
readonly tenantData: TenantResponse;
|
readonly tenantData: TenantResponse;
|
||||||
|
@ -8,13 +9,20 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function TenantStatusTag({ tenantData, className }: Props) {
|
function TenantStatusTag({ tenantData, className }: Props) {
|
||||||
const { usage, quota, openInvoices, isSuspended } = tenantData;
|
const {
|
||||||
|
usage,
|
||||||
|
quota,
|
||||||
|
openInvoices,
|
||||||
|
isSuspended,
|
||||||
|
subscription: { planId, isEnterprisePlan },
|
||||||
|
} = tenantData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tenant status priority:
|
* Tenant status priority:
|
||||||
* 1. suspend
|
* 1. suspend
|
||||||
* 2. overdue
|
* 2. overdue
|
||||||
* 3. mau exceeded
|
* 3. mau exceeded
|
||||||
|
* 4. token exceeded
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isSuspended) {
|
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 isMauExceeded = mauLimit !== null && activeUsers >= mauLimit;
|
||||||
|
const isTokenExceeded = tokenLimit !== null && !isPaidTenant && tokenUsage >= tokenLimit;
|
||||||
|
|
||||||
if (isMauExceeded) {
|
if (isMauExceeded) {
|
||||||
return (
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,8 @@ const tenants = {
|
||||||
create_tenant_button: 'Create tenant',
|
create_tenant_button: 'Create tenant',
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
mau_exceeded: 'MAU Exceeded',
|
mau_exceeded: 'MAU exceeded',
|
||||||
|
token_exceeded: 'Token exceeded',
|
||||||
suspended: 'Suspended',
|
suspended: 'Suspended',
|
||||||
overdue: 'Overdue',
|
overdue: 'Overdue',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue