test changeChantierStatus

This commit is contained in:
tuanvu
2025-12-11 11:07:15 +01:00
parent 984ef3ab3d
commit ced2d15e05
2 changed files with 23 additions and 2 deletions

View File

@@ -12,6 +12,8 @@ import ListMateriel from './gestionnaire_ressource';
import Home from './home';
import MapScreen from './mapScreen';
import AntDesign from '@expo/vector-icons/AntDesign';
const Tabs = createBottomTabNavigator();
export default function TabLayout() {
@@ -61,8 +63,17 @@ export default function TabLayout() {
tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
}}
>
</Tabs.Screen>
<Tabs.Screen
name="ajouterChantier"
component={ListMateriel}
options={{
title: 'Ajouter',
tabBarIcon: ({ color }) => (
<AntDesign name="plus" size={24} color="black" />
),
}}
/>
</Tabs.Navigator>
);

View File

@@ -1,4 +1,4 @@
import { collection, getDoc, getDocs, Timestamp } from "firebase/firestore";
import { collection, doc, getDoc, getDocs, Timestamp, updateDoc } from "firebase/firestore";
import { Chantier, Reservation, Ressources, User } from "../class/class";
import { db } from "../firebase_config";
@@ -80,3 +80,13 @@ function convertReservation(res: any): Reservation {
res.dateFin instanceof Timestamp ? res.dateFin.toDate() : new Date(res.dateFin),
};
}
export async function changeChantierStatus(chantierId: string, newStatus: string): Promise<void> {
try {
const chantierRef = doc(db, "chantier", chantierId);
await updateDoc(chantierRef, { status: newStatus });
console.log(`Chantier ${chantierId} status updated to ${newStatus}`);
} catch (err) {
console.error("Error", err);
}
}