Skip to content

Commit

Permalink
Merge pull request #265 from jisazamp/develop
Browse files Browse the repository at this point in the history
feat(locale): adds locale text to answers dropdown filter
  • Loading branch information
wingkwong authored May 15, 2024
2 parents 9eae846 + ae0ec0f commit f08a4c9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib/core-components/QuizResultFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ function QuizResultFilter({ filteredValue, handleChange, appLocale }) {
};

const selectedOptionClass = isOpen ? 'selected-open' : '';
const selectedValuesLocale = {
all: appLocale.resultFilterAll,
correct: appLocale.resultFilterCorrect,
incorrect: appLocale.resultFilterIncorrect,
unanswered: appLocale.resultFilterUnanswered,
};

useEffect(() => {
const handleOutsideClick = (e) => {
if (isOpen && dropdownRef.current && !dropdownRef.current.contains(e.target)) {
if (
isOpen
&& dropdownRef.current
&& !dropdownRef.current.contains(e.target)
) {
setIsOpen(false);
}
};
Expand All @@ -44,7 +54,7 @@ function QuizResultFilter({ filteredValue, handleChange, appLocale }) {
tabIndex={0}
>
<div className={`selected-option ${selectedOptionClass}`}>
{filteredValue === 'all' ? appLocale.resultFilterAll : filteredValue}
{selectedValuesLocale[filteredValue]}
</div>
<span className={`arrow ${isOpen ? 'up' : 'down'}`} />
</div>
Expand Down

0 comments on commit f08a4c9

Please sign in to comment.