mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 09:59:40 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
1 KiB
TypeScript
38 lines
1 KiB
TypeScript
import { get } from '../utils/apiClient';
|
|
import type { CreditBalance } from '../types/credits';
|
|
|
|
const BASE_API_URL = process.env.EXPO_PUBLIC_API_URL || 'https://manadeck-backend-111768794939.europe-west3.run.app';
|
|
|
|
/**
|
|
* Credit Service
|
|
* Handles all credit-related API operations
|
|
*/
|
|
export const creditService = {
|
|
/**
|
|
* Get user's current credit balance
|
|
*/
|
|
async getBalance(): Promise<number> {
|
|
try {
|
|
const response = await get<CreditBalance>(`${BASE_API_URL}/v1/api/credits/balance`);
|
|
return response.balance || 0;
|
|
} catch (error) {
|
|
console.error('Error fetching credit balance:', error);
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Get user profile including credit balance
|
|
*/
|
|
async getProfile(): Promise<{ user: any; credits: number }> {
|
|
try {
|
|
const response = await get<{ user: any; credits: number }>(`${BASE_API_URL}/v1/api/profile`);
|
|
return response;
|
|
} catch (error) {
|
|
console.error('Error fetching profile:', error);
|
|
throw error;
|
|
}
|
|
},
|
|
};
|
|
|
|
export default creditService;
|