Adjusted crud tests + added auth tests

This commit is contained in:
Teodor
2026-04-30 22:21:56 +02:00
parent 545027a766
commit 3dcd392cd3
19 changed files with 578 additions and 313 deletions

View File

@@ -69,4 +69,4 @@ export default function TabLayout() {
<Tabs.Screen name="timer" options={{title: "Timer"}} />
</Tabs>
);
}
}

View File

@@ -4,13 +4,14 @@ import { Subject } from '@/lib/types';
import { Session } from '@supabase/supabase-js';
import { router, Stack, useFocusEffect } from 'expo-router';
import { useCallback, useEffect, useState } from 'react';
import { Alert, Pressable, ScrollView, Text, View } from 'react-native';
import { ActivityIndicator, Alert, Pressable, ScrollView, Text, View } from 'react-native';
import type { SubjectColor } from '@/lib/subjectColors';
export default function Subjects() {
const [subjects, SetSubjects] = useState<Subject[]>([]);
const [session, SetSession] = useState<Session | null>(null);
const [isLoading, SetIsLoading] = useState(false);
useEffect(() => {
supabase.auth.getSession().then(({ data }) => {
@@ -29,12 +30,16 @@ export default function Subjects() {
const GetSubjects = async () => {
if (!session?.user.id) return;
SetIsLoading(true);
const { data, error } = await supabase
.from('subjects')
.select('*')
.eq('uId', session.user.id)
.order('lastChanged', { ascending: false });
SetIsLoading(false);
if (error) {
Alert.alert('Subjects could not be fetched, please try again');
return;
@@ -51,6 +56,14 @@ export default function Subjects() {
}, [session])
);
if (isLoading) {
return (
<View className="flex-1 items-center justify-center bg-app-bg">
<ActivityIndicator size="large" />
</View>
);
}
return (
<View className="flex-1 bg-app-bg">
<Stack.Screen