File size: 1,541 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { fetchCurrentUser, updateCurrentUser } from "@/lib/auth/auth-client";
import { apiGet } from "@/lib/api/client";
import { withDemoFallback } from "@/lib/api/mode";
import type { UserUpdateRequest, BillingMe } from "@/lib/api/types";

export function getCurrentUser() {
  return fetchCurrentUser();
}

export function updateCurrentUserProfile(payload: UserUpdateRequest) {
  return updateCurrentUser(payload);
}

export async function getBillingMe(): Promise<BillingMe> {
  const fallback: BillingMe = {
    tier: "free",
    selected_plan: "free_trial",
    plan_name: "Free",
    status: "free",
    features: [
      "core_learning",
      "study_chat_ai",
      "tuition_ai_tutor",
      "deterministic_correction",
      "learn_anything_generation",
      "pyq_style_generation",
      "source_upload",
      "existing_content_read",
    ],
    usage_policy_key: "free_trial",
    effective_from: null,
    effective_until: null,
    payments_available: false,
    trial_started_at: null,
    trial_ends_at: null,
    monthly_generation_limit: 50,
    monthly_generation_used: 0,
    remaining_generations: 50,
    monthly_video_limit: 2,
    monthly_video_used: 0,
    remaining_videos: 2,
    usage_warning: null,
    coming_soon: false,
    checkout_plan_keys: [],
    portal_available: false,
    current_period_end: null,
    cancel_at_period_end: false,
    billing_message: "Payments are unavailable in preview mode.",
  };
  return withDemoFallback(
    () => apiGet<BillingMe>("/billing/me"),
    () => fallback,
  );
}