Compare commits

...

11 Commits

Author SHA1 Message Date
Carlos-Mesquita
3c1c4489f8 Updated user had only demographicInformation and was causing the diagnostic view to not show up after submitting the info 2024-10-01 17:11:04 +01:00
Carlos-Mesquita
044ec8d966 Added back the demographic view 2024-10-01 15:34:56 +01:00
Carlos Mesquita
07c9074d15 More bugs, some updates where not using set 2024-09-23 01:09:34 +01:00
Carlos Mesquita
71bac76c3a More mongodb migration bugs, remove _id from find, and a stat endpoint firebase leftover bug 2024-09-23 00:04:06 +01:00
carlos.mesquita
fb293dc98c Merged main into bugfix/mongo-migration-bugs 2024-09-22 22:47:23 +00:00
Tiago Ribeiro
5153c3d5f1 Merge branch 'main' into develop 2024-09-09 17:52:04 +01:00
Tiago Ribeiro
392eac2ef9 Merge branch 'main' into develop 2024-09-08 19:57:57 +01:00
Joao Ramos
a073ca1cce Temporarily disabled Play Again button 2024-09-08 13:56:08 +01:00
João Ramos
7e30ca5750 Merged in bug-fixing-8-sep-24_2 (pull request #100)
Bug fixing 8 sep 24 2

Approved-by: Tiago Ribeiro
2024-09-08 09:22:05 +00:00
Joao Ramos
2e065eddcb Added an workaround for the broken email system 2024-09-08 10:19:49 +01:00
Joao Ramos
4e91b2f1fb ENCOA-202: Fixed issue updating user 2024-09-08 10:08:24 +01:00
7 changed files with 38 additions and 28 deletions

View File

@@ -287,7 +287,9 @@ export default function Finish({user, scores, modules, information, solutions, i
<div className="flex w-fit cursor-pointer flex-col items-center gap-1">
<button
onClick={() => window.location.reload()}
disabled={user.type === "admin"}
// disabled={user.type === "admin"}
// TODO: temporarily disabled
disabled
className="bg-mti-purple-light hover:bg-mti-purple flex h-11 w-11 items-center justify-center rounded-full transition duration-300 ease-in-out">
<BsArrowCounterclockwise className="h-7 w-7 text-white" />
</button>

View File

@@ -40,6 +40,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
await db.collection("stats").updateOne(
{ id: (req.body as Body).id },
{
$set: {
id: (req.body as Body).id,
solutions,
score: {
@@ -48,6 +49,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
missing: 0,
},
isDisabled: false,
}
},
{ upsert: true },
);

View File

@@ -72,6 +72,9 @@ async function registerIndividual(req: NextApiRequest, res: NextApiResponse) {
...(passport_id ? {demographicInformation: {passport_id}} : {}),
registrationDate: new Date().toISOString(),
status: code ? "active" : "paymentDue",
// apparently there's an issue with the verification email system
// therefore we will skip this requirement for now
isVerified: true,
};
await db.collection("users").insertOne(user);
@@ -117,6 +120,9 @@ async function registerCorporate(req: NextApiRequest, res: NextApiResponse) {
subscriptionExpirationDate: req.body.subscriptionExpirationDate || null,
status: "paymentDue",
registrationDate: new Date().toISOString(),
// apparently there's an issue with the verification email system
// therefore we will skip this requirement for now
isVerified: true,
};
const defaultTeachersGroup: Group = {

View File

@@ -16,5 +16,5 @@ async function GET(req: NextApiRequest, res: NextApiResponse) {
const snapshot = await db.collection("stats").findOne({ id: id as string});
if (!snapshot) return res.status(404).json({id: id as string});
res.status(200).json({...snapshot.data(), id: snapshot.id});
res.status(200).json({...snapshot, id: snapshot.id});
}

View File

@@ -158,7 +158,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
delete updatedUser.password;
delete updatedUser.newPassword;
await db.collection("users").updateOne({id: queryId}, {$set: updatedUser});
await db.collection("users").updateOne({id: queryId ? (queryId as string) : req.session.user.id}, {$set: updatedUser});
if (!queryId) {
req.session.user = updatedUser ? {...updatedUser, id: req.session.user.id} : null;
@@ -169,7 +169,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
await managePaymentRecords({...updatedUser, id: req.session.user!.id}, queryId);
}
res.status(200).json({user: {...updatedUser, id: req.session.user!.id}});
res.status(200).json({user: {...updatedUser, ...user, id: req.session.user!.id}});
}
export const config = {

View File

@@ -79,7 +79,7 @@ export default function Home({user: propsUser, linkedCorporate}: Props) {
useEffect(() => {
if (user) {
// setShowDemographicInput(!user.demographicInformation || !user.demographicInformation.country || !user.demographicInformation.phone);
setShowDemographicInput(!user.demographicInformation || !user.demographicInformation.country || !user.demographicInformation.phone);
setShowDiagnostics(user.isFirstLogin && user.type === "student");
}
}, [user]);

View File

@@ -8,11 +8,11 @@ import client from "@/lib/mongodb";
const db = client.db(process.env.MONGODB_DB);
export async function getUsers() {
return await db.collection("users").find<User>({}).toArray();
return await db.collection("users").find<User>({}, { projection: { _id: 0 } }).toArray();
}
export async function getUser(id: string): Promise<User | undefined> {
const user = await db.collection("users").findOne<User>({id});
const user = await db.collection("users").findOne<User>({id: id}, { projection: { _id: 0 } });
return !!user ? user : undefined;
}
@@ -21,7 +21,7 @@ export async function getSpecificUsers(ids: string[]) {
return await db
.collection("users")
.find<User>({id: {$in: ids}})
.find<User>({id: {$in: ids}}, { projection: { _id: 0 } })
.toArray();
}