Did the same to all of the dashboards
This commit is contained in:
@@ -53,8 +53,15 @@ export async function getSpecificUsers(ids: string[]) {
|
||||
}
|
||||
|
||||
export async function getLinkedUsers(userID?: string, userType?: Type, type?: Type, page?: number, size?: number) {
|
||||
const q = [
|
||||
...(!!type ? [where("type", "==", type)] : []),
|
||||
orderBy(documentId()),
|
||||
...(page !== undefined && !!size ? [startAt(page * size)] : []),
|
||||
...(page !== undefined && !!size ? [limit(page + 1 * size)] : []),
|
||||
];
|
||||
|
||||
if (!userID || userType === "admin" || userType === "developer") {
|
||||
const snapshot = await getDocs(collection(db, "users"));
|
||||
const snapshot = await getDocs(query(collection(db, "users"), ...q));
|
||||
const users = snapshot.docs.map((doc) => ({
|
||||
id: doc.id,
|
||||
...doc.data(),
|
||||
@@ -73,15 +80,7 @@ export async function getLinkedUsers(userID?: string, userType?: Type, type?: Ty
|
||||
...(userType === "teacher" ? belongingGroups.flatMap((x) => x.participants) : []),
|
||||
]);
|
||||
|
||||
const q = [
|
||||
where(documentId(), "in", participants),
|
||||
...(!!type ? [where("type", "==", type)] : []),
|
||||
orderBy(documentId()),
|
||||
...(page !== undefined && !!size ? [startAt(page * size)] : []),
|
||||
...(page !== undefined && !!size ? [limit(page + 1 * size)] : []),
|
||||
];
|
||||
|
||||
const snapshot = await getDocs(query(collection(db, "users"), ...q));
|
||||
const snapshot = await getDocs(query(collection(db, "users"), ...[where(documentId(), "in", participants), ...q]));
|
||||
const users = snapshot.docs.map((doc) => ({
|
||||
id: doc.id,
|
||||
...doc.data(),
|
||||
|
||||
Reference in New Issue
Block a user