Skip to main content

User Slice

The slice holding information about the current user and their plans. Also holds cached courses.

State

type UserSlice = {
currentUser: User;
planList: Plan[];
courseCache: SISRetrievedCourse[];
cacheNumbers: String[];
unfoundNumbers: String[];
retrievedAll: boolean;
};
PropertyTypeDescription
currentUserUserEncapsulation of information involving a user
planListArray of PlanThe list of all plans a user has
courseCacheArray of SISRetrievedCourseEncapsulation of a course based on SIS information
cacheNumbersArray of StringSeems to help with determining if a course is cached or not
unfoundNumbersArray of StringSeems to help with determining if a course is cached or not - if it is not then pull from database
retrievedAllbooleanHelps with deciding if all courses for a search have already been cached if not pull from database

Reducers

ReducerAction Payload TypeState Affected
updateUserUsercurrentUser
updatePlanListArray of PlanplanList
updateGuestPlanIdsArray of StringcurrentUser
updateCourseCacheArray of SISRetrievedCoursecacheNumbers, courseCache
updateUnfoundNumbersStringunfoundNumbers
updateAllCoursesCachedArray of SISRetrievedCoursecourseCache
updateRetrievedAllBooleanretrievedAll
resetUserNonecurrentUser and planList

updateUser

Used to update the currentUser object

ComponentDescription
HandleUserEntryDummyUsed in login Update user information when logging in
HandleUserEntryDummyUsed in useEffect when trying to retrieve user information
HandleUserEntryDummyUsed in handleExistingUser if user already exists
DashboardEntryUsed in initialLogin if completely new user
DashboardEntryUsed in fetchUser when retrieving user info based on url
DashboardEntryUsed in handleGuest when user is a guest

updatePlanList

Used to update the array of plans

ComponentDescription
HandleUserEntryUsed in processRetrievedPlans and processYears when there's no initial plan
HandleUserEntryUsed in handleFinishAdding after plan was imported
HandleUserEntryUsed in getPlans after sorting the plans
CourseListUsed in swapCourse after courses in a Plan were changed
SemesterUsed in handlePostResponse after posting a new plan to the data base
YearSettingsDropdownUsed in handleYearChange after a year was updated
ActionBarUsed in updateName after plan's name was changed
ActionBarUsed in addNewYear afer a new year was added to a plan
PlanChooseUsed in handlePlanChange after switching to a different plan
CourseDisplayPopupUsed in handlePostAddCourse after a new course was added to a plan
DeleteCoursePopupUsed in activateDeleteCourse after a course was deleted
DeletePlanPopupUsed in deleteCurrentPlan after a plan was deleted
CourseDisplayUsed in updateDistributions after distribution requirements were met
GenerateNewPlanUsed in useEffect after a new plan was generated

updateGuestPlanIds

Used to update the currentUser's ids if they are a guest

ComponentDescription
GenerateNewPlanUsed in useEffect when making a new plan and if the user is a guest

updateCourseCache

Used to update which courses have been cached

ComponentDescription
AppUsed in useEffect when a new SIS course was added
HandleUserEntryDummyUsed in cache when caching all courses in a plan
FormUsed in find when successfully finds a course so need to cache it
FormUsed in performSmartSearch when searching courses with filters so need to cache it
assetsUsed in getCourse after retrieving a course from the api

updateUnfoundNumbers

Used to update the cache numbers that were not able to be retrieved

ComponentDescription
assetsUsed in getCourse if failed to retrieve from data base

updateAllCoursesCached

ComponentDescription
AppUsed in retrieveData after receiving all SIS courses

updateRetrievedAll

ComponentDescription
AppUsed in retrieveData after receiving all SIS courses and sets boolean to true

resetUser

ComponentDescription
UserSectionUsed to reset the user when going back to the login page

Selectors

SelectorsProperty
selectUsercurrentUser
selectPlanListplanList
selectCourseCachecourseCache
selectRetrievedAllretrievedAll
selectUnfoundNumbersunfoundNumbers

selectUser

ComponentDescription
AppUsed in useEffect to check what specifically to render based if the user exists or not
HandleUserEntryDummyUsed in useEffect to either make or get plans from a user based on if they are a guest or not
UserSectionUsed to help determine if the person is a guest or not
SemesterUsed to help determine if the person is a guest or not
ActionBarUsed to help determine if the person is a guest or not
PlanChooseUsed in PlanChoose to help determine if the person is a guest or not
DashboardEntryUsed in useEffect to help determine if the person exists and then log ins based on that
CourseDisplayPopupUsed in addCourse to help determine if the person is a guest or not
DeleteCoursePopupUsed the user's id to generate a new plan
DeletePlanPopupUsed to help determine if a plan should be deleted
DeleteYearPopupUsed the user's id to generate a new plan
CourseDisplayUsed in updateDistributions to help determine if the person is a guest or not
GenerateNewPlanUsed to help with developing the plan based on user's information

selectPlanList

ComponentDescription
HandleUserEntryDummyUsed in handleFinishAdding after courses finsihed importing so need to update the plans
CourseListUsed in swapCourse to help update the current plan (index 0) in the list
SemesterUsed in handlePostResponse by replacing the plan in the list with the same id
YearSettingsDropDownUsed in handleYearChange by updating the current plan with the new one
ActionBarUsed in updateName by replacing the plan in the list with the same id
PlanChooseUsed in handlePlanChange by switching elements in the array so the new plan is the current one
CourseDisplayPopupUsed in handlePostAddCourse in updating the current plan in the list based on the id
DeleteCoursePopupUsed in activateDeleteCourse by updating list after deleting course
DeletePlanPopupUsed in deleteCurrentPlan to see if can delete, can't delete if there is only one plan
PlanAddUsed in handleCancel and sees if a user has any plans before cancelling, must have one
CourseDisplayUsed in updateDistributions when needing to update the current plan
GenerateNewPlanUsed in useEffect if needing to generate a new plan so need to add to list

selectCourseCache

ComponentDescription
AppUsed in useEffect in checking if any courses are cached yet
InfoMenuUsed in useEffect when trying to update the distributions
CourseComponentUsed in useEffect when checking prerequisites of a course
CouseListUsed in getSISCourse to send back the SIS course based on user's cache
FineDistributionUsed in useEffect when needing to update the fine distributions
CourseDisplayPopupUsed in useEffect when needing to display the information of a course
PrereqDisplayUsed in useEffect when a new course needs to get the pre reqs, in display when displaying prereqs, and in updateInspected by making a function that can update the cache
FormUsed in find when given a search query to help with finding courses

selectRetrievedAll

ComponentDescription
FormConditional in determining if all courses have been retrieved from the database yet

selectUnfoundNumbers

N/A Depreciated?