Merge pull request #294 from mirumee/fix/shipping-screen-countries-sorting

Fix issue with country sorting on shipping page
This commit is contained in:
Marcin Gębala 2019-12-05 16:07:06 +01:00 committed by GitHub
commit be0d3e1a05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,6 +89,10 @@ const CountryList: React.FC<CountryListProps> = props => {
const [isCollapsed, setCollapseStatus] = React.useState(true); const [isCollapsed, setCollapseStatus] = React.useState(true);
const toggleCollapse = () => setCollapseStatus(!isCollapsed); const toggleCollapse = () => setCollapseStatus(!isCollapsed);
function sortCountries(countries: CountryFragment[]): CountryFragment[] {
return [...countries].sort((a, b) => a.country.localeCompare(b.country));
}
return ( return (
<Card> <Card>
<CardTitle <CardTitle
@ -131,7 +135,7 @@ const CountryList: React.FC<CountryListProps> = props => {
</TableRow> </TableRow>
{!isCollapsed && {!isCollapsed &&
renderCollection( renderCollection(
countries, sortCountries(countries),
(country, countryIndex) => ( (country, countryIndex) => (
<TableRow key={country ? country.code : "skeleton"}> <TableRow key={country ? country.code : "skeleton"}>
<TableCell className={classes.offsetCell}> <TableCell className={classes.offsetCell}>