Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Index

Variables

BADGES

BADGES: BadgeModel[] = ...

Array of all the badges users can acquire on the site.

BASE_URL

BASE_URL: "https://advice-uct.vercel.app" | "http://localhost:3000" = ...

Base url for the appropriate environment

ComputerScience

ComputerScience: { majors: string[]; requires: string } = ...

Rules for majors in Computer Engineering/Business Computing

Type declaration

  • majors: string[]
  • requires: string

FIRST_YEAR_F_OR_H_COURSE

FIRST_YEAR_F_OR_H_COURSE: 18 = 18

FIRST_YEAR_SCIENCE_MIN_CREDITS

FIRST_YEAR_SCIENCE_MIN_CREDITS: 144 = 144

FIRST_YEAR_W_COURSE

FIRST_YEAR_W_COURSE: 36 = 36

FOURTH_YEAR_EDP_SCIENCE_MIN_CREDITS

FOURTH_YEAR_EDP_SCIENCE_MIN_CREDITS: 420 = 420

SECOND_YEAR_F_OR_H_COURSE

SECOND_YEAR_F_OR_H_COURSE: 24 = 24

SECOND_YEAR_SCIENCE_MIN_CREDITS

SECOND_YEAR_SCIENCE_MIN_CREDITS: 288 = 288

SECOND_YEAR_W_COURSE

SECOND_YEAR_W_COURSE: 48 = 48

THIRD_YEAR_F_OR_H_COURSE

THIRD_YEAR_F_OR_H_COURSE: 36 = 36

THIRD_YEAR_SCIENCE_MIN_CREDITS

THIRD_YEAR_SCIENCE_MIN_CREDITS: 420 = 420

THIRD_YEAR_W_COURSE

THIRD_YEAR_W_COURSE: 72 = 72

getHtml

getHtml: Function = ...

Get HTML for sending an email.

param title

Title of the email.

param html

Html body of the email.

returns

String containing entire HTML for the email.

paths

paths: { aboutUs: string; commerceHandbook: string; contactUs: string; courses: string; credits: string; dashboard: string; faq: string; glossary: string; handbooks: string; home: string; humanitiesHandbook: string; privacy: string; profile: string; scienceHandbook: string; signin: string; terms: string; uctLinks: string } = ...

Object with all the root paths of the site.

Type declaration

  • aboutUs: string
  • commerceHandbook: string
  • contactUs: string
  • courses: string
  • credits: string
  • dashboard: string
  • faq: string
  • glossary: string
  • handbooks: string
  • home: string
  • humanitiesHandbook: string
  • privacy: string
  • profile: string
  • scienceHandbook: string
  • signin: string
  • terms: string
  • uctLinks: string

sendMail

sendMail: Function = ...

Send an advice request via email to a SA.

param to

Recipient of the email to be sent.

param fromName

The originator of the email to be sent.

param notes

The notes of the advice request

Functions

Const addHistoryItem

  • addHistoryItem(date: Date, advisor: string, advisorID: string, studentID: string, notes: string): Promise<void>
  • Post a new consultation history item to the database.

    Parameters

    • date: Date

      Date of the advice session

    • advisor: string
    • advisorID: string

      The ID of the student advisor who gave the advice

    • studentID: string

      The ID of the student who received the advice

    • notes: string

      The notes from the session

    Returns Promise<void>

Const checkRules

  • checkRules(majors: string[]): { message: string; valid: boolean }
  • Checks current major selection for violation of any of the major rules.

    Parameters

    • majors: string[]

      List of major names user wants to take.

    Returns { message: string; valid: boolean }

    Object with true if selection is fine, false if selection violates rules and violation message if any.

    • message: string
    • valid: boolean

Const getAdvisors

  • getAdvisors(advisors: StudentAdvisorModel[], setAdvisors: Function, setFetching?: Function): Promise<void>
  • Use fetch-retry to retry getting student advisors details until successful. Afterwards set state to the student advisors.

    Parameters

    • advisors: StudentAdvisorModel[]

      Currently stored advisors.

    • setAdvisors: Function

      Function to set the state to the advisor data.

    • Optional setFetching: Function

    Returns Promise<void>

Const getCourse

  • Use the course ID to find the full object corresponding to that course.

    Parameters

    • courses: null | CourseModel[]

      The list of all the courses.

    • courseID: string

      The course ID of the course being looked for.

    Returns CourseModel

    A CourseModel object containing all the properties for the specified course.

Const getData

  • getData(setCourses: undefined | Function, setMajors: undefined | Function, courses: null | CourseModel[], majors: null | MajorModel[]): Promise<void>
  • Fetch majors and courses data from the database and update context with the data.

    Parameters

    • setCourses: undefined | Function

      Set context function to update courses context.

    • setMajors: undefined | Function

      Set context function to update majors context.

    • courses: null | CourseModel[]

      Current courses in context.

    • majors: null | MajorModel[]

      Current majors in context.

    Returns Promise<void>

Const getMajor

  • Use the major ID to find the full object corresponding to that major.

    Parameters

    • majors: null | MajorModel[]

      The list of all the majors.

    • majorID: string

      The major ID of the major being looked for.

    Returns MajorModel

    A MajorModel object containing all the properties for the specified major.

Const getProgramme

  • Use the programme ID to find the full object corresponding to that programme.

    Parameters

    • programmes: null | ProgrammeModel[]

      The list of all the programmes.

    • programmeID: string

      The programme ID of the programme being looked for.

    Returns ProgrammeModel

    A ProgrammeModel object containing all the properties for the specified programme.

Const getUser

  • Use the user ID to find the full object corresponding to that user.

    Parameters

    • userID: string

      The user ID of the user being looked for.

    Returns Promise<UserModel>

    A UserModel object containing all the properties for the specified user.

Const getUsers

  • Get all the users in the database

    Returns Promise<UserModel[]>

    An array of UserModel objects for all the users in the database.

Const isInList

  • Determine if the course is already in provided courses list.

    Parameters

    Returns boolean

    True if item is already in list, else false.

Const loadUser

  • loadUser(session: null | Session, user: null | UserModel, setUser: undefined | Function): Promise<void>
  • Parameters

    • session: null | Session

      Session which indicates whether there is a user session in the app.

    • user: null | UserModel

      The currently logged in user.

    • setUser: undefined | Function

      Function to update state of the user.

    Returns Promise<void>

Const sentenceToSentenceCase

  • sentenceToSentenceCase(sentence: string): string
  • Convert a sentence to sentence case.

    Parameters

    • sentence: string

      Sentence to convert to sentence case.

    Returns string

    Sentence in sentence case form.

Const sumCredits

  • Get the sum of all the courses in the toSum list.

    Parameters

    • toSum: undefined | CourseModel[]

      The list of courses to add credits from.

    • courses: null | CourseModel[]

      The list of all the courses.

    Returns number

    The sum of all the credits in the toSum parameter.

Const toSentenceCase

  • toSentenceCase(word: string): string
  • Convert a word to sentence case.

    Parameters

    • word: string

      Word to convert to sentence case.

    Returns string

    Word in sentence case form.

Generated using TypeDoc