ENCOA-126: Corporate should not be allowed to edit is own name
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {app} from "@/firebase";
|
||||
import {CorporateUser, Group, StudentUser, TeacherUser} from "@/interfaces/user";
|
||||
import {CorporateUser, Group, MasterCorporateUser, StudentUser, TeacherUser} from "@/interfaces/user";
|
||||
import {collection, doc, getDoc, getDocs, getFirestore, query, setDoc, where} from "firebase/firestore";
|
||||
import moment from "moment";
|
||||
import {getUser} from "./users.be";
|
||||
@@ -35,14 +35,14 @@ export const updateExpiryDateOnGroup = async (participantID: string, corporateID
|
||||
|
||||
export const getUserCorporate = async (id: string) => {
|
||||
const user = await getUser(id);
|
||||
if (user.type === "corporate" || user.type === "mastercorporate") return user;
|
||||
if (user.type === "mastercorporate") return user;
|
||||
|
||||
const groups = await getParticipantGroups(id);
|
||||
const admins = await Promise.all(groups.map((x) => x.admin).map(getUser));
|
||||
const corporates = admins.filter((x) => x.type === "corporate");
|
||||
const corporates = admins.filter((x) => x.type === "corporate" || x.type === "mastercorporate");
|
||||
|
||||
if (corporates.length === 0) return undefined;
|
||||
return corporates.shift() as CorporateUser;
|
||||
return corporates.shift() as CorporateUser | MasterCorporateUser;
|
||||
};
|
||||
|
||||
export const getGroups = async () => {
|
||||
|
||||
Reference in New Issue
Block a user