mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat: check quota correctly (#6561)
This commit is contained in:
@@ -70,7 +70,9 @@ export const AIUsagePanelNotSubscripted = () => {
|
||||
const { data: quota } = useQuery({
|
||||
query: getCopilotQuotaQuery,
|
||||
});
|
||||
const { limit = 10, used = 0 } = quota.currentUser?.copilot.quota || {};
|
||||
const { limit: nullableLimit, used = 0 } =
|
||||
quota.currentUser?.copilot.quota || {};
|
||||
const limit = nullableLimit || 10;
|
||||
const percent = Math.min(
|
||||
100,
|
||||
Math.max(0.5, Number(((used / limit) * 100).toFixed(4)))
|
||||
|
||||
@@ -62,6 +62,7 @@ export interface CreateCheckoutSessionInput {
|
||||
export enum FeatureType {
|
||||
Copilot = 'Copilot',
|
||||
EarlyAccess = 'EarlyAccess',
|
||||
UnlimitedCopilot = 'UnlimitedCopilot',
|
||||
UnlimitedWorkspace = 'UnlimitedWorkspace',
|
||||
}
|
||||
|
||||
@@ -387,7 +388,11 @@ export type GetCopilotQuotaQuery = {
|
||||
__typename?: 'UserType';
|
||||
copilot: {
|
||||
__typename?: 'Copilot';
|
||||
quota: { __typename?: 'CopilotQuota'; limit: number; used: number };
|
||||
quota: {
|
||||
__typename?: 'CopilotQuota';
|
||||
limit: number | null;
|
||||
used: number;
|
||||
};
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user