mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-25 07:34:39 +02:00
refactor(context-mobile): migrate from Supabase to backend API + mana-core-auth
Complete migration of Context mobile app from direct Supabase access to NestJS backend API with mana-core-auth authentication. New files: - context/AuthProvider.tsx: mana-core-auth integration via @manacore/shared-auth - services/backendApi.ts: Backend API client for spaces, documents, AI, tokens Rewritten services (same exports, backend implementation): - supabaseService.ts: Now thin wrapper around backendApi - aiService.ts: Uses backendApi for auth token - tokenCountingService.ts: Model prices from backend API - tokenTransactionService.ts: All token ops via backend API - revenueCatService.ts: Token balance via backend API Updated 16 consumer files (auth forms, token components, AI toolbars) Deleted: - utils/supabase.ts, context/AuthContext.tsx - services/spaceService.ts, services/spaceServiceDirect.ts Dependencies: - Added: @manacore/shared-auth, expo-secure-store - Removed: @supabase/supabase-js, @google/generative-ai, openai, @azure/openai Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c6d5d4840e
commit
5bd967900f
25 changed files with 896 additions and 2471 deletions
|
|
@ -3,7 +3,7 @@ import { useEffect } from 'react';
|
|||
import { Slot, Stack, useRouter, useSegments } from 'expo-router';
|
||||
import { useFonts } from 'expo-font';
|
||||
import { SplashScreen } from 'expo-router';
|
||||
import { AuthProvider, useAuth } from '../context/AuthContext';
|
||||
import { AuthProvider, useAuth } from '../context/AuthProvider';
|
||||
import { ThemeProvider } from '../components/theme';
|
||||
import { DebugProvider } from '../context/DebugContext';
|
||||
import { I18nProvider } from '../context/I18nContext';
|
||||
|
|
@ -51,7 +51,7 @@ function RootLayoutNav() {
|
|||
|
||||
// Initialisiere RevenueCat, wenn der Benutzer angemeldet ist
|
||||
if (user) {
|
||||
initializeRevenueCat(user.id);
|
||||
initializeRevenueCat(user.userId);
|
||||
}
|
||||
}, [user, loading, segments, router]);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { Ionicons } from '@expo/vector-icons';
|
|||
|
||||
import { Screen } from '~/components/layout/Screen';
|
||||
import { Text } from '~/components/ui/Text';
|
||||
import { useAuth } from '~/context/AuthContext';
|
||||
import { useAuth } from '~/context/AuthProvider';
|
||||
import { getSpaces, getDocuments, Document, Space } from '~/services/supabaseService';
|
||||
import { useTheme } from '~/utils/theme/theme';
|
||||
import { useTranslations } from '~/context/I18nContext';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { View, Text, ScrollView, StyleSheet, TouchableOpacity, Alert, Switch } f
|
|||
import { Stack, useRouter } from 'expo-router';
|
||||
import { ThemeSelector } from '~/components/theme';
|
||||
import { useTheme } from '~/utils/theme/theme';
|
||||
import { useAuth } from '~/context/AuthContext';
|
||||
import { useAuth } from '~/context/AuthProvider';
|
||||
import { useDebug } from '~/context/DebugContext';
|
||||
import { useTranslations } from '~/context/I18nContext';
|
||||
import { LanguagePicker } from '~/components/settings/LanguagePicker';
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {
|
|||
} from 'react-native';
|
||||
import { Text } from '~/components/ui/Text';
|
||||
import { useTheme } from '~/utils/theme/theme';
|
||||
import { supabase } from '~/utils/supabase';
|
||||
import {
|
||||
getCurrentTokenBalance,
|
||||
getTokenTransactions,
|
||||
|
|
@ -33,24 +32,16 @@ export default function TokenManagementScreen() {
|
|||
try {
|
||||
setLoading(true);
|
||||
|
||||
// Hole den aktuellen Benutzer
|
||||
const { data: sessionData } = await supabase.auth.getSession();
|
||||
const userId = sessionData?.session?.user?.id;
|
||||
|
||||
if (!userId) {
|
||||
throw new Error('Nicht angemeldet');
|
||||
}
|
||||
|
||||
// Hole das Token-Guthaben
|
||||
const balance = await getCurrentTokenBalance(userId);
|
||||
// Hole das Token-Guthaben (backend identifies user from JWT)
|
||||
const balance = await getCurrentTokenBalance();
|
||||
setTokenBalance(balance);
|
||||
|
||||
// Hole die Token-Transaktionen
|
||||
const transactionData = await getTokenTransactions(userId, 20);
|
||||
const transactionData = await getTokenTransactions('', 20);
|
||||
setTransactions(transactionData);
|
||||
|
||||
// Hole die Nutzungsstatistiken
|
||||
const stats = await getTokenUsageStats(userId, timeframe);
|
||||
const stats = await getTokenUsageStats('', timeframe);
|
||||
setUsageStats(stats);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Token-Daten:', error);
|
||||
|
|
@ -387,16 +378,11 @@ export default function TokenManagementScreen() {
|
|||
// Aktualisiere die Daten nach dem Kauf
|
||||
const refreshData = async () => {
|
||||
try {
|
||||
const { data: sessionData } = await supabase.auth.getSession();
|
||||
const userId = sessionData?.session?.user?.id;
|
||||
const balance = await getCurrentTokenBalance();
|
||||
setTokenBalance(balance);
|
||||
|
||||
if (userId) {
|
||||
const balance = await getCurrentTokenBalance(userId);
|
||||
setTokenBalance(balance);
|
||||
|
||||
const transactionData = await getTokenTransactions(userId, 20);
|
||||
setTransactions(transactionData);
|
||||
}
|
||||
const transactionData = await getTokenTransactions('', 20);
|
||||
setTransactions(transactionData);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Aktualisieren der Daten:', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue