dados perfil aluno

This commit is contained in:
2026-04-28 17:16:03 +01:00
parent 0b544677a8
commit 6a9a16e4ea
24 changed files with 514 additions and 174 deletions

31
lib/supabase.ts Normal file
View File

@@ -0,0 +1,31 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { createClient } from '@supabase/supabase-js';
import { AppState, Platform } from 'react-native';
import 'react-native-url-polyfill/auto';
// Substitui pelas tuas credenciais se necessário (estas são as que enviaste)
const supabaseUrl = 'https://ssorfpctjeujolmtkfib.supabase.co';
const supabaseAnonKey = 'sb_publishable_SDocGprdYkUKi04FyfVqmA_Ykirp9cK';
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
auth: {
// No React Native usamos o AsyncStorage para persistir o login
storage: AsyncStorage,
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: false,
// Nota: Removido o 'lock' e o 'lockAcquireTimeout' para evitar erros de TS
// O Supabase v2 no mobile já gere o fluxo de tokens de forma mais estável sem eles.
},
});
// Garante que o refresh do token só acontece quando a app está visível (Foreground)
if (Platform.OS !== "web") {
AppState.addEventListener('change', (state) => {
if (state === 'active') {
supabase.auth.startAutoRefresh();
} else {
supabase.auth.stopAutoRefresh();
}
});
}