diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 8394c071..ccdcd678 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
+- Using welcoming and inclusive language
+- Being respectful of differing viewpoints and experiences
+- Gracefully accepting constructive criticism
+- Focusing on what is best for the community
+- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
-* The use of sexualized language or imagery and unwelcome sexual attention or
- advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
+- The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+- Trolling, insulting/derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
## Our Responsibilities
diff --git a/api/admin.js b/api/admin.js
index 28a84754..af6d7862 100644
--- a/api/admin.js
+++ b/api/admin.js
@@ -16,8 +16,8 @@ router.use(utils.requireAdmin);
router.put("/:email", async (req, res) => {
const updatedhackerProfile = await models.HackerProfile.update(req.body, {
where: {
- email: req.params.email
- }
+ email: req.params.email,
+ },
});
return res.json({ hackerProfile: newHackerProfile });
});
@@ -33,25 +33,25 @@ router.get("/profiles", async (req, res) => {
[Op.or]: [
{
email: {
- [Op.like]: flexQuery
- }
+ [Op.like]: flexQuery,
+ },
},
{
firstName: {
- [Op.like]: flexQuery
- }
+ [Op.like]: flexQuery,
+ },
},
{
lastName: {
- [Op.like]: flexQuery
- }
- }
- ]
+ [Op.like]: flexQuery,
+ },
+ },
+ ],
},
- limit: 50
+ limit: 50,
});
return res.json({
- profiles
+ profiles,
});
} catch (e) {
return res.status(500).json({ error: e.message });
@@ -63,12 +63,12 @@ router.post("/updateRole", async (req, res) => {
const { email, role } = req.body;
const result = await models.HackerProfile.update(
{
- role: role
+ role: role,
},
{
where: {
- email: email
- }
+ email: email,
+ },
}
);
@@ -91,8 +91,8 @@ router.get("/reviewHistory", async (req, res) => {
try {
const reviews = await models.HackerReview.findAll({
where: {
- createdBy: req.user.id
- }
+ createdBy: req.user.id,
+ },
});
return res.json({ reviews: reviews });
} catch (e) {
@@ -106,14 +106,14 @@ router.put("/review/:id", async (req, res) => {
"scoreOne",
"scoreTwo",
"scoreThree",
- "comments"
+ "comments",
]);
const formInput = req.body;
for (let key of Object.keys(formInput)) {
if (!allowedFields.has(key)) {
return res.status(400).json({
- error: `${key} is not a supported field`
+ error: `${key} is not a supported field`,
});
}
}
@@ -121,14 +121,14 @@ router.put("/review/:id", async (req, res) => {
try {
const result = await models.HackerReview.update(req.body, {
where: {
- id: requestId
- }
+ id: requestId,
+ },
});
return res.json({ update: result });
} catch (e) {
return res.status(500).json({
- error: e
+ error: e,
});
}
});
@@ -138,23 +138,23 @@ router.get("/eligibleProfiles", async (req, res) => {
const allProfiles = await models.HackerProfile.findAll({
where: {
submittedAt: {
- [sequelize.Op.not]: null
- }
+ [sequelize.Op.not]: null,
+ },
},
include: [
{
- model: models.HackerReview
- }
- ]
+ model: models.HackerReview,
+ },
+ ],
});
- filteredProfiles = allProfiles.filter(profile => {
- const reviewsByCurrUser = profile.HackerReviews.filter(review => {
+ filteredProfiles = allProfiles.filter((profile) => {
+ const reviewsByCurrUser = profile.HackerReviews.filter((review) => {
return review.dataValues.createdBy === req.user.id;
});
return reviewsByCurrUser.length === 0 && profile.HackerReviews.length < 1;
});
return res.json({
- eligibleReviews: filteredProfiles
+ eligibleReviews: filteredProfiles,
});
} catch (e) {
return res.status(500).json({ error: e.message });
@@ -170,7 +170,7 @@ router.post("/review", async (req, res) => {
scoreOne: formBody.scoreOne,
scoreTwo: formBody.scoreTwo,
scoreThree: formBody.scoreThree,
- comments: formBody.comments
+ comments: formBody.comments,
});
return res.json({ newReview: newReview });
@@ -186,31 +186,31 @@ router.get("/review", async (req, res) => {
include: [
[
sequelize.fn("COUNT", sequelize.col("HackerReviews.id")),
- "reviewCount"
- ]
- ]
+ "reviewCount",
+ ],
+ ],
},
include: [
{
model: models.HackerReview,
- attributes: []
- }
+ attributes: [],
+ },
],
- group: ["HackerProfile.userId"]
+ group: ["HackerProfile.userId"],
});
- const acceptableProfile = profilesWCount.find(profile => {
+ const acceptableProfile = profilesWCount.find((profile) => {
return profile.dataValues.reviewCount < 1;
});
if (acceptableProfile) {
const newReview = await models.HackerReview.create({
hackerId: acceptableProfile.dataValues.userId,
- createdBy: req.user.id
+ createdBy: req.user.id,
});
return res.json({
review: newReview,
- profile: acceptableProfile
+ profile: acceptableProfile,
});
} else {
return res.json({ review: null, profile: null }); // Returns empty when there are no more profiles
diff --git a/api/apis.js b/api/apis.js
index c4816405..733a19c2 100644
--- a/api/apis.js
+++ b/api/apis.js
@@ -10,9 +10,9 @@ router.get("/", async (req, res) => {
include: [
{
model: models.ApiLinks,
- as: "links"
- }
- ]
+ as: "links",
+ },
+ ],
});
return res.json({ success: apis });
@@ -22,14 +22,14 @@ router.get("/event", async (req, res) => {
let id = parseInt(Object.keys(req.query)[0].split(",")[1]);
const apis = await models.Apis.findAll({
where: {
- major_event: id
+ major_event: id,
},
include: [
{
model: models.ApiLinks,
- as: "links"
- }
- ]
+ as: "links",
+ },
+ ],
});
return res.json({ success: apis });
diff --git a/api/database/migrations/20200127000435-modify-role-superadmin-volunteer.js b/api/database/migrations/20200127000435-modify-role-superadmin-volunteer.js
index f7b35e27..37e21b2e 100644
--- a/api/database/migrations/20200127000435-modify-role-superadmin-volunteer.js
+++ b/api/database/migrations/20200127000435-modify-role-superadmin-volunteer.js
@@ -5,7 +5,7 @@ module.exports = {
return queryInterface.changeColumn("HackerProfiles", "role", {
type: Sequelize.ENUM,
values: ["hacker", "admin", "sponsor", "volunteer"],
- defaultValue: "hacker"
+ defaultValue: "hacker",
});
},
@@ -13,7 +13,7 @@ module.exports = {
return queryInterface.changeColumn("HackerProfiles", "role", {
type: Sequelize.ENUM,
values: ["hacker", "admin", "sponsor", "superadmin"],
- defaultValue: "hacker"
+ defaultValue: "hacker",
});
- }
+ },
};
diff --git a/api/database/migrations/20201012041027-api-directory.js b/api/database/migrations/20201012041027-api-directory.js
index c872194c..47122da5 100644
--- a/api/database/migrations/20201012041027-api-directory.js
+++ b/api/database/migrations/20201012041027-api-directory.js
@@ -7,23 +7,23 @@ module.exports = {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
name: {
type: Sequelize.STRING,
- allowNull: false
+ allowNull: false,
},
link: {
type: Sequelize.STRING,
- allowNull: false
+ allowNull: false,
},
api_id: {
type: Sequelize.INTEGER,
- allowNull: false
- }
+ allowNull: false,
+ },
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable("ApiLinks");
- }
+ },
};
diff --git a/api/database/migrations/20201012041350-apis.js b/api/database/migrations/20201012041350-apis.js
index cc341a39..5bebc1b6 100644
--- a/api/database/migrations/20201012041350-apis.js
+++ b/api/database/migrations/20201012041350-apis.js
@@ -7,23 +7,23 @@ module.exports = {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
name: {
type: Sequelize.STRING,
- allowNull: false
+ allowNull: false,
},
description: {
type: Sequelize.BLOB,
- allowNull: false
+ allowNull: false,
},
major_event: {
type: Sequelize.BOOLEAN,
- allowNull: false
- }
+ allowNull: false,
+ },
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable("Apis");
- }
+ },
};
diff --git a/api/database/migrations/20201012041524-major_events.js b/api/database/migrations/20201012041524-major_events.js
index c862a023..cc4ee377 100644
--- a/api/database/migrations/20201012041524-major_events.js
+++ b/api/database/migrations/20201012041524-major_events.js
@@ -7,27 +7,27 @@ module.exports = {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
name: {
type: Sequelize.STRING,
- allowNull: false
+ allowNull: false,
},
isHackathon: {
type: Sequelize.BOOLEAN,
- allowNull: false
+ allowNull: false,
},
start_date: {
type: Sequelize.DATE,
- allowNull: false
+ allowNull: false,
},
end_date: {
type: Sequelize.DATE,
- allowNull: false
- }
+ allowNull: false,
+ },
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable("MajorEvents");
- }
+ },
};
diff --git a/api/database/migrations/20201012051044-change_api_description.js b/api/database/migrations/20201012051044-change_api_description.js
index 42817d9a..0df92d59 100644
--- a/api/database/migrations/20201012051044-change_api_description.js
+++ b/api/database/migrations/20201012051044-change_api_description.js
@@ -4,16 +4,16 @@ module.exports = {
up: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.changeColumn("Apis", "description", {
- type: Sequelize.STRING
- })
+ type: Sequelize.STRING,
+ }),
]);
},
down: (queryInterface, Sequelize) => {
return Promise.all([
queryInterface.changeColumn("Apis", "description", {
- type: Sequelize.BLOB
- })
+ type: Sequelize.BLOB,
+ }),
]);
- }
+ },
};
diff --git a/api/models/apiLinks.js b/api/models/apiLinks.js
index 66ba3a68..3464e961 100644
--- a/api/models/apiLinks.js
+++ b/api/models/apiLinks.js
@@ -9,18 +9,18 @@ module.exports = (sequelize, DataTypes) => {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
name: DataTypes.STRING,
link: DataTypes.STRING,
- api_id: DataTypes.INTEGER
+ api_id: DataTypes.INTEGER,
},
{
- timestamps: false
+ timestamps: false,
}
);
- ApiLinks.associate = function(models) {
+ ApiLinks.associate = function (models) {
ApiLinks.belongsTo(models.Apis, { foreignKey: "api_id" });
};
diff --git a/api/models/apis.js b/api/models/apis.js
index 371a86c7..e5ed4c60 100644
--- a/api/models/apis.js
+++ b/api/models/apis.js
@@ -10,18 +10,18 @@ module.exports = (sequelize, DataTypes) => {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
name: DataTypes.STRING,
description: DataTypes.STRING,
- major_event: DataTypes.INTEGER
+ major_event: DataTypes.INTEGER,
},
{
- timestamps: false
+ timestamps: false,
}
);
- Apis.associate = function(models) {
+ Apis.associate = function (models) {
Apis.hasMany(models.ApiLinks, { as: "links", foreignKey: "api_id" });
};
diff --git a/api/models/majorEvents.js b/api/models/majorEvents.js
index 1d8ba59b..25640b54 100644
--- a/api/models/majorEvents.js
+++ b/api/models/majorEvents.js
@@ -8,15 +8,15 @@ module.exports = (sequelize, DataTypes) => {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
name: DataTypes.STRING,
isHackathon: DataTypes.BOOLEAN,
start_date: DataTypes.DATE,
- end_date: DataTypes.DATE
+ end_date: DataTypes.DATE,
},
{
- timestamps: false
+ timestamps: false,
}
);
diff --git a/api/models/signups.js b/api/models/signups.js
index 35d22b50..0567b5eb 100644
--- a/api/models/signups.js
+++ b/api/models/signups.js
@@ -8,24 +8,24 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
- allowNull: false
+ allowNull: false,
},
email: {
type: DataTypes.STRING,
- allowNull: false
+ allowNull: false,
},
ip: {
type: DataTypes.STRING,
- allowNull: false
+ allowNull: false,
},
created_at: {
type: DataTypes.DATE,
- allowNull: false
- }
+ allowNull: false,
+ },
},
{ timestamps: false }
);
- signups.prototype.getSignUps = function() {
+ signups.prototype.getSignUps = function () {
return sequelize.models.signups.findAll({});
};
return signups;
diff --git a/api/points.js b/api/points.js
index c1cb3a5d..b9ebd1e4 100644
--- a/api/points.js
+++ b/api/points.js
@@ -29,13 +29,13 @@ router.post("/tasks", async (req, res) => {
"isGroupTask",
"isActive",
"type",
- "isPast"
+ "isPast",
]);
const formInput = req.body;
for (let key of Object.keys(formInput)) {
if (!allowedFields.has(key)) {
return res.status(400).json({
- error: `${key} is not a supported field`
+ error: `${key} is not a supported field`,
});
}
}
@@ -67,8 +67,8 @@ router.delete("/tasks/:id", async (req, res) => {
const id = req.params.id;
await models.Task.destroy({
where: {
- id: id
- }
+ id: id,
+ },
});
return res.status(200);
} catch (e) {
diff --git a/api/projectTeam.js b/api/projectTeam.js
index 32de8a29..33bd3596 100644
--- a/api/projectTeam.js
+++ b/api/projectTeam.js
@@ -6,11 +6,11 @@ const router = express.Router();
router.use(utils.authMiddleware);
router.use(utils.preprocessRequest);
-const getProjectTeamForSelf = async req => {
+const getProjectTeamForSelf = async (req) => {
const { id } = req.user;
const person = await models.Person.findByPk(id, {
- include: [{ model: models.ProjectTeam, required: false }]
+ include: [{ model: models.ProjectTeam, required: false }],
});
if (person) {
return person.ProjectTeam;
@@ -18,11 +18,11 @@ const getProjectTeamForSelf = async req => {
return person;
};
-const getPersonForQRID = async qrCodeId => {
+const getPersonForQRID = async (qrCodeId) => {
const hackerProfile = await models.HackerProfile.findOne({
where: {
- qrCodeId: qrCodeId
- }
+ qrCodeId: qrCodeId,
+ },
});
const userId = hackerProfile.get("userId");
const person = await models.Person.findByPk(userId);
@@ -37,12 +37,12 @@ router.get("/self", async (req, res) => {
router.put("/join/:name", async (req, res) => {
const { name } = req.params;
let projectTeam = await models.ProjectTeam.findOne({
- where: { name }
+ where: { name },
});
if (!projectTeam) {
return res.status(400).json({
- error: `Team: ${name} not found`
+ error: `Team: ${name} not found`,
});
}
@@ -53,7 +53,7 @@ router.put("/join/:name", async (req, res) => {
await projectTeam.addMember(req.user.id);
projectTeam = await models.ProjectTeam.findOne({
- where: { name }
+ where: { name },
});
return res.json({ success: projectTeam });
@@ -80,9 +80,9 @@ router.post("/self", async (req, res) => {
return res.status(400).json({ error: "Already has a team" });
}
- const result = await models.sequelize.transaction(async t => {
+ const result = await models.sequelize.transaction(async (t) => {
const projectTeam = await models.ProjectTeam.create(body, {
- transaction: t
+ transaction: t,
});
await person.setProjectTeam(projectTeam, { transaction: t });
@@ -134,7 +134,7 @@ router.delete("/self/deletePrize/:prizeID", async (req, res) => {
await projectTeam.removePrize(prizeID);
await projectTeam.save();
projectTeam = await models.ProjectTeam.findOne({
- where: { name }
+ where: { name },
});
return res.json({ success: projectTeam });
});
diff --git a/api/tasks.js b/api/tasks.js
index 5139c37c..c0fdb067 100644
--- a/api/tasks.js
+++ b/api/tasks.js
@@ -15,31 +15,31 @@ router.get("/list", utils.requireNonHacker, async (req, res) => {
if (req.user.role && req.user.role === "admin") {
filter.push({
- type: "admin"
+ type: "admin",
});
filter.push({
- type: "volunteer"
+ type: "volunteer",
});
filter.push({
- type: "sponsor"
+ type: "sponsor",
});
} else if (req.user.role && req.user.role === "volunteer") {
filter.push({
- type: "volunteer"
+ type: "volunteer",
});
filter.push({
- type: "sponsor"
+ type: "sponsor",
});
} else if (req.user.role && req.user.role === "sponsor") {
filter.push({
- type: "sponsor"
+ type: "sponsor",
});
}
const tasks = await models.Task.findAll({
where: {
- [Op.or]: filter
- }
+ [Op.or]: filter,
+ },
});
return res.json({ success: tasks });
@@ -52,14 +52,14 @@ router.post("/create", utils.requireAdmin, async (req, res) => {
"points",
"name",
"isGroupTask",
- "isActive"
+ "isActive",
]);
const formInput = req.body;
for (let key of Object.keys(formInput)) {
if (!allowedFields.has(key)) {
return res.status(400).json({
- error: `${key} is not a supported field`
+ error: `${key} is not a supported field`,
});
}
}
@@ -79,8 +79,8 @@ router.delete("/:id", utils.requireAdmin, async (req, res) => {
const id = req.params.id;
await models.Task.destroy({
where: {
- id: id
- }
+ id: id,
+ },
});
return res.json({ success: null });
});
diff --git a/api/team.js b/api/team.js
index 8a2b55df..e75dcef6 100644
--- a/api/team.js
+++ b/api/team.js
@@ -10,23 +10,23 @@ router.use(utils.preprocessRequest);
// - If a hacker is on a team, get that team info
router.get("/", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
const team = await hackerProfile.getTeam({
include: [
{
model: models.HackerProfile,
- attributes: ["firstName", "lastName", "status", "email", "userId"]
- }
- ]
+ attributes: ["firstName", "lastName", "status", "email", "userId"],
+ },
+ ],
});
if (team) {
return res.json({ team });
} else {
return res.json({
- message: "User does not currently belong to a team"
+ message: "User does not currently belong to a team",
});
}
});
@@ -36,7 +36,7 @@ router.get("/", async (req, res) => {
router.get("/:code", async (req, res) => {
// Try to find a team with the provided code
const team = await models.Team.findOne({
- where: { teamCode: req.params.code || "" }
+ where: { teamCode: req.params.code || "" },
});
if (!team) {
return res
@@ -51,7 +51,7 @@ router.get("/:code", async (req, res) => {
// - If a hacker is not on a team, create a team
router.post("/", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
let team = await hackerProfile.getTeam();
@@ -59,35 +59,29 @@ router.post("/", async (req, res) => {
return res.status(500).json({ message: "User already belongs on a team" });
}
- let generatedCode = Math.random()
- .toString(36)
- .slice(4, 8)
- .toUpperCase();
+ let generatedCode = Math.random().toString(36).slice(4, 8).toUpperCase();
while (
await models.Team.findOne({
- where: { teamCode: generatedCode }
+ where: { teamCode: generatedCode },
})
) {
// Regenerate code
- generatedCode = Math.random()
- .toString(36)
- .slice(4, 8)
- .toUpperCase();
+ generatedCode = Math.random().toString(36).slice(4, 8).toUpperCase();
}
team = await models.Team.create({
name: req.body.name,
teamCode: generatedCode,
- ownerId: req.user.id
+ ownerId: req.user.id,
});
await hackerProfile.update({
- teamId: team.id
+ teamId: team.id,
});
return res.json({
- team
+ team,
});
});
@@ -95,7 +89,7 @@ router.post("/", async (req, res) => {
// - Attempts to delete a user's current team
router.delete("/", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
// Can't join a team if you're already on one!
@@ -123,7 +117,7 @@ router.delete("/", async (req, res) => {
// - If a hacker is not on a team, attempt to join a team
router.post("/join/:code", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
// Can't join a team if you're already on one!
@@ -134,7 +128,7 @@ router.post("/join/:code", async (req, res) => {
// Try to find a team with the provided code
team = await models.Team.findOne({
- where: { teamCode: req.params.code || "" }
+ where: { teamCode: req.params.code || "" },
});
if (!team) {
return res
@@ -153,7 +147,7 @@ router.post("/join/:code", async (req, res) => {
await hackerProfile.setTeam(team);
return res.status(200).json({
- message: "Successfully joined team"
+ message: "Successfully joined team",
});
});
@@ -161,7 +155,7 @@ router.post("/join/:code", async (req, res) => {
// - If a hacker is not on a team, attempt to join a team
router.post("/kick/:userid", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
// Can't kick someone else from a team if you are not on a team!
@@ -172,14 +166,14 @@ router.post("/kick/:userid", async (req, res) => {
if (team.ownerId === req.params.userid) {
return res.status(400).json({
- message: `Not allowed to kick yourself. Delete the team instead.`
+ message: `Not allowed to kick yourself. Delete the team instead.`,
});
}
if (team.ownerId === req.user.id) {
// Allow kicking
const kickProfile = await models.HackerProfile.findOne({
- where: { userId: req.params.userid }
+ where: { userId: req.params.userid },
});
let kicked_team = await hackerProfile.getTeam();
@@ -194,7 +188,7 @@ router.post("/kick/:userid", async (req, res) => {
}
return res.status(400).json({
- message: `Could not kick member with userid ${req.params.userid}.`
+ message: `Could not kick member with userid ${req.params.userid}.`,
});
});
@@ -202,7 +196,7 @@ router.post("/kick/:userid", async (req, res) => {
// - If a hacker is not on a team, attempt to join a team
router.post("/kick/:userid", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
// Can't kick someone else from a team if you are not on a team!
@@ -213,14 +207,14 @@ router.post("/kick/:userid", async (req, res) => {
if (team.ownerId === req.params.userid) {
return res.status(400).json({
- message: `Not allowed to kick yourself. Delete the team instead.`
+ message: `Not allowed to kick yourself. Delete the team instead.`,
});
}
if (team.ownerId === req.user.id) {
// Allow kicking
const kickProfile = await models.HackerProfile.findOne({
- where: { userId: req.params.userid }
+ where: { userId: req.params.userid },
});
let kicked_team = await hackerProfile.getTeam();
@@ -235,7 +229,7 @@ router.post("/kick/:userid", async (req, res) => {
}
return res.status(400).json({
- message: `Could not kick member with userid ${req.params.userid}.`
+ message: `Could not kick member with userid ${req.params.userid}.`,
});
});
@@ -243,7 +237,7 @@ router.post("/kick/:userid", async (req, res) => {
// - If a hacker is on a team, attempt to leave that team
router.post("/leave", async (req, res) => {
const hackerProfile = await models.HackerProfile.findOne({
- where: { userId: req.user.id }
+ where: { userId: req.user.id },
});
// Can't leave a team if you're not in one!
@@ -263,11 +257,11 @@ router.post("/leave", async (req, res) => {
// If we're still here, we can leave the team :)
await hackerProfile.update({
- teamId: null
+ teamId: null,
});
return res.status(200).json({
- message: "Successfully left team"
+ message: "Successfully left team",
});
});
diff --git a/components/AdminStats.tsx b/components/AdminStats.tsx
index f115cf0b..d1c2f30d 100644
--- a/components/AdminStats.tsx
+++ b/components/AdminStats.tsx
@@ -281,9 +281,9 @@ const AdminStats = ({ profile, showtitle = true }) => {
- Genders
+ Preferred Pronouns
- Male:{" "}
+ He/Him/His:{" "}
{profiles && profiles.length > 0
? profiles.reduce((a, b) => a + (b.gender == "male" ? 1 : 0), 0)
@@ -291,7 +291,7 @@ const AdminStats = ({ profile, showtitle = true }) => {
- Female:{" "}
+ She/Her/Hers:{" "}
{profiles && profiles.length > 0
? profiles.reduce(
@@ -302,7 +302,7 @@ const AdminStats = ({ profile, showtitle = true }) => {
- Non-Binary:{" "}
+ They/Them/Theirs:{" "}
{profiles && profiles.length > 0
? profiles.reduce(
diff --git a/components/BattlePass.tsx b/components/BattlePass.tsx
index 808447ec..467839b4 100644
--- a/components/BattlePass.tsx
+++ b/components/BattlePass.tsx
@@ -28,7 +28,7 @@ const bpItem: React.SFC = ({
userPoints = 0,
itemTier = 0,
minimum,
- projSubmitted
+ projSubmitted,
}) => {
let locked = !unlocked;
let showOverlay = false;
@@ -62,13 +62,19 @@ const bpItem: React.SFC = ({
const useBattlepassItems = (bp: Battlepass, userPoints: number) => {
return useMemo(() => {
- const premiumItems = bp && bp.length > 0 ? bp.filter(item => {
- return item.isPremium;
- }) : [];
-
- const basicItems = bp && bp.length > 0 ? bp.filter(item => {
- return !item.isPremium;
- }): [];
+ const premiumItems =
+ bp && bp.length > 0
+ ? bp.filter((item) => {
+ return item.isPremium;
+ })
+ : [];
+
+ const basicItems =
+ bp && bp.length > 0
+ ? bp.filter((item) => {
+ return !item.isPremium;
+ })
+ : [];
if (premiumItems && premiumItems.length > 0) {
premiumItems.reduce(
@@ -120,14 +126,14 @@ const useBattlepassItems = (bp: Battlepass, userPoints: number) => {
basicItems,
premiumItems,
currentTier,
- pointsTillNextTier
+ pointsTillNextTier,
};
}, [bp, userPoints]);
};
const BattlePass = ({
bp,
userPoints,
- projSubmitted
+ projSubmitted,
}: {
bp: Battlepass;
userPoints: number;
@@ -137,7 +143,7 @@ const BattlePass = ({
basicItems,
premiumItems,
currentTier,
- pointsTillNextTier
+ pointsTillNextTier,
} = useBattlepassItems(bp, userPoints || 0);
const bptable = (
@@ -154,7 +160,7 @@ const BattlePass = ({
premium: false,
projSubmitted,
...item,
- currentTier: index === currentTier
+ currentTier: index === currentTier,
})
: "";
})
@@ -173,7 +179,7 @@ const BattlePass = ({
premium: true,
projSubmitted,
...item,
- currentTier: index === currentTier
+ currentTier: index === currentTier,
})
: "";
})
diff --git a/components/Head.tsx b/components/Head.tsx
index 68ec20ce..7c878d86 100644
--- a/components/Head.tsx
+++ b/components/Head.tsx
@@ -32,7 +32,7 @@ const Head = ({ title }: HeadProps) => {
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '2475646642710223');
- fbq('track', 'PageView');`
+ fbq('track', 'PageView');`,
}}
/>
@@ -43,7 +43,7 @@ const Head = ({ title }: HeadProps) => {
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-127488741-2');
- `
+ `,
}}
/>
diff --git a/components/results/Accepted.tsx b/components/results/Accepted.tsx
index 3610e70f..e49b003d 100644
--- a/components/results/Accepted.tsx
+++ b/components/results/Accepted.tsx
@@ -9,7 +9,7 @@ import {
Form,
FormGroup,
RadioChoice,
- RadioChoiceLabel
+ RadioChoiceLabel,
} from "../../styles";
import Select from "../Select";
@@ -26,7 +26,7 @@ const travelOptions = [
{ label: "HackSC Bus", value: "bus" },
{ label: "Flying", value: "flying" },
{ label: "USC Student (N/A)", value: "usc" },
- { label: "Other", value: "other" }
+ { label: "Other", value: "other" },
];
const shirtSizeOptions = [
@@ -34,10 +34,10 @@ const shirtSizeOptions = [
{ label: "Small", value: "s" },
{ label: "Medium", value: "m" },
{ label: "Large", value: "l" },
- { label: "X-Large", value: "xl" }
+ { label: "X-Large", value: "xl" },
];
-const Accepted: React.FunctionComponent = props => {
+const Accepted: React.FunctionComponent = (props) => {
const [travelMethod, setTravelMethod] = useState(null);
const [travelFile, setTravelFile] = useState(null);
@@ -57,13 +57,13 @@ const Accepted: React.FunctionComponent = props => {
nutAllergy: useRef(null),
lactoseIntolerant: useRef(null),
glutenFree: useRef(null),
- other: useRef(null)
+ other: useRef(null),
},
codeOfConduct: useRef(null),
- noBusCheck: useRef(null)
+ noBusCheck: useRef(null),
};
- const checkFile = e => {
+ const checkFile = (e) => {
const { travelPlan } = formRefs;
if (travelPlan.current && !travelPlan.current.files[0]) {
@@ -77,7 +77,7 @@ const Accepted: React.FunctionComponent = props => {
setError(null);
};
- const handleSubmit = async e => {
+ const handleSubmit = async (e) => {
e.preventDefault();
if (submitting) {
@@ -91,7 +91,7 @@ const Accepted: React.FunctionComponent = props => {
shirtSize,
dietaryRestrictions,
codeOfConduct,
- noBusCheck
+ noBusCheck,
} = formRefs;
const reqBody = {
@@ -124,16 +124,16 @@ const Accepted: React.FunctionComponent = props => {
dietaryRestrictions.glutenFree.current.checked,
other:
dietaryRestrictions.other.current &&
- dietaryRestrictions.other.current.value
+ dietaryRestrictions.other.current.value,
},
- noBusCheck: noBusCheck.current && noBusCheck.current.checked
+ noBusCheck: noBusCheck.current && noBusCheck.current.checked,
};
const formData = jsonToFormData(reqBody);
setSubmitting(true);
const response = await fetch("/api/profile/confirm", {
method: "POST",
- body: formData
+ body: formData,
});
setSubmitting(false);
@@ -149,7 +149,7 @@ const Accepted: React.FunctionComponent = props => {
const handleDecline = async () => {
await fetch("/api/profile/decline", {
- method: "POST"
+ method: "POST",
});
await Router.push("/dashboard");
diff --git a/components/steps/Profile.tsx b/components/steps/Profile.tsx
index 94c47670..7ba8dfd4 100644
--- a/components/steps/Profile.tsx
+++ b/components/steps/Profile.tsx
@@ -8,7 +8,7 @@ import {
RadioChoiceLabel,
Flex,
Column,
- Button
+ Button,
} from "../../styles";
import Select from "../Select";
@@ -31,7 +31,7 @@ const yearOptions = [
{ label: "Sophomore", value: "sophomore" },
{ label: "Junior", value: "junior" },
{ label: "Senior", value: "senior" },
- { label: "Graduate", value: "graduate" }
+ { label: "Graduate", value: "graduate" },
];
const gradDateOptions = [
@@ -43,40 +43,40 @@ const gradDateOptions = [
{ label: "Fall 2022", value: "fall-2022" },
{ label: "Spring 2023", value: "spring-2023" },
{ label: "Fall 2023", value: "fall-2023" },
- { label: "Other", value: "other" }
+ { label: "Other", value: "other" },
];
/** TODO: Add Not Listed / custom input option */
const genderOptions = [
- { label: "Male", value: "male" },
- { label: "Female", value: "female" },
- { label: "Non-Binary", value: "non-binary" },
+ { label: "He/Him/His", value: "male" },
+ { label: "She/Her/Hers", value: "female" },
+ { label: "They/Them/Theirs", value: "non-binary" },
{ label: "Other", value: "other" },
- { label: "Prefer not to say", value: "no-say" }
+ { label: "Prefer not to say", value: "no-say" },
];
const skillLevelOptions = [
{
label: "Beginner - First time hacker or still learning",
- value: "beginner"
+ value: "beginner",
},
{
label: "Intermediate - Not your first rodeo but still lots to learn",
- value: "intermediate"
+ value: "intermediate",
},
- { label: "Advanced - Hacker who knows the game", value: "advanced" }
+ { label: "Advanced - Hacker who knows the game", value: "advanced" },
];
-const uploadResume = async resumeFile => {
+const uploadResume = async (resumeFile) => {
var resumeForm = new FormData();
resumeForm.append("file", resumeFile);
await fetch("/api/profile/resume", {
method: "POST",
- body: resumeForm
+ body: resumeForm,
});
};
-const ProfileStep: React.FunctionComponent = props => {
+const ProfileStep: React.FunctionComponent = (props) => {
const { profile } = props;
const [hasChanged, setHasChanged] = useState(
!!profile && !!profile.submittedAt
@@ -114,7 +114,7 @@ const ProfileStep: React.FunctionComponent = props => {
if (process.browser) {
if (hasChanged) {
- window.onbeforeunload = function(event) {
+ window.onbeforeunload = function (event) {
var message =
"Important: Please click on 'Save' button to leave this page.";
if (typeof event == "undefined") {
@@ -133,7 +133,7 @@ const ProfileStep: React.FunctionComponent = props => {
return profile ? (
+
+
+
+ hacksc.com:
+
+
+
+
+
+ staging.hacksc.com:
+
+
+
+
+
+ dashboard.hacksc.com:
+
+
+
+
+
Actions
@@ -98,8 +116,16 @@ Admin.getInitialProps = async (ctx) => {
};
};
+const PaddedSubTitle = styled.h3`
+ margin: 0 1rem 0 0;
+`;
+
+const PaddedFlex = styled(Flex)`
+ margin: 0.25rem 0 0 0;
+`;
+
const ActionsHeader = styled.h2`
- margin: 48px 0 16px;
+ margin: 2rem 0 1rem;
`;
const Actions = styled.div`
diff --git a/pages/api-directory.tsx b/pages/api-directory.tsx
index f55f94cd..106f01f8 100644
--- a/pages/api-directory.tsx
+++ b/pages/api-directory.tsx
@@ -51,7 +51,6 @@ API.getInitialProps = async ({ req }) => {
if (profile && profile.status == "checkedIn") {
//const houseInfo = await getHouseInfo(req, 1);
- //console.log(houseInfo);
}
if (typeof window !== "undefined") {
diff --git a/pages/api/admin.ts b/pages/api/admin.ts
deleted file mode 100644
index c95ffa86..00000000
--- a/pages/api/admin.ts
+++ /dev/null
@@ -1,223 +0,0 @@
-const express = require("express");
-const models = require("./models");
-const utils = require("./utils");
-const router = express.Router();
-const sequelize = require("sequelize");
-const Sentry = require("@sentry/node");
-
-/* This router supports superuser routes, such as updating the status of users */
-
-router.use(utils.authMiddleware);
-router.use(utils.requireAdmin);
-
-// Full write access to a user's hackerProfile
-// Variable parameters in the foremost endpoint path restricts use to just this route.
-// Consider changing route as to not use up all single-path put requests
-router.put("/:email", async (req, res) => {
- const updatedhackerProfile = await models.HackerProfile.update(req.body, {
- where: {
- email: req.params.email,
- },
- });
- return res.json({ hackerProfile: updatedhackerProfile });
-});
-
-// TODO: use the new client fetcher api
-router.get("/profiles", async (req, res) => {
- const Op = sequelize.Op;
- const { query } = req.query;
- const flexQuery = "%" + query + "%";
- try {
- const profiles = await models.HackerProfile.findAll({
- where: {
- [Op.or]: [
- {
- email: {
- [Op.like]: flexQuery,
- },
- },
- {
- firstName: {
- [Op.like]: flexQuery,
- },
- },
- {
- lastName: {
- [Op.like]: flexQuery,
- },
- },
- ],
- },
- limit: 50,
- });
- return res.json({
- profiles,
- });
- } catch (e) {
- return res.status(500).json({ error: e.message });
- }
-});
-
-router.post("/updateRole", async (req, res) => {
- try {
- const { email, role } = req.body;
- const result = await models.HackerProfile.update(
- {
- role: role,
- },
- {
- where: {
- email: email,
- },
- }
- );
-
- return res.json({ success: result });
- } catch (e) {
- return res.status(500).json({ error: e.message });
- }
-});
-
-router.get("/reviews", async (req, res) => {
- try {
- const reviews = await models.HackerReview.findAll();
- return res.json({ reviews: reviews });
- } catch (e) {
- return res.status(500).json({ err: e });
- }
-});
-
-router.get("/reviewHistory", async (req, res) => {
- try {
- const reviews = await models.HackerReview.findAll({
- where: {
- createdBy: req.user.id,
- },
- });
- return res.json({ reviews: reviews });
- } catch (e) {
- return res.status(500).json({ err: e });
- }
-});
-
-router.put("/review/:id", async (req, res) => {
- const requestId = req.params.id;
- const allowedFields = new Set([
- "scoreOne",
- "scoreTwo",
- "scoreThree",
- "comments",
- ]);
- const formInput = req.body;
-
- for (let key of Object.keys(formInput)) {
- if (!allowedFields.has(key)) {
- return res.status(400).json({
- error: `${key} is not a supported field`,
- });
- }
- }
-
- try {
- const result = await models.HackerReview.update(req.body, {
- where: {
- id: requestId,
- },
- });
-
- return res.json({ update: result });
- } catch (e) {
- return res.status(500).json({
- error: e,
- });
- }
-});
-
-router.get("/eligibleProfiles", async (req, res) => {
- try {
- const allProfiles = await models.HackerProfile.findAll({
- where: {
- submittedAt: {
- [sequelize.Op.not]: null,
- },
- },
- include: [
- {
- model: models.HackerReview,
- },
- ],
- });
- let filteredProfiles = allProfiles.filter((profile) => {
- const reviewsByCurrUser = profile.HackerReviews.filter((review) => {
- return review.dataValues.createdBy === req.user.id;
- });
- return reviewsByCurrUser.length === 0 && profile.HackerReviews.length < 1;
- });
- return res.json({
- eligibleReviews: filteredProfiles,
- });
- } catch (e) {
- return res.status(500).json({ error: e.message });
- }
-});
-
-router.post("/review", async (req, res) => {
- try {
- const formBody = req.body;
- const newReview = await models.HackerReview.create({
- hackerId: formBody.userId,
- createdBy: req.user.id,
- scoreOne: formBody.scoreOne,
- scoreTwo: formBody.scoreTwo,
- scoreThree: formBody.scoreThree,
- comments: formBody.comments,
- });
-
- return res.json({ newReview: newReview });
- } catch (e) {
- return res.status(500).json({ error: e.message });
- }
-});
-
-router.get("/review", async (req, res) => {
- try {
- const profilesWCount = await models.HackerProfile.findAll({
- attributes: {
- include: [
- [
- sequelize.fn("COUNT", sequelize.col("HackerReviews.id")),
- "reviewCount",
- ],
- ],
- },
- include: [
- {
- model: models.HackerReview,
- attributes: [],
- },
- ],
- group: ["HackerProfile.userId"],
- });
-
- const acceptableProfile = profilesWCount.find((profile) => {
- return profile.dataValues.reviewCount < 1;
- });
- if (acceptableProfile) {
- const newReview = await models.HackerReview.create({
- hackerId: acceptableProfile.dataValues.userId,
- createdBy: req.user.id,
- });
-
- return res.json({
- review: newReview,
- profile: acceptableProfile,
- });
- } else {
- return res.json({ review: null, profile: null }); // Returns empty when there are no more profiles
- }
- } catch (e) {
- return res.status(500).json({ err: e });
- }
-});
-
-export { router };
diff --git a/pages/api/admin/Readme.md b/pages/api/admin/Readme.md
new file mode 100644
index 00000000..f7500060
--- /dev/null
+++ b/pages/api/admin/Readme.md
@@ -0,0 +1,6 @@
+/_ This router supports superuser routes, such as updating the status of users _/
+
+Middlewares:
+
+- authMiddleware
+- requireAdmin
diff --git a/pages/api/admin/[email].ts b/pages/api/admin/[email].ts
new file mode 100644
index 00000000..b6bfe953
--- /dev/null
+++ b/pages/api/admin/[email].ts
@@ -0,0 +1,26 @@
+const db = require("../../../lib/db");
+const escape = require("sql-template-strings");
+const validator = require("email-validator");
+const models = require("../models");
+const Status = require("http-status-codes");
+const { authMiddleware, requireAdmin } = require("../utils");
+
+// Full write access to a user's hackerProfile
+// Variable parameters in the foremost endpoint path restricts use to just this route.
+// Consider changing route as to not use up all single-path put requests
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method !== "PUT") {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+ const updatedhackerProfile = await models.HackerProfile.update(req.body, {
+ where: {
+ email: req.params.email,
+ },
+ });
+ return res.json({ hackerProfile: updatedhackerProfile });
+};
+
+export default query;
diff --git a/pages/api/admin/eligibleProfiles.ts b/pages/api/admin/eligibleProfiles.ts
new file mode 100644
index 00000000..ffdc118c
--- /dev/null
+++ b/pages/api/admin/eligibleProfiles.ts
@@ -0,0 +1,41 @@
+const models = require("../models");
+const { authMiddleware, requireAdmin } = require("../utils");
+const Status = require("http-status-codes");
+const { sequelize } = require("../../../lib/database/models");
+
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method !== "GET") {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+
+ try {
+ const allProfiles = await models.HackerProfile.findAll({
+ where: {
+ submittedAt: {
+ [sequelize.Op.not]: null
+ }
+ },
+ include: [
+ {
+ model: models.HackerReview
+ }
+ ]
+ });
+ let filteredProfiles = allProfiles.filter(profile => {
+ const reviewsByCurrUser = profile.HackerReviews.filter(review => {
+ return review.dataValues.createdBy === req.user.id;
+ });
+ return reviewsByCurrUser.length === 0 && profile.HackerReviews.length < 1;
+ });
+ return res.json({
+ eligibleReviews: filteredProfiles
+ });
+ } catch (e) {
+ return res.status(500).json({ error: e.message });
+ }
+};
+
+export default query;
diff --git a/pages/api/admin/profiles.ts b/pages/api/admin/profiles.ts
new file mode 100644
index 00000000..73ca7873
--- /dev/null
+++ b/pages/api/admin/profiles.ts
@@ -0,0 +1,49 @@
+const models = require("../models");
+const { sequelize } = require("../../../lib/database/models");
+const { authMiddleware, requireAdmin } = require("../utils");
+const Status = require("http-status-codes");
+
+// TODO: use the new client fetcher api
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method !== "GET") {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+
+ const Op = sequelize.Op;
+ const { query } = req.query;
+ const flexQuery = "%" + query + "%";
+ try {
+ const profiles = await models.HackerProfile.findAll({
+ where: {
+ [Op.or]: [
+ {
+ email: {
+ [Op.like]: flexQuery
+ }
+ },
+ {
+ firstName: {
+ [Op.like]: flexQuery
+ }
+ },
+ {
+ lastName: {
+ [Op.like]: flexQuery
+ }
+ }
+ ]
+ },
+ limit: 50
+ });
+ return res.json({
+ profiles
+ });
+ } catch (e) {
+ return res.status(500).json({ error: e.message });
+ }
+};
+
+export default query;
diff --git a/pages/api/admin/review.ts b/pages/api/admin/review.ts
index 2706284b..8e2cd013 100644
--- a/pages/api/admin/review.ts
+++ b/pages/api/admin/review.ts
@@ -40,4 +40,4 @@ module.exports = async (req, res) => {
}
};
-export default {};
\ No newline at end of file
+export default {};
diff --git a/pages/api/admin/review/[id].ts b/pages/api/admin/review/[id].ts
new file mode 100644
index 00000000..fea895e7
--- /dev/null
+++ b/pages/api/admin/review/[id].ts
@@ -0,0 +1,40 @@
+const models = require("../../models");
+const { authMiddleware, requireAdmin } = require("../../utils");
+
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ const requestId = req.params.id;
+ const allowedFields = new Set([
+ "scoreOne",
+ "scoreTwo",
+ "scoreThree",
+ "comments"
+ ]);
+ const formInput = req.body;
+
+ for (let key of Object.keys(formInput)) {
+ if (!allowedFields.has(key)) {
+ return res.status(400).json({
+ error: `${key} is not a supported field`
+ });
+ }
+ }
+
+ try {
+ const result = await models.HackerReview.update(req.body, {
+ where: {
+ id: requestId
+ }
+ });
+
+ return res.json({ update: result });
+ } catch (e) {
+ return res.status(500).json({
+ error: e
+ });
+ }
+};
+
+export default query;
diff --git a/pages/api/admin/review/index.ts b/pages/api/admin/review/index.ts
new file mode 100644
index 00000000..525d809b
--- /dev/null
+++ b/pages/api/admin/review/index.ts
@@ -0,0 +1,71 @@
+const models = require("../../models");
+const { authMiddleware, requireAdmin } = require("../../utils");
+const Status = require("http-status-codes");
+const { sequelize } = require("../../../../lib/database/models");
+
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method === "POST") {
+ try {
+ const formBody = req.body;
+ const newReview = await models.HackerReview.create({
+ hackerId: formBody.userId,
+ createdBy: req.user.id,
+ scoreOne: formBody.scoreOne,
+ scoreTwo: formBody.scoreTwo,
+ scoreThree: formBody.scoreThree,
+ comments: formBody.comments
+ });
+
+ return res.json({ newReview: newReview });
+ } catch (e) {
+ return res.status(500).json({ error: e.message });
+ }
+ } else if (req.method === "GET") {
+ try {
+ const profilesWCount = await models.HackerProfile.findAll({
+ attributes: {
+ include: [
+ [
+ sequelize.fn("COUNT", sequelize.col("HackerReviews.id")),
+ "reviewCount"
+ ]
+ ]
+ },
+ include: [
+ {
+ model: models.HackerReview,
+ attributes: []
+ }
+ ],
+ group: ["HackerProfile.userId"]
+ });
+
+ const acceptableProfile = profilesWCount.find(profile => {
+ return profile.dataValues.reviewCount < 1;
+ });
+ if (acceptableProfile) {
+ const newReview = await models.HackerReview.create({
+ hackerId: acceptableProfile.dataValues.userId,
+ createdBy: req.user.id
+ });
+
+ return res.json({
+ review: newReview,
+ profile: acceptableProfile
+ });
+ } else {
+ return res.json({ review: null, profile: null }); // Returns empty when there are no more profiles
+ }
+ } catch (e) {
+ console.log(e);
+ return res.status(500).json({ err: e });
+ }
+ } else {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+};
+
+export default query;
diff --git a/pages/api/admin/reviewHistory.ts b/pages/api/admin/reviewHistory.ts
new file mode 100644
index 00000000..e70e890d
--- /dev/null
+++ b/pages/api/admin/reviewHistory.ts
@@ -0,0 +1,25 @@
+const models = require("../models");
+const { authMiddleware, requireAdmin } = require("../utils");
+const Status = require("http-status-codes");
+
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method !== "GET") {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+
+ try {
+ const reviews = await models.HackerReview.findAll({
+ where: {
+ createdBy: req.user.id
+ }
+ });
+ return res.json({ reviews: reviews });
+ } catch (e) {
+ return res.status(500).json({ err: e });
+ }
+};
+
+export default query;
diff --git a/pages/api/admin/reviews.ts b/pages/api/admin/reviews.ts
new file mode 100644
index 00000000..d649db0f
--- /dev/null
+++ b/pages/api/admin/reviews.ts
@@ -0,0 +1,21 @@
+const models = require("../models");
+const { authMiddleware, requireAdmin } = require("../utils");
+const Status = require("http-status-codes");
+
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method !== "GET") {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+
+ try {
+ const reviews = await models.HackerReview.findAll();
+ return res.json({ reviews: reviews });
+ } catch (e) {
+ return res.status(500).json({ err: e });
+ }
+};
+
+export default query;
diff --git a/pages/api/admin/updateRole.ts b/pages/api/admin/updateRole.ts
new file mode 100644
index 00000000..d18b0d54
--- /dev/null
+++ b/pages/api/admin/updateRole.ts
@@ -0,0 +1,32 @@
+const models = require("../models");
+const { authMiddleware, requireAdmin } = require("../utils");
+const Status = require("http-status-codes");
+
+const query = async (req, res, next) => {
+ authMiddleware(req, res, next);
+ requireAdmin(req, res, next);
+
+ if (req.method !== "POST") {
+ return res.status(Status.BAD_REQUEST).send("");
+ }
+
+ try {
+ const { email, role } = req.body;
+ const result = await models.HackerProfile.update(
+ {
+ role: role
+ },
+ {
+ where: {
+ email: email
+ }
+ }
+ );
+
+ return res.json({ success: result });
+ } catch (e) {
+ return res.status(500).json({ error: e.message });
+ }
+};
+
+export default query;
diff --git a/pages/api/models/types/index.ts b/pages/api/models/types/index.ts
index b9112f89..37799355 100644
--- a/pages/api/models/types/index.ts
+++ b/pages/api/models/types/index.ts
@@ -1 +1 @@
-export type { default as DBType } from "./db";
+export type { default as DBType } from './db';
diff --git a/pages/appReview.tsx b/pages/appReview.tsx
index 1da7f4e0..25a3462e 100644
--- a/pages/appReview.tsx
+++ b/pages/appReview.tsx
@@ -7,7 +7,7 @@ import {
getHackerProfileForReview,
submitReview,
getReviewHistory,
- getTotalReviewHistory
+ getTotalReviewHistory,
} from "../lib/admin";
import Head from "../components/Head";
import Navbar from "../components/Navbar";
@@ -40,7 +40,7 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
const scoreInputs = [useRef(null), useRef(null), useRef(null)];
const switchInputsOnKeyDown = useCallback(
- e => {
+ (e) => {
const { key } = e;
if (key === "Enter") {
@@ -64,7 +64,7 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
window.scrollTo({
left: 0,
top: scoreInputs[i].current.offsetTop - 50,
- behavior: "smooth"
+ behavior: "smooth",
});
e.preventDefault();
@@ -112,7 +112,7 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
userId: currentProfile.userId,
scoreOne: s1,
scoreTwo: s2,
- scoreThree: s3
+ scoreThree: s3,
};
setSubmitting(true);
@@ -250,7 +250,7 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
{
+ onChange={(e) => {
setS1(e.target.value);
}}
value={s1}
@@ -271,7 +271,7 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
{
+ onChange={(e) => {
setS2(e.target.value);
}}
value={s2}
@@ -292,10 +292,10 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
{
+ onChange={(e) => {
setS3(e.target.value);
}}
- onKeyUp={e => {
+ onKeyUp={(e) => {
if (e.key === "e") {
e.preventDefault();
}
@@ -323,7 +323,7 @@ const AppReview = ({ hackerProfile, reviewHistory, totalReviews }) => {
);
};
-AppReview.getInitialProps = async ctx => {
+AppReview.getInitialProps = async (ctx) => {
const { req } = ctx;
const profile = await getProfile(req);
@@ -338,7 +338,7 @@ AppReview.getInitialProps = async ctx => {
return {
hackerProfile: profileReview,
reviewHistory,
- totalReviews
+ totalReviews,
};
};
diff --git a/pages/application.tsx b/pages/application.tsx
index eb097229..d4e6b3a1 100644
--- a/pages/application.tsx
+++ b/pages/application.tsx
@@ -44,7 +44,6 @@ Application.getInitialProps = async ({ req }) => {
const profile = await getProfile(req);
//const houses = await getHouses(req);
const houses = [];
- //console.log(req);
// Null profile means user is not logged in
if (!profile) {
@@ -59,7 +58,6 @@ Application.getInitialProps = async ({ req }) => {
if (profile && profile.status == "checkedIn") {
//const houseInfo = await getHouseInfo(req, 1);
- //console.log(houseInfo);
}
/*
diff --git a/pages/battlepassManager.tsx b/pages/battlepassManager.tsx
index 12dd1051..d56fc83e 100644
--- a/pages/battlepassManager.tsx
+++ b/pages/battlepassManager.tsx
@@ -5,7 +5,7 @@ import { handleLoginRedirect, getProfile } from "../lib/authenticate";
import {
getCurrentUnlockables,
saveUnlockable,
- updateUnlockable
+ updateUnlockable,
} from "../lib/live";
import { Head, Navbar, Footer } from "../components";
@@ -23,7 +23,7 @@ const EditableCell = ({ unlockable }) => {
type="number"
placeholder="tier"
value={currUnlockable.tier}
- onChange={e => {
+ onChange={(e) => {
setCurrUnlockable({ ...currUnlockable, tier: e.target.value });
}}
/>
@@ -31,19 +31,19 @@ const EditableCell = ({ unlockable }) => {
type="number"
placeholder="pointThreshold"
value={currUnlockable.pointThreshold}
- onChange={e => {
+ onChange={(e) => {
setCurrUnlockable({
...currUnlockable,
- pointThreshold: e.target.value
+ pointThreshold: e.target.value,
});
}}
/>