feat : Structure de base
This commit is contained in:
3
app.json
3
app.json
@@ -38,7 +38,8 @@
|
||||
}
|
||||
],
|
||||
"expo-image",
|
||||
"expo-font"
|
||||
"expo-font",
|
||||
"expo-secure-store"
|
||||
],
|
||||
"experiments": {
|
||||
"typedRoutes": true,
|
||||
|
||||
10
package-lock.json
generated
10
package-lock.json
generated
@@ -27,6 +27,7 @@
|
||||
"expo-linear-gradient": "~56.0.4",
|
||||
"expo-linking": "~56.0.12",
|
||||
"expo-router": "~56.2.7",
|
||||
"expo-secure-store": "~56.0.4",
|
||||
"expo-splash-screen": "~56.0.10",
|
||||
"expo-status-bar": "~56.0.4",
|
||||
"expo-symbols": "~56.0.5",
|
||||
@@ -5124,6 +5125,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/expo-secure-store": {
|
||||
"version": "56.0.4",
|
||||
"resolved": "https://registry.npmjs.org/expo-secure-store/-/expo-secure-store-56.0.4.tgz",
|
||||
"integrity": "sha512-hjEi/gmpdFFJ9lYbdp3k3p/WchV7Gi0Qt8jt/m/0WJadqQrskafHAlDxbZkII1cN3Yd7zp9Lvkeq3UfGhSwirQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-server": {
|
||||
"version": "56.0.4",
|
||||
"resolved": "https://registry.npmjs.org/expo-server/-/expo-server-56.0.4.tgz",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"expo-linear-gradient": "~56.0.4",
|
||||
"expo-linking": "~56.0.12",
|
||||
"expo-router": "~56.2.7",
|
||||
"expo-secure-store": "~56.0.4",
|
||||
"expo-splash-screen": "~56.0.10",
|
||||
"expo-status-bar": "~56.0.4",
|
||||
"expo-symbols": "~56.0.5",
|
||||
|
||||
13
src/app/(auth)/_layout.tsx
Normal file
13
src/app/(auth)/_layout.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useAuth } from '@/stores/authStore';
|
||||
import { Redirect, Stack } from 'expo-router';
|
||||
|
||||
export default function AuthLayout() {
|
||||
const session = useAuth((state) => state.session);
|
||||
|
||||
if (session) {
|
||||
const href = (session.role === 'org' ? '/(org)' : '/(tabs)') as any;
|
||||
return <Redirect href={href} />;
|
||||
}
|
||||
|
||||
return <Stack screenOptions={{ headerShown: false}} />;
|
||||
}
|
||||
32
src/app/(auth)/interets.tsx
Normal file
32
src/app/(auth)/interets.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function InteretsScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Interets</Text>
|
||||
<Text style={styles.description}>Base ecran interets</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(auth)/login.tsx
Normal file
32
src/app/(auth)/login.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function LoginScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Login</Text>
|
||||
<Text style={styles.description}>Base ecran login</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(auth)/onboarding.tsx
Normal file
32
src/app/(auth)/onboarding.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function OnboardingScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Onboarding</Text>
|
||||
<Text style={styles.description}>Base ecran onboarding</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
12
src/app/(org)/_layout.tsx
Normal file
12
src/app/(org)/_layout.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useAuth } from '@/stores/authStore';
|
||||
import { Redirect, Stack } from 'expo-router';
|
||||
|
||||
export default function OrgLayout() {
|
||||
const session = useAuth((state) => state.session);
|
||||
|
||||
if (!session) return <Redirect href="../(auth)/login" />;
|
||||
|
||||
if (session.role !== 'org') return <Redirect href="../(tabs)" />;
|
||||
|
||||
return <Stack screenOptions={{ headerShown: false }} />;
|
||||
}
|
||||
32
src/app/(org)/events.tsx
Normal file
32
src/app/(org)/events.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function OrgEventsScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Org Events</Text>
|
||||
<Text style={styles.description}>Base ecran events organisateur</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(org)/index.tsx
Normal file
32
src/app/(org)/index.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function OrgHomeScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Org Home</Text>
|
||||
<Text style={styles.description}>Base ecran organisation</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(org)/profile.tsx
Normal file
32
src/app/(org)/profile.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function OrgProfileScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Org Profile</Text>
|
||||
<Text style={styles.description}>Base ecran profil organisateur</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(org)/stats.tsx
Normal file
32
src/app/(org)/stats.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function OrgStatsScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Org Stats</Text>
|
||||
<Text style={styles.description}>Base ecran statistiques organisateur</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
12
src/app/(tabs)/_layout.tsx
Normal file
12
src/app/(tabs)/_layout.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useAuth } from '@/stores/authStore';
|
||||
import { Redirect, Stack } from 'expo-router';
|
||||
|
||||
export default function TabsLayout() {
|
||||
const session = useAuth((state) => state.session);
|
||||
|
||||
if (!session) return <Redirect href="../(auth)/login" />;
|
||||
|
||||
if (session.role === 'org') return <Redirect href="../(org)" />;
|
||||
|
||||
return <Stack screenOptions={{ headerShown: false}} />;
|
||||
}
|
||||
32
src/app/(tabs)/index.tsx
Normal file
32
src/app/(tabs)/index.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function HomeTabScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Accueil</Text>
|
||||
<Text style={styles.description}>Base ecran accueil tab</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(tabs)/map.tsx
Normal file
32
src/app/(tabs)/map.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function MapTabScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Map</Text>
|
||||
<Text style={styles.description}>Base ecran carte</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(tabs)/my-events.tsx
Normal file
32
src/app/(tabs)/my-events.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function MyEventsTabScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>My Events</Text>
|
||||
<Text style={styles.description}>Base ecran mes events</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/(tabs)/profile.tsx
Normal file
32
src/app/(tabs)/profile.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function ProfileTabScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Profile</Text>
|
||||
<Text style={styles.description}>Base ecran profil tab</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
@@ -1,9 +1,17 @@
|
||||
import { QueryClientProvider } from '@tanstack/react-query';
|
||||
import { Stack } from 'expo-router';
|
||||
import * as SplashScreen from 'expo-splash-screen';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { useEffect } from 'react';
|
||||
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
||||
|
||||
import { queryClient } from '../hooks/queryClient';
|
||||
import { useAppFonts } from '../theme/typography';
|
||||
|
||||
import { useAuth } from '@/stores/authStore';
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
export default function RootLayout() {
|
||||
const [fontsLoaded] = useAppFonts();
|
||||
|
||||
@@ -11,9 +19,33 @@ export default function RootLayout() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const hydrated = useAuth((state) => state.hydrated);
|
||||
const hydrate = useAuth((state) => state.hydrate);
|
||||
|
||||
useEffect(() => { hydrate(); }, []);
|
||||
|
||||
const ready = hydrated && fontsLoaded;
|
||||
|
||||
useEffect(() => {
|
||||
if (ready) SplashScreen.hideAsync();
|
||||
}, [ready]);
|
||||
|
||||
if (!ready) return null;
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<Stack />
|
||||
<SafeAreaProvider>
|
||||
<StatusBar style="auto" />
|
||||
<Stack screenOptions={{ headerShown: false, contentStyle: { backgroundColor: '#0B0B12' } }}>
|
||||
<Stack.Screen name="(auth)" />
|
||||
<Stack.Screen name="(tabs)" />
|
||||
<Stack.Screen name="(org)" />
|
||||
<Stack.Screen name="event/[id]" />
|
||||
<Stack.Screen name="create/event" options={{ presentation: 'modal' }} />
|
||||
<Stack.Screen name="create/post" options={{ presentation: 'modal' }} />
|
||||
</Stack>
|
||||
|
||||
</SafeAreaProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
32
src/app/create/event.tsx
Normal file
32
src/app/create/event.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function CreateEventScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Create Event</Text>
|
||||
<Text style={styles.description}>Base ecran creation event</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
32
src/app/create/post.tsx
Normal file
32
src/app/create/post.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function CreatePostScreen() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Create Post</Text>
|
||||
<Text style={styles.description}>Base ecran creation post</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
});
|
||||
41
src/app/event/[id].tsx
Normal file
41
src/app/event/[id].tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { useLocalSearchParams } from 'expo-router';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { colors } from '@/theme/colors';
|
||||
import { spacing } from '@/theme/spacing';
|
||||
import { typography } from '@/theme/typography';
|
||||
|
||||
export default function EventDetailScreen() {
|
||||
const { id } = useLocalSearchParams<{ id?: string | string[] }>();
|
||||
const eventId = Array.isArray(id) ? id[0] : id;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Event Detail</Text>
|
||||
<Text style={styles.description}>Base ecran detail event</Text>
|
||||
<Text style={styles.meta}>ID: {eventId ?? 'non defini'}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.deepBackground,
|
||||
padding: spacing[24],
|
||||
justifyContent: 'center',
|
||||
gap: spacing[8],
|
||||
},
|
||||
title: {
|
||||
...typography.screenTitle,
|
||||
color: colors.textPrimary,
|
||||
},
|
||||
description: {
|
||||
...typography.body,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
meta: {
|
||||
...typography.metadata,
|
||||
color: colors.textStrong,
|
||||
},
|
||||
});
|
||||
39
src/stores/authStore.ts
Normal file
39
src/stores/authStore.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import * as SecureStore from 'expo-secure-store';
|
||||
import { create } from 'zustand';
|
||||
|
||||
export type Role = 'user' | 'org';
|
||||
export type Session = {
|
||||
userId: string;
|
||||
token: string;
|
||||
role: Role;
|
||||
}
|
||||
|
||||
type AuthState = {
|
||||
session: Session | null;
|
||||
hydrated: boolean; // Le disque a été lu, la réponse est fiable
|
||||
hydrate: () => Promise<void>;
|
||||
signIn: (session: Session) => Promise<void>;
|
||||
signOut: () => Promise<void>;
|
||||
};
|
||||
|
||||
const KEY = 'bahla.session';
|
||||
|
||||
export const useAuth = create<AuthState>((set) => ({
|
||||
session: null,
|
||||
hydrated: false,
|
||||
|
||||
hydrate: async () => {
|
||||
const session = await SecureStore.getItemAsync(KEY);
|
||||
set({ session: session ? JSON.parse(session) : null, hydrated: true });
|
||||
},
|
||||
|
||||
signIn: async (s: Session) => {
|
||||
await SecureStore.setItemAsync(KEY, JSON.stringify(s));
|
||||
set({ session: s });
|
||||
},
|
||||
|
||||
signOut: async () => {
|
||||
await SecureStore.deleteItemAsync(KEY);
|
||||
set({ session: null });
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user