Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 058c01b
Author: Victor Siu <[email protected]>
Date:   Mon Jun 17 19:25:24 2024 -0700

    Feature/vs2961/attendance dashboard (#106)

    * Add backend query code

    * Add frontend components

    * Add mobile

    * Add attendance dashboard code

    * Add code for attendanceTable

    * Fix linting

    * Make varying sessions work

    * Fix linting

    * Fix types

    * fix linting

    * Prevent buttons from being clicked multiple times

commit 525fbe2
Author: adhi0331 <[email protected]>
Date:   Sun Jun 16 15:29:45 2024 -0500

    fixed minor bug

commit a16cf00
Author: Aaron Chan <[email protected]>
Date:   Sun Jun 16 13:15:56 2024 -0700

    Account Archival Frontend & Backend (#107)

    * feat: add create program notes backend

    * fix: THead unique key prop warning

    * feat: add edited by field to notes

    * fix: fix styling issues

    * feat: add edit and delete functionality to progress notes and change userId to uid for backend

    * fix: fix calendar styling

    * feat: add download progress notes functionality using react-pdf

    * feat: add mobile responsiveness

    * feat: create program context provider shared across Home, Programs, and Notes page

    * fix: fix styling to be consistent across pages

    * feat: add progress note filtering and add loading spinner to pages

    * feat: add account type authorization checks on frontend and backend

    * refactor: refactor notes logic and fix styling

    * feat: add logic to check for no students and refactor filter

    * feat: add shadows using overflow clip

    * fix: fix styling for search filter

    * fix: fix small style inconsistencies

    * fix: update poppins font url to use https

    * fix: fix modal close button styling to be more consistent

    * fix: fix escape key overriding dialog close

    * Squashed commit of the following:

    commit 0b133b8
    Author: Michael Sullivan <[email protected]>
    Date:   Tue May 14 09:09:16 2024 -0700

        Feature/mraysu/program form v2 (#100)

        * Update Backend Program Schema

        * V2 UI

        * Disabled Editing Program Type

        * Frontend-backend integration

        * Lint fixes

        ---------

        Co-authored-by: mraysu <[email protected]>
        Co-authored-by: Adhithya Ananthan <[email protected]>

    commit e17b509
    Author: parth4apple <[email protected]>
    Date:   Tue May 14 09:01:15 2024 -0700

        Student and Enrollment Schema modifications (#101)

        * feat: initial schema

        * feat: edit routes

        * feat: test and fix routes

    * feat: add frontend and backend for account archival

    * feat: ensure ui updates and refactor code

    * Squashed merge with main

    * fix: update type of VerifyUser to be same as User

    * fix: fix user type error

commit fe61637
Author: Andrew Pu <[email protected]>
Date:   Sun Jun 16 13:00:01 2024 -0700

    Feature/andrewzpu/program profile pages (#105)

    * added backend route for getting single program

    * added separate pages for each program

    * Added program edit popup and "no programs" message

    * Fixed add button display

    * Reorganized ProgramFormButton to take take any component

    * Removed start and end date from card

    * Connected Program Card to Program Profile Pages

    * Set up basic framework of Program Profile Page

    * Added feature where clicking anywhere else will close the edit popup button

    * Updated popup and redirect functionality of program profiles

    * Finished full screen view of program profile

    * Fixed hourly pay references

    * Added backend route to get program enrollments

    * Connected enrollments route to program profile page

    * Updated student count messages on cards and program profile

    * Added Student Names to Enrollment Table

    * Fixed mobile view

    * Fixed minor details

    * Minor Table Change

    * finish merge

    * fixed try catch error

    ---------

    Co-authored-by: Adhithya Ananthan <[email protected]>
    Co-authored-by: adhi0331 <[email protected]>

commit 6e67ad3
Author: Michael Sullivan <[email protected]>
Date:   Sat Jun 15 08:16:22 2024 -0700

    Feature/mraysu/program archive (#96)

    * Archive Program Route

    * Change program status to archived for students

    * Added Archived field to program schema

    * Implemented Archive Button

    * Prevent students from 'joining' archived programs

    * Lint fix

    * Integrated new enrollment schema

    * Archived Programs Page

    * Fix merge issues

    * Updated Archive Page View

    * Mobile UI Adjustments

    ---------

    Co-authored-by: mraysu <[email protected]>

commit b0b800a
Author: Aammya Sapra <[email protected]>
Date:   Fri Jun 14 21:40:43 2024 -0700

    Feature/aammya8/new account approval (#104)

    * Add user approval and denial functionality, as well as email user about account approval updates

    * backup

    * backup

    * fixed delete route

    * change approve/deny/delete to use email

    * approve/deny controllers do not get entered? but delete does

    * Fix Notifications UI (immediately remove corresponding card when approve/deny button clicked)

    * Modify routes for testing purposes

    * Debug statements --> user does not get found in denyUser

    * Email successfully sent for deny (accidentally deleted user before trying to send email earlier lol)

    * Fix frontend (populate account type)

    * Remove extra comments

    * added auth protection and cleaned up code

    * added env for emails

    * fix user role bug

    * fixed some bugs and deleted some log statements

    * ran lint fix

    ---------

    Co-authored-by: adhi0331 <[email protected]>
  • Loading branch information
aaronchan32 committed Nov 28, 2024
1 parent 270d779 commit 41404b2
Show file tree
Hide file tree
Showing 70 changed files with 3,230 additions and 317 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
echo SERVICE_ACCOUNT_KEY=${{ secrets.SERVICE_ACCOUNT_KEY }} >> .env
echo APP_PORT=${{ secrets.APP_PORT }} >> .env
echo APP_FIREBASE_CONFIG=${{ secrets.APP_FIREBASE_CONFIG }} >> .env
echo EMAIL_ADDRESS_1=${{ secrets.EMAIL_ADDRESS_1 }} >> .env
echo PASS_1=${{ secrets.PASS_1 }} >> .env
- name: Build Frontend
run: cd frontend && npm ci && npm run build
- name: Build Backend
Expand Down
19 changes: 19 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
"firebase-functions": "^4.7.0",
"mongodb": "^6.3.0",
"mongoose": "^8.3.1",
"nodemailer": "^6.9.13",
"tsc-alias": "^1.8.8"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/nodemailer": "^6.4.14",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"eslint": "^8.56.0",
Expand Down
89 changes: 82 additions & 7 deletions backend/src/controllers/program.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
import { RequestHandler } from "express";
import { validationResult } from "express-validator";
//import { error } from "firebase-functions/logger";
import createHttpError from "http-errors";
// import { error } from "firebase-functions/logger";

import EnrollmentModel from "../models/enrollment";
import ProgramModel from "../models/program";
import validationErrorParser from "../util/validationErrorParser";

Expand All @@ -14,7 +16,12 @@ export type Program = {
daysOfWeek: string[];
color: string; //colorValueHex;
hourlyPay: string;
sessions: [string[]];
sessions: { start_time: string; end_time: string }[];
archived: boolean;
};

export type ExistingProgram = Program & {
dateUpdated: string;
};

export const createProgram: RequestHandler = async (req, res, next) => {
Expand All @@ -23,7 +30,10 @@ export const createProgram: RequestHandler = async (req, res, next) => {
try {
validationErrorParser(errors);

const programForm = await ProgramModel.create(req.body as Program);
const programForm = await ProgramModel.create({
...(req.body as Program),
dateUpdated: new Date().toISOString(),
});

res.status(201).json(programForm);
} catch (error) {
Expand All @@ -37,22 +47,75 @@ export const updateProgram: RequestHandler = async (req, res, next) => {
validationErrorParser(errors);

const programId = req.params.id;
const programData = req.body as Program;
const programData = req.body as ExistingProgram;

const editedProgram = await ProgramModel.findOneAndUpdate({ _id: programId }, programData, {
new: true,
});
const editedProgram = await ProgramModel.findOneAndUpdate(
{ _id: programId },
{ ...programData, archived: false, dateUpdated: new Date().toISOString() }, //stand-in method of un-archiving programs
{
new: true,
},
);

if (!editedProgram) {
return res.status(404).json({ message: "No object in database with provided ID" });
}

// Waitlist all archived students. Making sure to only waitlist Archived students
// will prevent enrollments from being updated every time the program is updated
await EnrollmentModel.updateMany(
{ programId: { $eq: programId }, status: { $eq: "Archived" } },
{ $set: { status: "Waitlisted", dateUpdated: Date.now() } },
);

res.status(200).json(editedProgram);
} catch (error) {
next(error);
}
};

export const getProgram: RequestHandler = async (req, res, next) => {
const { id } = req.params;

try {
const program = await ProgramModel.findById(id);

if (program === null) {
throw createHttpError(404, "Program not found");
}

res.status(200).json(program);
} catch (error) {
next(error);
}
};

export const archiveProgram: RequestHandler = async (req, res, next) => {
const errors = validationResult(req);
try {
validationErrorParser(errors);

const programId = req.params.id;
const program = await ProgramModel.findByIdAndUpdate(
programId,
{ $set: { archived: true, dateUpdated: new Date().toISOString() } },
{ new: true },
);
if (!program)
return res.status(404).json({ message: "Program with this id not found in database" });

//Archive all students
await EnrollmentModel.updateMany(
{ programId: { $eq: programId } },
{ $set: { status: "Archived", dateUpdated: Date.now() } },
);

return res.status(200).json(program);
} catch (error) {
next(error);
}
};

export const getAllPrograms: RequestHandler = async (req, res, next) => {
try {
const programs = await ProgramModel.find();
Expand All @@ -62,3 +125,15 @@ export const getAllPrograms: RequestHandler = async (req, res, next) => {
next(error);
}
};

export const getProgramEnrollments: RequestHandler = async (req, res, next) => {
const { id } = req.params;

try {
const enrollments = await EnrollmentModel.find({ programId: id });

res.status(200).json(enrollments);
} catch (error) {
next(error);
}
};
Loading

0 comments on commit 41404b2

Please sign in to comment.