Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 3766612
Author: theosiemensrhodes <[email protected]>
Date:   Wed Feb 12 10:50:06 2025 -0800

    update frontend to match sql

commit 06ac697
Author: Theo Siemens-Rhodes <[email protected]>
Date:   Wed Feb 12 10:34:43 2025 -0800

    Volunteer Profile Imgs in Side Panel & Ensure admin users have login (#58)

    * add f_name, l_name to user, ensure admin login is successful

    * ensure f_name, l_name inserted, ensure inactive volunteers cannot login

commit 9a24013
Merge: 3a37582 9f8fce7
Author: Josh Fung <[email protected]>
Date:   Tue Feb 11 23:29:28 2025 -0800

    Merge pull request #57 from ubclaunchpad/schedule-button-status-logic

    Schedule Page Logic

commit 9f8fce7
Author: Josh Fung <[email protected]>
Date:   Tue Feb 11 23:08:13 2025 -0800

    Added thirty minute window to check-in before and after the shift

commit bfce70e
Merge: 74daca8 3a37582
Author: Josh Fung <[email protected]>
Date:   Sun Feb 9 16:44:11 2025 -0800

    Merge branch 'main' into schedule-button-status-logic

commit 74daca8
Author: Josh Fung <[email protected]>
Date:   Sat Feb 8 22:41:58 2025 -0800

    Fixed shift cards on volunteer dashboard

commit 7e0721c
Author: Josh Fung <[email protected]>
Date:   Thu Feb 6 19:00:12 2025 -0800

    Made panel more similar to designs and buttons more reusable

commit 600e13b
Author: Josh Fung <[email protected]>
Date:   Thu Feb 6 17:44:51 2025 -0800

    Past and fulfilled coverage requests are no longer shown

commit ef3f8f5
Merge: 01008da 6842393
Author: Josh Fung <[email protected]>
Date:   Thu Feb 6 16:57:21 2025 -0800

    Merge branch 'main' into schedule-button-status-logic

commit 01008da
Author: Josh Fung <[email protected]>
Date:   Thu Feb 6 16:23:22 2025 -0800

    Added a different status for your fulfilled coverage requests

commit 584d609
Author: Josh Fung <[email protected]>
Date:   Thu Feb 6 12:25:38 2025 -0800

    Refactor and cleanup

commit 5d3403a
Author: Josh Fung <[email protected]>
Date:   Tue Feb 4 15:36:08 2025 -0800

    Added logic for cancelling shift coverage request

commit fd5ca84
Author: Josh Fung <[email protected]>
Date:   Tue Feb 4 00:57:05 2025 -0800

    Added canceling on covering someone else's shift

commit fb625b2
Merge: 3b9120c 9afcfc8
Author: Josh Fung <[email protected]>
Date:   Tue Feb 4 00:14:45 2025 -0800

    Merge branch 'main' into schedule-button-status-logic

commit 3b9120c
Author: Josh Fung <[email protected]>
Date:   Fri Jan 31 12:42:24 2025 -0800

    Implemented basic cover shift logic and re-rendering side panel

commit 2a56827
Author: Josh Fung <[email protected]>
Date:   Tue Jan 28 20:24:07 2025 -0800

    Implemented check in from frontend and refactored so details panel is re-rendered

commit e9ff8bd
Author: Josh Fung <[email protected]>
Date:   Sun Jan 26 19:21:24 2025 -0800

    Created API endpoint and routes for shift check-in

commit 4a03f0b
Author: Josh Fung <[email protected]>
Date:   Sun Jan 26 17:29:46 2025 -0800

    Corrected prioritization of user's coverage requests over user's shifts

commit 822cf24
Author: Josh Fung <[email protected]>
Date:   Sun Jan 26 17:25:21 2025 -0800

    Refactored to reuse fetchShifts()

commit fe30e39
Author: Josh Fung <[email protected]>
Date:   Sun Jan 26 16:46:27 2025 -0800

    Filter out duplicate shifts and prioritize showing coverage shifts over user's own shifts
  • Loading branch information
theosiemensrhodes committed Feb 12, 2025
1 parent 8b412cb commit a1afe16
Show file tree
Hide file tree
Showing 49 changed files with 1,382 additions and 620 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RowDataPacket } from "mysql2";

import { RowDataPacket } from "mysql2";

/*
* This file was generated by a tool.
* Rerun sql-ts to regenerate this file.
Expand Down Expand Up @@ -29,15 +29,10 @@ export interface ClassDB extends RowDataPacket {
'subcategory'?: string | null;
'zoom_link': string;
}
export interface ClassImageDB extends RowDataPacket {
'fk_class_id'?: number | null;
'image'?: Buffer | null;
'image_id'?: number;
}
export interface ClassPreferenceDB extends RowDataPacket {
'class_rank'?: number | null;
'fk_class_id'?: number | null;
'fk_volunter_id'?: string | null;
'fk_schedule_id'?: number | null;
'fk_volunteer_id'?: string | null;
}
export interface ImageDB extends RowDataPacket {
'image': Buffer;
Expand All @@ -55,6 +50,7 @@ export interface PendingShiftCoverageDB extends RowDataPacket {
'request_id': number;
}
export interface ScheduleDB extends RowDataPacket {
'active'?: any;
'day': number;
'end_time': string;
'fk_class_id': number;
Expand All @@ -67,42 +63,45 @@ export interface ShiftCoverageRequestDB extends RowDataPacket {
'request_id'?: number;
}
export interface ShiftDB extends RowDataPacket {
'checked_in'?: any | null;
'checked_in'?: any;
'duration': number;
'fk_schedule_id': number;
'fk_volunteer_id': string;
'shift_date': string;
'shift_id': number;
'shift_id'?: number;
}
export interface UserDB extends RowDataPacket {
'created_at'?: Date | null;
'email': string;
'f_name': string;
'fk_image_id'?: string | null;
'l_name': string;
'password': string;
'role': string;
'role2': 'volunteer' | 'admin' | 'instructor';
'user_id': string;
}
export interface VolunteerScheduleDB extends RowDataPacket {
'fk_schedule_id': number;
export interface VolunteerClassDB extends RowDataPacket {
'fk_class_id': number;
'fk_volunteer_id': string;
}
export interface VolunteerProfilePicDB extends RowDataPacket {
export interface VolunteerScheduleDB extends RowDataPacket {
'fk_schedule_id': number;
'fk_volunteer_id': string;
'profile_pic': Buffer;
}
export interface VolunteerDB extends RowDataPacket {
'active': any;
'active'?: any;
'bio'?: string | null;
'city'?: string | null;
'email': string;
'f_name': string;
'fk_user_id'?: string | null;
'l_name': string;
'p_name'?: string | null;
'p_time_ctmt': number;
'p_time_ctmt'?: number;
'phone_number'?: string | null;
'pronouns'?: string | null;
'province'?: string | null;
'total_hours': number;
'total_hours'?: number;
'volunteer_id': string;
}
6 changes: 5 additions & 1 deletion backend/src/common/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export type Role = "ADMIN" | "VOLUN" | "INSTR";
export enum Role {
admin = 'admin',
volunteer = 'volunteer',
instructor = 'instructor'
};
4 changes: 2 additions & 2 deletions backend/src/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextFunction, Request, Response } from "express";
import { ValidationChain } from "express-validator";
import { UserDB } from "./generated.js";
import { UserDB } from "./databaseModels.js";

export type AuthenticatedRequest = Request & {
export type AuthenticatedUserRequest = Request & {
user?: RequestUser
}

Expand Down
3 changes: 2 additions & 1 deletion backend/src/config/authCheck.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dotenv from "dotenv";
import { NextFunction, Request, Response } from "express";
import jwt from "jsonwebtoken";
import { Role } from "../common/interfaces.js";
import {
AuthenticatedRequest,
DecodedJwtPayload,
Expand Down Expand Up @@ -63,7 +64,7 @@ async function isAdmin(
res: Response,
next: NextFunction
): Promise<any> {
if (req.user!.role !== "ADMIN") {
if (req.user!.role !== Role.admin) {
return res.status(403).json({
error: "Forbidden",
});
Expand Down
5 changes: 2 additions & 3 deletions backend/src/controllers/adminController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Response } from "express";
import VolunteerModel from "../models/volunteerModel.js";

import { VolunteerDB } from "../common/generated.js";
import { VolunteerDB } from "../common/databaseModels.js";
import { AuthenticatedRequest } from "../common/types.js";
import VolunteerModel from "../models/volunteerModel.js";

const volunteerModel = new VolunteerModel();

Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/availabilityController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Response } from 'express';
import { AvailabilityDB } from '../common/generated.js';
import { AvailabilityDB } from '../common/databaseModels.js';
import { AuthenticatedRequest } from '../common/types.js';
import AvailabilityModel from '../models/availabilityModel.js';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/classController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Response } from 'express';
import { ClassDB } from '../common/generated.js';
import { ClassDB } from '../common/databaseModels.js';
import { AuthenticatedRequest } from '../common/types.js';
import ClassesModel from '../models/classModel.js';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/instructorController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Response } from 'express';
import { InstructorDB } from '../common/generated.js';
import { InstructorDB } from '../common/databaseModels.js';
import { AuthenticatedRequest } from '../common/types.js';
import InstructorModel from '../models/instructorModel.js';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/scheduleController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Response } from 'express';
import { ScheduleDB } from '../common/generated.js';
import { ScheduleDB } from '../common/databaseModels.js';
import { AuthenticatedRequest } from '../common/types.js';
import ScheduleModel from '../models/scheduleModel.js';

Expand Down
63 changes: 49 additions & 14 deletions backend/src/controllers/shiftController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Response } from 'express';
import { ShiftDB } from '../common/generated.js';
import { ShiftDB } from '../common/databaseModels.js';
import { AuthenticatedRequest } from '../common/types.js';
import ShiftModel from '../models/shiftModel.js';

Expand Down Expand Up @@ -44,15 +44,6 @@ async function getShiftsByVolunteerIdAndMonth(req: AuthenticatedRequest, res: Re
res.status(200).json(shifts);
}

// volunteer requesting to cover someone else’s open shift
async function requestToCoverShift(req: AuthenticatedRequest, res: Response) {
const { request_id, volunteer_id } = req.body;

const request = await shiftModel.requestToCoverShift(request_id, volunteer_id);

res.status(200).json(request);
}

async function addShift(req: AuthenticatedRequest, res: Response) {
const shift: ShiftDB = req.body;

Expand All @@ -69,6 +60,14 @@ async function addShift(req: AuthenticatedRequest, res: Response) {
res.status(200).json(addedShift);
}

async function deleteShift(req: AuthenticatedRequest, res: Response) {
const shift_id = Number(req.params.shift_id);

const request = await shiftModel.deleteShift(shift_id);

res.status(200).json(request);
}

async function updateShift(req: AuthenticatedRequest, res: Response) {
const shift_id = Number(req.params.shift_id);
const shift: ShiftDB = req.body;
Expand All @@ -78,16 +77,52 @@ async function updateShift(req: AuthenticatedRequest, res: Response) {
res.status(200).json(request);
}

async function deleteShift(req: AuthenticatedRequest, res: Response) {
// volunteer checks into a shift
async function checkInShift(req: AuthenticatedRequest, res: Response) {
const shift_id = Number(req.params.shift_id);

const request = await shiftModel.deleteShift(shift_id);
const request = await shiftModel.updateShiftCheckIn(shift_id);

res.status(200).json(request);
}

// volunteer requesting to cover someone else’s open shift
async function requestCoverShift(req: AuthenticatedRequest, res: Response) {
const { request_id, volunteer_id } = req.body;

const request = await shiftModel.insertCoverShift(request_id, volunteer_id);

res.status(200).json(request);
}

// volunteer cancels on covering a shift
async function withdrawCoverShift(req: AuthenticatedRequest, res: Response) {
const { request_id, volunteer_id } = req.body;

const request = await shiftModel.deleteCoverShift(request_id, volunteer_id);

res.status(200).json(request);
}

// volunteer requests coverage for their own shift
async function requestShiftCoverage(req: AuthenticatedRequest, res: Response) {
const { shift_id } = req.body;

const request = await shiftModel.insertShiftCoverageRequest(shift_id);

res.status(200).json(request);
}

// volunteers cancels their request for shift coverage
async function withdrawShiftCoverage(req: AuthenticatedRequest, res: Response) {
const { request_id, shift_id } = req.body;

const request = await shiftModel.deleteShiftCoverageRequest(request_id, shift_id);

res.status(200).json(request);
}

export {
addShift, deleteShift, getShiftInfo, getShiftsByDate, getShiftsByVolunteerId, getShiftsByVolunteerIdAndMonth,
requestToCoverShift, updateShift
addShift, checkInShift, deleteShift, getShiftInfo, getShiftsByDate, getShiftsByVolunteerId, getShiftsByVolunteerIdAndMonth, requestCoverShift, requestShiftCoverage, updateShift, withdrawCoverShift, withdrawShiftCoverage
};

Loading

0 comments on commit a1afe16

Please sign in to comment.