Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/trochas/mmm-projet
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");
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ export async function getChantiers(): Promise<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