Skip to content

Commit fc2bd55

Browse files
committed
feat: Added oldest as sort param
1 parent b5fc255 commit fc2bd55

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

components/utils/Header.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ const Header = ({
173173
<CloseIcon title="Clear Search Query" color='#ffffff' size='24px' onClick={() => setSearchTerm('')}/>
174174
</NavbarSearchInput>
175175
<DropdownButton variant="outline-secondary" size="sm" id="dropdown-basic-button" title={`Sort by ${sort}`} className="border-0">
176+
<Dropdown.Item
177+
href="#"
178+
active={sort==='oldest'}
179+
onClick={() =>setSort('oldest')}>
180+
Oldest
181+
</Dropdown.Item>
176182
<Dropdown.Item
177183
href="#"
178184
active={sort==='popularity'}

components/utils/ShapeList.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ const ShapeList = (
221221
copy.sort((a, b) => b.__createdtime__ - a.__createdtime__);
222222
} else if(sort === 'popularity') {
223223
copy.sort((a, b) => b.likes - a.likes);
224+
} else if(sort === 'oldest') {
225+
copy.sort((a, b) => a.__createdtime__ - b.__createdtime__);
224226
}
225227
setFilteredShape(filterShape(copy, searchTerm));
226228
}, [searchTerm, shapes, sort]);

0 commit comments

Comments
 (0)