DocDoeAI / src /lib /api /users.ts
asnannp's picture
deploy: sync backend to Space root (learn-lesson HF cache fix)
65d68f5
Raw History Blame Contribute Delete
1.54 kB
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,
);
}