1 time login only
This commit is contained in:
@@ -26,19 +26,11 @@ export default function RootLayout() {
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [userRole, setUserRole] = useState<string | null>(null);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS === 'android' && UIManager.setLayoutAnimationEnabledExperimental) {
|
||||
UIManager.setLayoutAnimationEnabledExperimental(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = onAuthStateChanged(auth, async (currentUser) => {
|
||||
setUser(currentUser);
|
||||
if (!currentUser) {
|
||||
router.replace("/login/login");
|
||||
setUser(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,6 +39,7 @@ export default function RootLayout() {
|
||||
|
||||
if (!userDoc.exists()) {
|
||||
router.replace("/login/login");
|
||||
setUser(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,8 +49,10 @@ export default function RootLayout() {
|
||||
|
||||
if (role === "chef") {
|
||||
router.replace("/(tabs)");
|
||||
} else if (role === "responsable") {
|
||||
router.replace("/login/login");
|
||||
} else if (role === "resp") {
|
||||
router.replace("/(tabs)");
|
||||
} else if (role === "ouvrier") {
|
||||
router.replace("/(tabs)");
|
||||
} else {
|
||||
router.replace("/login/login");
|
||||
}
|
||||
|
||||
@@ -38,11 +38,12 @@ export async function getRessources(): Promise<Ressources[]> {
|
||||
}
|
||||
|
||||
export async function getChantiers(): Promise<Chantier[]> {
|
||||
const snap = await getDocs(collection(db, "chantiers"));
|
||||
const snap = await getDocs(collection(db, "chantier"));
|
||||
const chantiers: Chantier[] = [];
|
||||
|
||||
for (const docSnap of snap.docs) {
|
||||
const data = docSnap.data();
|
||||
//Faut convertir les Timestamp en Date ( merci à firebase :) )
|
||||
const dateDep = data.dateDep instanceof Timestamp ? data.dateDep.toDate() : new Date(data.dateDep);
|
||||
let chef: User | null = null;
|
||||
if (data.chef) {
|
||||
|
||||
Reference in New Issue
Block a user