feat: check quota correctly (#6561)

This commit is contained in:
darkskygit
2024-04-16 09:41:48 +00:00
parent 0ca8a23dd8
commit 1b0864eb60
26 changed files with 309 additions and 95 deletions

View File

@@ -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)))