Uniform keys for RATING_TEXT
Closed this issue · 1 comments
oslego commented
The RATING_TEXT
object and consuming code afford the existence of both string keys like "A", "B", "C" as well as a Boolean false
and a Numeric zero for unrated services.
The object keys should have a consistent type. The false
and 0
should be collapsed into a single key given how their associated label description is identical.
Perhaps it helps to have a util method which returns a rating label and description given an input, instead of tying the service.rated
value directly to the keys of RATING_TEXT
. This would help remove some ambiguity from the code.
Something like:
getRatingText(label) {
let text = "";
switch (label) {
case "A":
text = "The terms of service treat you fairly...";
break;
case "B":
text = "...";
break;
// ... more known labels
// handle anything unexpected
default:
text = "We haven't sufficiently reviewed the terms...";
}
return text;
}
JustinBack commented
This is a good idea, we should move all functions into one place as well, I'll test something like this today