icssc / peterportal-client

A web application to aid UCI students with course discovery and planning.
https://peterportal.org
MIT License
15 stars 12 forks source link

Refactor type for vote colors #401

Closed js0mmer closed 7 months ago

js0mmer commented 7 months ago

Currently vote colors is not typed and is instantiated as an empty array: https://github.com/icssc/peterportal-client/blob/acb7df1277b8a37c3263034bcfb3ae2dc239bcb4/site/src/component/Review/Review.tsx#L26

This leads to some confusing typing that occurs later: https://github.com/icssc/peterportal-client/blob/acb7df1277b8a37c3263034bcfb3ae2dc239bcb4/site/src/component/Review/Review.tsx#L75-L76

Refactor this to give the state a type that matches what is received from the backend. Also change variable names to not be one letter and to make sense semantically. A Record<string, number> or an interface like below should work for the type if I am understanding the code correctly.

interface VoteColors {
  [id: string]: number;
}

Blocked by #364

js0mmer commented 7 months ago

Made obsolete by #432 Vote colors will now be received along with reviews by using an aggregation on the endpoint