Compare commits
11 Commits
release/as
...
bugfix/mon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c1c4489f8 | ||
|
|
044ec8d966 | ||
|
|
07c9074d15 | ||
|
|
71bac76c3a | ||
|
|
fb293dc98c | ||
|
|
5153c3d5f1 | ||
|
|
392eac2ef9 | ||
|
|
a073ca1cce | ||
|
|
7e30ca5750 | ||
|
|
2e065eddcb | ||
|
|
4e91b2f1fb |
@@ -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">
|
<div className="flex w-fit cursor-pointer flex-col items-center gap-1">
|
||||||
<button
|
<button
|
||||||
onClick={() => window.location.reload()}
|
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">
|
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" />
|
<BsArrowCounterclockwise className="h-7 w-7 text-white" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
await db.collection("stats").updateOne(
|
await db.collection("stats").updateOne(
|
||||||
{ id: (req.body as Body).id },
|
{ id: (req.body as Body).id },
|
||||||
{
|
{
|
||||||
|
$set: {
|
||||||
id: (req.body as Body).id,
|
id: (req.body as Body).id,
|
||||||
solutions,
|
solutions,
|
||||||
score: {
|
score: {
|
||||||
@@ -48,6 +49,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
missing: 0,
|
missing: 0,
|
||||||
},
|
},
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ async function registerIndividual(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
...(passport_id ? {demographicInformation: {passport_id}} : {}),
|
...(passport_id ? {demographicInformation: {passport_id}} : {}),
|
||||||
registrationDate: new Date().toISOString(),
|
registrationDate: new Date().toISOString(),
|
||||||
status: code ? "active" : "paymentDue",
|
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);
|
await db.collection("users").insertOne(user);
|
||||||
@@ -117,6 +120,9 @@ async function registerCorporate(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
subscriptionExpirationDate: req.body.subscriptionExpirationDate || null,
|
subscriptionExpirationDate: req.body.subscriptionExpirationDate || null,
|
||||||
status: "paymentDue",
|
status: "paymentDue",
|
||||||
registrationDate: new Date().toISOString(),
|
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 = {
|
const defaultTeachersGroup: Group = {
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ async function GET(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const snapshot = await db.collection("stats").findOne({ id: id as string});
|
const snapshot = await db.collection("stats").findOne({ id: id as string});
|
||||||
if (!snapshot) return res.status(404).json({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});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
delete updatedUser.password;
|
delete updatedUser.password;
|
||||||
delete updatedUser.newPassword;
|
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) {
|
if (!queryId) {
|
||||||
req.session.user = updatedUser ? {...updatedUser, id: req.session.user.id} : null;
|
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);
|
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 = {
|
export const config = {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default function Home({user: propsUser, linkedCorporate}: Props) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user) {
|
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");
|
setShowDiagnostics(user.isFirstLogin && user.type === "student");
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import client from "@/lib/mongodb";
|
|||||||
const db = client.db(process.env.MONGODB_DB);
|
const db = client.db(process.env.MONGODB_DB);
|
||||||
|
|
||||||
export async function getUsers() {
|
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> {
|
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;
|
return !!user ? user : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export async function getSpecificUsers(ids: string[]) {
|
|||||||
|
|
||||||
return await db
|
return await db
|
||||||
.collection("users")
|
.collection("users")
|
||||||
.find<User>({id: {$in: ids}})
|
.find<User>({id: {$in: ids}}, { projection: { _id: 0 } })
|
||||||
.toArray();
|
.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user