-
Notifications
You must be signed in to change notification settings - Fork 10
Feat/waitlisting/integration #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gabrielhan23
wants to merge
33
commits into
master
Choose a base branch
from
feat/waitlisting/integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d140eb4
waitlisting backend code: waitlist student model, apis (view, add, an…
gabrielhan23 fe784c6
reverted docker compose
gabrielhan23 af5d7ed
added a count waitlist method
R1A2J 4affe39
displaying active feature for waitlisted database in admin site
R1A2J 260cfdc
showing only active students when we click on particular section from…
R1A2J 481626c
update sections
dbswjd24 1dc9477
added a count waitlist method
R1A2J 6a0b708
displaying active feature for waitlisted database in admin site
R1A2J bbaca01
showing only active students when we click on particular section from…
R1A2J 97cf4a9
add max_waitlist_capacity to section partial_update
maxmwang 86ddc72
Merge branch 'feat/waitlisting/integration' into feat/waitlisting/fro…
maxmwang 61fb87c
add max_waitlist_capacity to section partial_update
maxmwang fc24af8
Merge branch 'feat/waitlisting/integration' into feat/waitlisting/fro…
maxmwang 9a20d84
add waitlistCapacity to MetaEditModal and MentorSectionInfo
maxmwang 0e95ea1
edit waitlistCapacity on frontend (#527)
maxmwang 14ce137
add numWaitlistedStudnets to section serializer (#528)
maxmwang 2362aae
add numWaitlistedStudnets to section serializer (#528)
maxmwang bb3707a
allow students to join waitlist for sections
maxmwang 489118c
add view waitlist frontend and fix backend endpoint add
gabrielhan23 3ba529f
Merge branch 'feat/waitlisting/frontend' of github.com:csmberkeley/cs…
gabrielhan23 ff874a1
basic view, can add to waitlist, fixed card bugs
gabrielhan23 bbe7a3e
added waitlist section view
gabrielhan23 b1f3139
fix resources
gabrielhan23 46cbe03
add migrations
gabrielhan23 6e2c981
fix migration
gabrielhan23 3bd1e5c
add numWaitlistedStudnets to section serializer (#531)
gabrielhan23 a9ec880
merge
gabrielhan23 55691ff
fix waitlisting tests, allow cascade waitlist, add from coord, preven…
gabrielhan23 2be41d9
fix tests
gabrielhan23 5fc7cd0
fix backend for section swap
gabrielhan23 058a158
update frontend to show warning modals
gabrielhan23 914a282
add tests
gabrielhan23 2beb837
merge with main
gabrielhan23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "presets": ["@babel/preset-react", "@babel/preset-typescript"], | ||
| "plugins": ["transform-class-properties", "lodash", "@babel/plugin-transform-runtime", "dynamic-import-node"] | ||
| "plugins": ["transform-class-properties", "@babel/plugin-transform-runtime", "dynamic-import-node"] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,15 +2,21 @@ import React, { useState } from "react"; | |||||
| import { Link, Navigate } from "react-router-dom"; | ||||||
|
|
||||||
| import { formatSpacetimeInterval } from "../../utils/datetime"; | ||||||
| import { EnrollUserMutationResponse, useEnrollUserMutation } from "../../utils/queries/sections"; | ||||||
| import { Mentor, Spacetime } from "../../utils/types"; | ||||||
| import { useProfiles } from "../../utils/queries/base"; | ||||||
| import { | ||||||
| EnrollUserMutationResponse, | ||||||
| useEnrollUserMutation, | ||||||
| useEnrollStudentToWaitlistMutation | ||||||
| } from "../../utils/queries/sections"; | ||||||
| import { Mentor, Role, Spacetime } from "../../utils/types"; | ||||||
| import Modal, { ModalCloser } from "../Modal"; | ||||||
|
|
||||||
| import CheckCircle from "../../../static/frontend/img/check_circle.svg"; | ||||||
| import ClockIcon from "../../../static/frontend/img/clock.svg"; | ||||||
| import GroupIcon from "../../../static/frontend/img/group.svg"; | ||||||
| import LocationIcon from "../../../static/frontend/img/location.svg"; | ||||||
| import UserIcon from "../../../static/frontend/img/user.svg"; | ||||||
| import WaitlistIcon from "../../../static/frontend/img/waitlist.svg"; | ||||||
| import XCircle from "../../../static/frontend/img/x_circle.svg"; | ||||||
|
|
||||||
| interface SectionCardProps { | ||||||
|
|
@@ -22,6 +28,9 @@ interface SectionCardProps { | |||||
| description: string; | ||||||
| userIsCoordinator: boolean; | ||||||
| courseOpen: boolean; | ||||||
| numStudentsWaitlisted: number; | ||||||
| waitlistCapacity: number; | ||||||
| courseId: number; | ||||||
| } | ||||||
|
|
||||||
| export const SectionCard = ({ | ||||||
|
|
@@ -32,12 +41,21 @@ export const SectionCard = ({ | |||||
| capacity, | ||||||
| description, | ||||||
| userIsCoordinator, | ||||||
| courseOpen | ||||||
| courseOpen, | ||||||
| numStudentsWaitlisted, | ||||||
| waitlistCapacity, | ||||||
| courseId | ||||||
| }: SectionCardProps): React.ReactElement => { | ||||||
| /** | ||||||
| * Mutation to enroll a student in the section. | ||||||
| */ | ||||||
| const enrollStudentMutation = useEnrollUserMutation(id); | ||||||
| /** | ||||||
| * Mutation to enroll a student in the section's waitlist. | ||||||
| */ | ||||||
| const enrollStudentWaitlistMutation = useEnrollStudentToWaitlistMutation(id); | ||||||
|
|
||||||
| const { data: profiles } = useProfiles(); | ||||||
|
|
||||||
| /** | ||||||
| * Whether to show the modal (after an attempt to enroll). | ||||||
|
|
@@ -51,19 +69,26 @@ export const SectionCard = ({ | |||||
| * The error message if the enrollment failed. | ||||||
| */ | ||||||
| const [errorMessage, setErrorMessage] = useState<string>(""); | ||||||
| /** | ||||||
| * Whether to show the swap/waitlist confirmation modal. | ||||||
| */ | ||||||
| const [showSwapConfirm, setShowSwapConfirm] = useState<boolean>(false); | ||||||
| /** | ||||||
| * Whether the pending action is a waitlist join (vs direct enroll). | ||||||
| */ | ||||||
| const [pendingIsWaitlist, setPendingIsWaitlist] = useState<boolean>(false); | ||||||
|
|
||||||
| /** | ||||||
| * Handle enrollment in the section. | ||||||
| * Check if the user is already enrolled in another section of this course. | ||||||
| */ | ||||||
| const enroll = () => { | ||||||
| if (!courseOpen) { | ||||||
| setShowModal(true); | ||||||
| setEnrollmentSuccessful(false); | ||||||
| setErrorMessage("The course is not open for enrollment."); | ||||||
| return; | ||||||
| } | ||||||
| const isAlreadyEnrolled = profiles?.some(p => p.courseId === courseId && p.role === Role.STUDENT) ?? false; | ||||||
|
|
||||||
| enrollStudentMutation.mutate(undefined, { | ||||||
| /** | ||||||
| * Perform the actual mutation (enroll or waitlist). | ||||||
| */ | ||||||
| const performEnroll = (useWaitlist: boolean) => { | ||||||
| const mutation = useWaitlist ? enrollStudentWaitlistMutation : enrollStudentMutation; | ||||||
| mutation.mutate(undefined, { | ||||||
| onSuccess: () => { | ||||||
| setEnrollmentSuccessful(true); | ||||||
| setShowModal(true); | ||||||
|
|
@@ -76,6 +101,31 @@ export const SectionCard = ({ | |||||
| }); | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * Handle enrollment in the section. | ||||||
| */ | ||||||
| const enroll = () => { | ||||||
| if (!courseOpen) { | ||||||
| setShowModal(true); | ||||||
| setEnrollmentSuccessful(false); | ||||||
| setErrorMessage("The course is not open for enrollment."); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| // Determine if we should use waitlist mutation (enrolled capacity is full but waitlist is not full) | ||||||
| const isEnrolledFull = numStudentsEnrolled >= capacity; | ||||||
| const shouldUseWaitlist = isEnrolledFull && numStudentsWaitlisted < waitlistCapacity; | ||||||
|
|
||||||
| // If user is already enrolled in another section, show a confirmation warning | ||||||
| if (isAlreadyEnrolled) { | ||||||
| setPendingIsWaitlist(shouldUseWaitlist); | ||||||
| setShowSwapConfirm(true); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| performEnroll(shouldUseWaitlist); | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * Handle closeing of the modal. | ||||||
|
||||||
| * Handle closeing of the modal. | |
| * Handle closing of the modal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lodash plugin was removed from the Babel configuration. If lodash is used anywhere in the frontend code, this could lead to larger bundle sizes as tree-shaking won't be as effective. Verify that lodash is not used in the codebase, or if it is, ensure that imports are done correctly (e.g.,
import map from 'lodash/map'instead ofimport { map } from 'lodash') to enable tree-shaking.