crud for tasks + auth

This commit is contained in:
Teodor
2026-04-20 01:05:29 +02:00
parent 0abfb47d6f
commit 473ba75e3e
13 changed files with 916 additions and 14 deletions

40
app/(tabs)/_layout.tsx Normal file
View File

@@ -0,0 +1,40 @@
import { supabase } from "@/lib/supabase";
import { Session } from "@supabase/supabase-js";
import { Redirect, Tabs } from "expo-router";
import { useEffect, useState } from "react";
export default function TabLayout() {
const [session, SetSession] = useState<Session | null>(null)
const [loading, SetLoading] = useState(true);
useEffect(() => {
const loadSession = async () => {
const { data } = await supabase.auth.getSession();
SetSession(data.session ?? null);
SetLoading(false);
}
loadSession();
const { data: sub } = supabase.auth.onAuthStateChange((_event, newSession) => {
SetSession(newSession);
SetLoading(false);
});
return () => sub.subscription.unsubscribe();
}, []);
if (loading) {
return null;
}
if (!session) {
return <Redirect href="/createUser" />;
}
return (
<Tabs>
<Tabs.Screen name="index" options={{title: "Today"}} />
<Tabs.Screen name="tasks" options={{title: "Tasks"}} />
</Tabs>
);
}