UNPKG

@spaced-out/ui-design-system

Version:
27 lines (26 loc) 825 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRatingLabel = exports.RATING_ERRORS = exports.RATINGS = void 0; const RATING_ERRORS = exports.RATING_ERRORS = Object.freeze({ INVALID_RANGE: { type: 'INVALID_RANGE', description: 'Given rating\'s stop value cannot come before the start value.' }, INVALID_RATING_LABELS: { type: 'INVALID_RATING_LABELS', description: 'Given rating labels are invalid.' } }); const RATINGS = exports.RATINGS = ['Not-Qualified', 'Proficient', 'Silver', 'Gold', 'Platinum', 'Diamond']; const getRatingLabel = (rating, labels) => { if (rating <= 0) { return labels[0]; } else if (rating >= labels.length) { return labels.slice(-1)[0]; } else { return labels[rating]; } }; exports.getRatingLabel = getRatingLabel;