index.ts 934 B

1234567891011121314151617181920212223242526272829
  1. import type { CurrentPlanInfoBackend } from '../type'
  2. import { NUM_INFINITE } from '@/app/components/billing/config'
  3. const parseLimit = (limit: number) => {
  4. if (limit === 0)
  5. return NUM_INFINITE
  6. return limit
  7. }
  8. export const parseCurrentPlan = (data: CurrentPlanInfoBackend) => {
  9. return {
  10. type: data.billing.subscription.plan,
  11. usage: {
  12. vectorSpace: data.vector_space.size,
  13. buildApps: data.apps?.size || 0,
  14. teamMembers: data.members.size,
  15. annotatedResponse: data.annotation_quota_limit.size,
  16. documentsUploadQuota: data.documents_upload_quota.size,
  17. },
  18. total: {
  19. vectorSpace: parseLimit(data.vector_space.limit),
  20. buildApps: parseLimit(data.apps?.limit) || 0,
  21. teamMembers: parseLimit(data.members.limit),
  22. annotatedResponse: parseLimit(data.annotation_quota_limit.limit),
  23. documentsUploadQuota: parseLimit(data.documents_upload_quota.limit),
  24. },
  25. }
  26. }