Skip to content

Commit

Permalink
Format run
Browse files Browse the repository at this point in the history
  • Loading branch information
Perlkonig committed Sep 11, 2024
1 parent 907558b commit ee1014b
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions src/components/Players.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,26 @@ function Players() {
const [usedCountries, usedCountriesSetter] = useState([]);

useEffect(() => {
if (allUsers !== undefined && allUsers !== null && Array.isArray(allUsers)) {
const uniques = new Set(allUsers.map(({country}) => isoToCountryCode(country, "numeric")));
const used = [];
for (const code of uniques) {
if (code === undefined || code === null) {
continue;
}
const name = isoToCountryCode(code, "countryName");
if (name !== undefined && name !== null) {
used.push([code, name]);
}
if (
allUsers !== undefined &&
allUsers !== null &&
Array.isArray(allUsers)
) {
const uniques = new Set(
allUsers.map(({ country }) => isoToCountryCode(country, "numeric"))
);
const used = [];
for (const code of uniques) {
if (code === undefined || code === null) {
continue;
}
used.sort((a, b) => a[1].localeCompare(b[1]));
usedCountriesSetter(used);
const name = isoToCountryCode(code, "countryName");
if (name !== undefined && name !== null) {
used.push([code, name]);
}
}
used.sort((a, b) => a[1].localeCompare(b[1]));
usedCountriesSetter(used);
}
}, [allUsers]);

Expand All @@ -64,11 +70,11 @@ function Players() {
};
})
.filter(({ country }) => {
if (countryFilter === "") {
return true;
} else {
return country === countryFilter;
}
if (countryFilter === "") {
return true;
} else {
return country === countryFilter;
}
})
.filter(({ lastSeen }) => {
const now = new Date().getTime();
Expand Down Expand Up @@ -285,18 +291,22 @@ function Players() {
Hide yellow and red
</label>
</div>
{usedCountries.length === 0 ? null :
{usedCountries.length === 0 ? null : (
<div className="control">
<div className="select">
<select
onChange={(e) => countryFilterSetter(e.target.value)}
>
<option value="" key={`countryFilter|all`}>--Show all--</option>
{usedCountries.map(([code, name]) => <option value={code} key={`countryFilter|${code}`}>{name}</option>)}
<div className="select">
<select onChange={(e) => countryFilterSetter(e.target.value)}>
<option value="" key={`countryFilter|all`}>
--Show all--
</option>
{usedCountries.map(([code, name]) => (
<option value={code} key={`countryFilter|${code}`}>
{name}
</option>
))}
</select>
</div>
</div>
</div>
}
)}
</div>

<div className="container">
Expand Down

0 comments on commit ee1014b

Please sign in to comment.