Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions packages/components/src/MapCardList/MapCardList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react';
import { compareDesc } from 'date-fns';
import { Box, Flex, Text } from 'theme-ui';

import { Button } from '../Button/Button';
Expand Down Expand Up @@ -29,27 +28,19 @@ export const MapCardList = (props: IProps) => {
}, [list]);

useEffect(() => {
const toRender = list
.sort((a, b) =>
compareDesc(
a.profile!.lastActive || Date.parse('0'),
b.profile!.lastActive || Date.parse('0'),
),
)
.slice(0, renderCount)
.map((item) => {
const isSelectedPin = item.id === selectedPin?.id;
const toRender = list.slice(0, renderCount).map((item) => {
const isSelectedPin = item.id === selectedPin?.id;

return (
<CardListItem
item={item}
key={item.id}
isSelectedPin={isSelectedPin}
onPinClick={onPinClick}
viewport={viewport}
/>
);
});
return (
<CardListItem
item={item}
key={item.id}
isSelectedPin={isSelectedPin}
onPinClick={onPinClick}
viewport={viewport}
/>
);
});

setDisplayItems(toRender);
}, [renderCount, list]);
Expand Down
7 changes: 7 additions & 0 deletions packages/cypress/src/integration/map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe('[Map]', () => {
cy.get('[data-cy="CardList-desktop"]').should('be.visible');
cy.get('[data-cy="list-results"]').contains(/\d+ results in view/);

cy.step('PRO users appear first in the list');
cy.get('[data-cy="CardList-desktop"]')
.find('[data-cy=CardListItem]')
.first()
.find('[data-testid="Username: pro badge"]')
.should('exist');

cy.step('Map filters can be used');
cy.get('[data-cy=MemberTypeVerticalList]')
.first()
Expand Down
10 changes: 2 additions & 8 deletions src/pages/Maps/Maps.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, Flex } from 'theme-ui';

import { MapList } from './Content/MapView/MapList';
import { MapView } from './Content/MapView/MapView';
import { filterPins } from './utils/filterPins';
import { filterPins, sortPinsByBadgeThenLastActive } from './utils/pinUtils';
import { mapPinService } from './map.service';
import { MapContext } from './MapContext';

Expand Down Expand Up @@ -133,13 +133,7 @@ const MapsPage = () => {
}
}

setAllPins(
pinsToSet.sort((a, b) => {
const aTime = a.profile.lastActive ? new Date(a.profile.lastActive).getTime() : 0;
const bTime = b.profile.lastActive ? new Date(b.profile.lastActive).getTime() : 0;
return bTime - aTime;
}),
);
setAllPins(sortPinsByBadgeThenLastActive(pinsToSet, 'pro'));

if (filters?.filters) {
const sortedTypes = (filters.filters.types || [])
Expand Down
11 changes: 0 additions & 11 deletions src/pages/Maps/utils/filterLatLong.tsx

This file was deleted.

175 changes: 0 additions & 175 deletions src/pages/Maps/utils/filterPins.test.ts

This file was deleted.

Loading
Loading