diff --git a/rair-front/src/components/MockUpPage/NftList/NftList.tsx b/rair-front/src/components/MockUpPage/NftList/NftList.tsx index a9617881..8ff35672 100644 --- a/rair-front/src/components/MockUpPage/NftList/NftList.tsx +++ b/rair-front/src/components/MockUpPage/NftList/NftList.tsx @@ -28,12 +28,28 @@ const NftListComponent: FC = ({ titleSearch, sortItem }) => { return ; } - const filteredData = catalog.filter((item) => { - return ( - item.product.cover !== 'none' && - item.product.name.toLowerCase().includes(titleSearch.toLowerCase()) - ); - }); + const filteredData = catalog + .filter((item) => { + return ( + item.product.cover !== 'none' && + item.product.name.toLowerCase().includes(titleSearch.toLowerCase()) + ); + }) + .sort((a, b) => { + if (sortItem === 'up') { + if (a.product.name < b.product.name) { + return 1; + } + } + + if (sortItem === 'down') { + if (a.product.name > b.product.name) { + return -1; + } + } + + return 0; + }); if (catalogStatus !== dataStatuses.Complete) { return ; diff --git a/rair-front/src/components/MockUpPage/SearchPanel.tsx b/rair-front/src/components/MockUpPage/SearchPanel.tsx index 8bdfe5b7..12c228cd 100644 --- a/rair-front/src/components/MockUpPage/SearchPanel.tsx +++ b/rair-front/src/components/MockUpPage/SearchPanel.tsx @@ -361,6 +361,7 @@ const SearchPanel: FC = ({ tabIndex, setTabIndex }) => { })} diff --git a/rair-front/src/components/video/video.types.ts b/rair-front/src/components/video/video.types.ts index 28c33738..1a944146 100644 --- a/rair-front/src/components/video/video.types.ts +++ b/rair-front/src/components/video/video.types.ts @@ -1,5 +1,6 @@ import { TTokenData } from '../../axios.responseTypes'; import { CatalogVideoItem } from '../../types/commonTypes'; +import { TSortChoice } from '../ResalePage/listOffers.types'; import { ContractType } from './../adminViews/adminView.types'; export interface IVideoPlayer { @@ -23,6 +24,7 @@ export interface IVideoList { responseLabel?: string; endpoint?: string; handleVideoIsUnlocked?: () => void; + sortItem: TSortChoice | undefined; } export type MediaListResponseType = { diff --git a/rair-front/src/components/video/videoList.tsx b/rair-front/src/components/video/videoList.tsx index b927aa78..b47b1eea 100644 --- a/rair-front/src/components/video/videoList.tsx +++ b/rair-front/src/components/video/videoList.tsx @@ -14,7 +14,7 @@ import LoadingComponent from '../common/LoadingComponent'; import HomePageFilterModal from '../GlobalModal/FilterModal/FilterModal'; import GlobalModal from '../GlobalModal/GlobalModal'; -const VideoList: React.FC = ({ titleSearch }) => { +const VideoList: React.FC = ({ titleSearch, sortItem }) => { const { videoListStatus, totalVideos, videos } = useAppSelector( (state) => state.videos ); @@ -50,6 +50,21 @@ const VideoList: React.FC = ({ titleSearch }) => { .filter((video) => video.title.toLowerCase().includes(titleSearch.toLowerCase()) ) + .sort((a, b) => { + if (sortItem === 'up') { + if (a.title < b.title) { + return 1; + } + } + + if (sortItem === 'down') { + if (a.title > b.title) { + return -1; + } + } + + return 0; + }) .map((video, index) => { return ; })