diff --git a/package-lock.json b/package-lock.json index fae5bf2..832ccb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3288,9 +3288,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.2.78", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.78.tgz", - "integrity": "sha512-qOwdPnnitQY4xKlKayt42q5W5UQrSHjgoXNVEtxeqdITJ99k4VXJOP3vt8Rkm9HmgJpH50UNU+rlqfkfWOqp0A==", + "version": "18.2.79", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.79.tgz", + "integrity": "sha512-RwGAGXPl9kSXwdNTafkOEuFrTBD5SA2B3iEB96xi8+xu5ddUa/cpvyVCSNn+asgLCTHkb5ZxN8gbuibYJi4s1w==", "dev": true, "dependencies": { "@types/prop-types": "*", @@ -4175,7 +4175,7 @@ }, "node_modules/bookem-shared": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/ChangePlusPlusVandy/bookem-shared.git#42a17e1d1c961fb08cd44cad351b7266c8774616", + "resolved": "git+ssh://git@github.com/ChangePlusPlusVandy/bookem-shared.git#526c66db3beb77a2570b5fbbff90941e5040531e", "license": "ISC", "dependencies": { "mongoose": "^6.8.3" @@ -5049,9 +5049,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.736", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.736.tgz", - "integrity": "sha512-Rer6wc3ynLelKNM4lOCg7/zPQj8tPOCB2hzD32PX9wd3hgRRi9MxEbmkFCokzcEhRVMiOVLjnL9ig9cefJ+6+Q==", + "version": "1.4.737", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.737.tgz", + "integrity": "sha512-QvLTxaLHKdy5YxvixAw/FfHq2eWLUL9KvsPjp0aHK1gI5d3EDuDgITkvj0nFO2c6zUY3ZqVAJQiBYyQP9tQpfw==", "dev": true }, "node_modules/emittery": { diff --git a/pages/api/admin/index.ts b/pages/api/admin/index.ts index 9ace6a9..4129bcb 100644 --- a/pages/api/admin/index.ts +++ b/pages/api/admin/index.ts @@ -33,11 +33,10 @@ export default async function handler( case 'POST': try { if (session.user.status !== 'superadmin') { - res.status(200).json({ + return res.status(200).json({ message: 'Sorry, only super admin is allowed to create new admins', status: 'error', }); - throw new Error('Only super admin is allowed to create new admins'); } // start a try catch block to catch any errors in parsing the request body const admin = req.body as QueriedAdminData; @@ -47,7 +46,7 @@ export default async function handler( // Check if the user's email and password are valid if (!email || !email.includes('@') || !password) { - res + return res .status(200) .json({ message: 'Invalid email or password', status: 'error' }); } @@ -62,10 +61,9 @@ export default async function handler( // If the user already exists, return an error if (checkExisting) { - res + return res .status(200) .json({ message: 'Admin email already exists', status: 'error' }); - throw new Error('Admin email already exists'); } // Hash the user's password diff --git a/pages/api/volunteer-logs/approved.ts b/pages/api/volunteer-logs/approved.ts index b443ae2..09d88e7 100644 --- a/pages/api/volunteer-logs/approved.ts +++ b/pages/api/volunteer-logs/approved.ts @@ -1,4 +1,6 @@ import dbConnect from '@/lib/dbConnect'; +import Users from 'bookem-shared/src/models/Users'; +import VolunteerEvents from 'bookem-shared/src/models/VolunteerEvents'; import VolunteerLogs from 'bookem-shared/src/models/VolunteerLogs'; import { QueriedVolunteerLogDTO } from 'bookem-shared/src/types/database'; import { NextApiRequest, NextApiResponse } from 'next'; @@ -14,6 +16,8 @@ export default async function handler( await dbConnect(); // TODO: remove this after development + await Users.find(); + await VolunteerEvents.find(); const logs = (await VolunteerLogs.find({ status: 'approved' }) .populate({ path: 'user' }) diff --git a/pages/api/volunteer-logs/index.ts b/pages/api/volunteer-logs/index.ts index d5bbec7..12757f0 100644 --- a/pages/api/volunteer-logs/index.ts +++ b/pages/api/volunteer-logs/index.ts @@ -18,6 +18,8 @@ export default async function handler( await dbConnect(); // TODO: remove this after development + await Users.find(); + await VolunteerEvents.find(); const logs = (await VolunteerLogs.find() .populate({ path: 'user' }) diff --git a/pages/api/volunteer-logs/pending.ts b/pages/api/volunteer-logs/pending.ts index 01ac11d..de0ce94 100644 --- a/pages/api/volunteer-logs/pending.ts +++ b/pages/api/volunteer-logs/pending.ts @@ -1,4 +1,6 @@ import dbConnect from '@/lib/dbConnect'; +import Users from 'bookem-shared/src/models/Users'; +import VolunteerEvents from 'bookem-shared/src/models/VolunteerEvents'; import VolunteerLogs from 'bookem-shared/src/models/VolunteerLogs'; import { QueriedVolunteerLogDTO } from 'bookem-shared/src/types/database'; import { NextApiRequest, NextApiResponse } from 'next'; @@ -14,6 +16,8 @@ export default async function handler( await dbConnect(); // TODO: remove this after development + await Users.find(); + await VolunteerEvents.find(); const logs = (await VolunteerLogs.find({ status: 'pending' }) .populate({ path: 'user' }) diff --git a/pages/api/volunteer-logs/rejected.ts b/pages/api/volunteer-logs/rejected.ts index 300bdd1..5d78328 100644 --- a/pages/api/volunteer-logs/rejected.ts +++ b/pages/api/volunteer-logs/rejected.ts @@ -1,4 +1,6 @@ import dbConnect from '@/lib/dbConnect'; +import Users from 'bookem-shared/src/models/Users'; +import VolunteerEvents from 'bookem-shared/src/models/VolunteerEvents'; import VolunteerLogs from 'bookem-shared/src/models/VolunteerLogs'; import { QueriedVolunteerLogDTO } from 'bookem-shared/src/types/database'; import { NextApiRequest, NextApiResponse } from 'next'; @@ -14,6 +16,8 @@ export default async function handler( await dbConnect(); // TODO: remove this after development + await Users.find(); + await VolunteerEvents.find(); const logs = (await VolunteerLogs.find({ status: 'rejected' }) .populate({ path: 'user' })