Improved the overall stability and speed of the app
This commit is contained in:
@@ -5,21 +5,23 @@ import {CorporateUser, Group, User} from "@/interfaces/user";
|
||||
import {getGroupsForUser} from "./groups.be";
|
||||
import {uniq, uniqBy} from "lodash";
|
||||
import {getUserCodes} from "./codes.be";
|
||||
import moment from "moment";
|
||||
const db = getFirestore(app);
|
||||
|
||||
export async function getUsers() {
|
||||
const snapshot = await getDocs(collection(db, "users"));
|
||||
|
||||
return snapshot.docs.map((doc) => ({
|
||||
id: doc.id,
|
||||
...doc.data(),
|
||||
})) as User[];
|
||||
id: doc.id,
|
||||
registrationDate: moment(doc.data().registrationDate).toISOString(),
|
||||
})) as unknown as User[];
|
||||
}
|
||||
|
||||
export async function getUser(id: string) {
|
||||
const userDoc = await getDoc(doc(db, "users", id));
|
||||
|
||||
return {...userDoc.data(), id} as User;
|
||||
return {...userDoc.data(), id, registrationDate: moment(userDoc.data()?.registrationDate).toISOString()} as unknown as User;
|
||||
}
|
||||
|
||||
export async function getSpecificUsers(ids: string[]) {
|
||||
@@ -28,9 +30,10 @@ export async function getSpecificUsers(ids: string[]) {
|
||||
const snapshot = await getDocs(query(collection(db, "users"), where("id", "in", ids)));
|
||||
|
||||
const groups = snapshot.docs.map((doc) => ({
|
||||
id: doc.id,
|
||||
...doc.data(),
|
||||
})) as User[];
|
||||
id: doc.id,
|
||||
registrationDate: moment(doc.data().registrationDate).toISOString(),
|
||||
})) as unknown as User[];
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user