Skip to content

Create Another Endpoint For Getting Terms #3

@jumarmartin

Description

@jumarmartin

On the frontend we hard write the terms in the javascript itself—which isn't a lot of work as it's only updated every new term—isn't a good practice. There should always be a single source of truth.

<select
  value={selectedTerm}
  onChange={(e) => setSelectedTerm(e.currentTarget.value)}
  style={{
    WebkitAppearance: "none",
    border: "none",
    MozAppearance: "none",
    appearance: "none",
  }}
>
  <option value="21/02">Winter 2021</option>
  <option value="21/03">Spring 2021</option>
  <option value="21/04">Summer I 2021 </option>
  <option value="21/05">Summer II 2021</option>
  <option value="21/01">Fall 2021</option>
</select>

From: https://github.com/elonsoc/courseadvysr-web/blob/92ea621d92fdf9680923fe4ed520746b752cd6ed/src/pages/Courses.tsx#L79-L94

In the database, we provide both the term code and title required to make calls for a particular term.

It looks like this:

termcode title
21/01 Fall 2021
20/01 Fall 2020
21/02 Winter 2021
21/04 Summer I 2021
21/05 Summer II 2021
21/03 Spring 2021

To prevent this code smell, an endpoint to query the db for terms is required.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions