ENCOA-272

This commit is contained in:
Tiago Ribeiro
2024-12-11 11:58:52 +00:00
parent 6a6c4661c4
commit d074ec390c
46 changed files with 1940 additions and 6423 deletions

View File

@@ -310,19 +310,17 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
if (groups.length > 0) {
const admins = await db.collection("users")
.find<CorporateUser>({ id: { $in: groups.map(g => g.admin).map(id => id)} })
.find<CorporateUser>({ id: { $in: groups.map(g => g.admin).map(id => id) } })
.toArray();
const adminData = admins.find((a) => a.corporateInformation?.companyInformation?.name);
const adminData = admins.find((a) => a.name);
if (adminData) {
return adminData.corporateInformation.companyInformation.name;
return adminData.name;
}
}
}
if (assignerUser.type === "corporate" && assignerUser.corporateInformation?.companyInformation?.name) {
return assignerUser.corporateInformation.companyInformation.name;
}
return assignerUser.type
}
} catch (err) {
console.error(err);
@@ -372,16 +370,16 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
// update the stats entries with the pdf url to prevent duplication
await db.collection("assignments").updateOne(
{ id: data.id },
{
$set: {
pdf: {
path: refName,
version: process.env.PDF_VERSION,
{
$set: {
pdf: {
path: refName,
version: process.env.PDF_VERSION,
}
}
}
}
);
);
const url = await getDownloadURL(fileRef);
res.status(200).end(url);
return;