ucsb-cs156-s24 / proj-courses-s24-4pm-1

https://ucsb-cs156-s24.github.io/proj-courses-s24-4pm-1/
0 stars 0 forks source link

FEATURE: Make the default quarter the END_QTR, not the START_QTR #24

Closed github-actions[bot] closed 1 month ago

github-actions[bot] commented 1 month ago

Summary

In all pages that use the SingleQuarterDropdown component (which is most of the searches), the default quarter is taken from one of two places:

It probably makes more sense for the default value (when nothing is in local storage) to be the END_QTR value, rather than the START_QTR value. That's typically the "active" quarter, i.e. the one everyone's most concerned about.

Acceptance Criteria

Implementation Suggestions

The code that handles the default quarter in SingleQuarterDropdown is this:

  if (!localSearchQuarter) {
    localStorage.setItem(controlId, quarters[0].yyyyq);
  }

  const [quarterState, setQuarterState] = useState(
    // Stryker disable next-line all : not sure how to test/mock local storage
    quarter.yyyq || localSearchQuarter || quarters[0].yyyyq,
  );

Note that value for quarters[0].yyyyq, which is the first thing in the list of quarter passed in, which will typically be START_QTR.

Instead, it would probably make more sense for the end user if the value were the last value in that array.

So the suggested change is to:

There may be other ways to accomplish this as well.

It might be good, for example, to factor out:

const defaultQuarter = ...

And that use defaultQuarter in place of quarters[0].yyyyq

github-actions[bot] commented 1 month ago

Copied from https://github.com/ucsb-cs156/proj-courses/issues/102