Started working on the assignments page
This commit is contained in:
@@ -23,6 +23,10 @@ export const getAssignments = async () => {
|
||||
return await db.collection("assignments").find<Assignment>({}).toArray();
|
||||
};
|
||||
|
||||
export const getAssignment = async (id: string) => {
|
||||
return await db.collection("assignments").findOne<Assignment>({id});
|
||||
};
|
||||
|
||||
export const getAssignmentsByAssignee = async (id: string, filter?: {[key in keyof Partial<Assignment>]: any}) => {
|
||||
return await db
|
||||
.collection("assignments")
|
||||
|
||||
@@ -84,6 +84,12 @@ export const getAllAssignersByCorporate = async (corporateID: string, type: Type
|
||||
return [...linkedTeachers.users.map((x) => x.id), ...linkedCorporates.users.map((x) => x.id)];
|
||||
};
|
||||
|
||||
export const getGroupsForEntities = async (ids: string[]) =>
|
||||
await db
|
||||
.collection("groups")
|
||||
.find<Group>({entity: {$in: ids}})
|
||||
.toArray();
|
||||
|
||||
export const getGroupsForUser = async (admin?: string, participant?: string) => {
|
||||
if (admin && participant) return await db.collection("groups").find<Group>({admin, participant}).toArray();
|
||||
|
||||
|
||||
@@ -44,10 +44,7 @@ export const convertBase64 = (file: File) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const mapBy = <T>(obj: T[], key: keyof T) => {
|
||||
if (!obj) return undefined;
|
||||
return obj.map((i) => i[key]);
|
||||
};
|
||||
export const mapBy = <T>(obj: T[] | undefined, key: keyof T) => (obj || []).map((i) => i[key]);
|
||||
export const filterBy = <T>(obj: T[], key: keyof T, value: any) => obj.filter((i) => i[key] === value);
|
||||
|
||||
export const serialize = <T>(obj: T): T => JSON.parse(JSON.stringify(obj));
|
||||
|
||||
Reference in New Issue
Block a user