File size: 831 Bytes
65d68f5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import { apiGet } from "@/lib/api/client";
export type OperationUsageItem = {
operation: string;
period: "day" | "month";
used: number;
limit: number;
remaining: number;
allowed: boolean;
};
export type OperationUsageStatus = {
tier: "free" | "popular" | "premium";
entitlement_status:
| "free"
| "trial"
| "active"
| "past_due"
| "cancel_at_period_end"
| "expired";
usage_policy_key: string;
items: OperationUsageItem[];
};
export function getOperationUsage() {
return apiGet<OperationUsageStatus>("/users/me/operation-usage");
}
export function formatStudyChatUsage(item: OperationUsageItem | null) {
if (!item) return null;
return item.allowed
? `${item.remaining} AI questions remaining today`
: "AI help limit reached · verified PYQ and correction still work";
}
|