Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | 19x 19x 19x 19x 19x | import { ReactElement } from "react"; import { decode } from "html-entities"; import { Carousel, MainTracks, PresentationCard } from "components"; import { CardType } from "components/CardContent"; import { useTranslations } from "hooks"; import { getYear } from "utils"; interface ISearchResultsProps { searchResponse: SpotifyApi.SearchResponse; } export default function SearchResults({ searchResponse, }: Readonly<ISearchResultsProps>): ReactElement { const { translations } = useTranslations(); return ( <div> {searchResponse.tracks?.items && searchResponse.tracks?.items?.length > 0 ? ( <> <MainTracks title={translations.pages.search.songs} tracksRecommendations={searchResponse.tracks?.items.slice(0, 5)} /> <Carousel gap={24}> {searchResponse.tracks?.items.slice(5)?.map((track) => { Iif (!track) return null; return ( <PresentationCard type={CardType.TRACK} key={track.id} track={track} images={track.album.images} title={track.name} subTitle={track.artists[0].name} id={track.id} isSingle /> ); })} </Carousel> </> ) : null} {searchResponse.playlists?.items && searchResponse.playlists?.items?.length > 0 ? ( <Carousel title={translations.pages.search.playlists} gap={24}> {searchResponse.playlists?.items?.map((item) => { Iif (!item) return null; const { images, name, description, id, owner } = item; return ( <PresentationCard type={CardType.PLAYLIST} key={id} images={images} title={name} subTitle={ decode(description) || `${translations.pages.search.by} ${owner.display_name ?? ""}` } id={id} /> ); })} </Carousel> ) : null} {searchResponse.artists?.items && searchResponse.artists?.items?.length > 0 ? ( <Carousel title={translations.pages.search.artists} gap={24}> {searchResponse.artists?.items?.map((item) => { Iif (!item) return null; const { images, name, id } = item; return ( <PresentationCard type={CardType.ARTIST} key={id} images={images} title={name} subTitle={translations.pages.search.artist} id={id} /> ); })} </Carousel> ) : null} {searchResponse.albums?.items && searchResponse.albums?.items?.length > 0 ? ( <Carousel title={translations.pages.search.albums} gap={24}> {searchResponse.albums?.items?.map((item) => { Iif (!item) return null; const { images, name, id, artists, release_date } = item; const artistNames = artists.map((artist) => artist.name); const subTitle = release_date ? `${getYear(release_date)} ยท ${translations.pages.search.album}` : artistNames.join(", "); return ( <PresentationCard type={CardType.ALBUM} key={id} images={images} title={name} subTitle={subTitle} id={id} /> ); })} </Carousel> ) : null} {searchResponse.shows?.items && searchResponse.shows?.items?.length > 0 ? ( <Carousel title={translations.pages.search.shows} gap={24}> {searchResponse.shows?.items?.map((item) => { Iif (!item) return null; const { images, name, id, publisher } = item; return ( <PresentationCard type={CardType.SHOW} key={id} images={images} title={name} subTitle={publisher} id={id} /> ); })} </Carousel> ) : null} {searchResponse.episodes?.items && searchResponse.episodes?.items?.length > 0 ? ( <Carousel title={translations.pages.search.episodes} gap={24}> {( searchResponse.episodes as SpotifyApi.PagingObject<SpotifyApi.EpisodeObject> )?.items?.map((item) => { Iif (!item) return null; const { images, name, id, description } = item; return ( <PresentationCard type={CardType.EPISODE} key={id} images={images} title={name} subTitle={description} id={id} isSingle /> ); })} </Carousel> ) : null} </div> ); } |