Updated the MasterCorporate and Corporate pages to allow to have Assignments

This commit is contained in:
Tiago Ribeiro
2024-08-13 10:02:40 +01:00
parent 8162567e12
commit 2784117862
10 changed files with 1050 additions and 819 deletions

View File

@@ -1,14 +1,20 @@
import { app } from "@/firebase";
import {app} from "@/firebase";
import { collection, getDocs, getFirestore } from "firebase/firestore";
import { User } from "@/interfaces/user";
import {collection, doc, getDoc, getDocs, getFirestore} from "firebase/firestore";
import {User} from "@/interfaces/user";
const db = getFirestore(app);
export async function getUsers() {
const snapshot = await getDocs(collection(db, "users"));
const snapshot = await getDocs(collection(db, "users"));
return snapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
})) as User[];
return snapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
})) as User[];
}
export async function getUser(id: string) {
const userDoc = await getDoc(doc(db, "users", id));
return {...userDoc.data(), id} as User;
}