-
-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add movie/series genre list pages (#1194)
- Loading branch information
1 parent
b767a58
commit 6f1a31d
Showing
17 changed files
with
198 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useContext } from 'react'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
import useSWR from 'swr'; | ||
import GenreCard from '../../GenreCard'; | ||
import { GenreSliderItem } from '../../../../server/interfaces/api/discoverInterfaces'; | ||
import { LanguageContext } from '../../../context/LanguageContext'; | ||
import { genreColorMap } from '../constants'; | ||
import PageTitle from '../../Common/PageTitle'; | ||
import Header from '../../Common/Header'; | ||
import LoadingSpinner from '../../Common/LoadingSpinner'; | ||
import Error from '../../../pages/_error'; | ||
|
||
const messages = defineMessages({ | ||
moviegenres: 'Movie Genres', | ||
}); | ||
|
||
const MovieGenreList: React.FC = () => { | ||
const { locale } = useContext(LanguageContext); | ||
const intl = useIntl(); | ||
const { data, error } = useSWR<GenreSliderItem[]>( | ||
`/api/v1/discover/genreslider/movie?language=${locale}` | ||
); | ||
|
||
if (!data && !error) { | ||
return <LoadingSpinner />; | ||
} | ||
|
||
if (!data) { | ||
return <Error statusCode={404} />; | ||
} | ||
|
||
return ( | ||
<> | ||
<PageTitle title={intl.formatMessage(messages.moviegenres)} /> | ||
<div className="mt-1 mb-5"> | ||
<Header>{intl.formatMessage(messages.moviegenres)}</Header> | ||
</div> | ||
<ul className="cards-horizontal"> | ||
{data.map((genre, index) => ( | ||
<li key={`genre-${genre.id}-${index}`}> | ||
<GenreCard | ||
name={genre.name} | ||
image={`https://www.themoviedb.org/t/p/w1280_filter(duotone,${ | ||
genreColorMap[genre.id] ?? genreColorMap[0] | ||
})${genre.backdrops[4]}`} | ||
url={`/discover/movies/genre/${genre.id}`} | ||
canExpand | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</> | ||
); | ||
}; | ||
|
||
export default MovieGenreList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useContext } from 'react'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
import useSWR from 'swr'; | ||
import GenreCard from '../../GenreCard'; | ||
import { GenreSliderItem } from '../../../../server/interfaces/api/discoverInterfaces'; | ||
import { LanguageContext } from '../../../context/LanguageContext'; | ||
import { genreColorMap } from '../constants'; | ||
import PageTitle from '../../Common/PageTitle'; | ||
import Header from '../../Common/Header'; | ||
import LoadingSpinner from '../../Common/LoadingSpinner'; | ||
import Error from '../../../pages/_error'; | ||
|
||
const messages = defineMessages({ | ||
seriesgenres: 'Series Genres', | ||
}); | ||
|
||
const TvGenreList: React.FC = () => { | ||
const { locale } = useContext(LanguageContext); | ||
const intl = useIntl(); | ||
const { data, error } = useSWR<GenreSliderItem[]>( | ||
`/api/v1/discover/genreslider/tv?language=${locale}` | ||
); | ||
|
||
if (!data && !error) { | ||
return <LoadingSpinner />; | ||
} | ||
|
||
if (!data) { | ||
return <Error statusCode={404} />; | ||
} | ||
|
||
return ( | ||
<> | ||
<PageTitle title={intl.formatMessage(messages.seriesgenres)} /> | ||
<div className="mt-1 mb-5"> | ||
<Header>{intl.formatMessage(messages.seriesgenres)}</Header> | ||
</div> | ||
<ul className="cards-horizontal"> | ||
{data.map((genre, index) => ( | ||
<li key={`genre-${genre.id}-${index}`}> | ||
<GenreCard | ||
name={genre.name} | ||
image={`https://www.themoviedb.org/t/p/w1280_filter(duotone,${ | ||
genreColorMap[genre.id] ?? genreColorMap[0] | ||
})${genre.backdrops[4]}`} | ||
url={`/discover/tv/genre/${genre.id}`} | ||
canExpand | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</> | ||
); | ||
}; | ||
|
||
export default TvGenreList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import { NextPage } from 'next'; | ||
import MovieGenreList from '../../../components/Discover/MovieGenreList'; | ||
|
||
const MovieGenresPage: NextPage = () => { | ||
return <MovieGenreList />; | ||
}; | ||
|
||
export default MovieGenresPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import { NextPage } from 'next'; | ||
import TvGenreList from '../../../components/Discover/TvGenreList'; | ||
|
||
const TvGenresPage: NextPage = () => { | ||
return <TvGenreList />; | ||
}; | ||
|
||
export default TvGenresPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters