1
|
|
|
import { useMatch } from 'react-location' |
2
|
|
|
import { Helmet } from 'react-helmet' |
3
|
|
|
import { YoutubeVideo } from 'entities/YoutubeVideo' |
4
|
|
|
import { Text, LoadingTape, Separator } from 'shared/ui' |
5
|
|
|
import { IMAGE_BACKDROP } from 'shared/config/images' |
6
|
|
|
|
7
|
|
|
import { IMovieDetailsVideos, IGenres, IMovieCast } from 'types/common' |
8
|
|
|
import type { LocationGenerics } from 'app/Routes' |
9
|
|
|
|
10
|
|
|
import styles from './movie.module.scss' |
11
|
|
|
|
12
|
|
|
const Movie = () => { |
|
|
|
|
13
|
|
|
const { |
14
|
|
|
data: { movie }, |
15
|
|
|
isLoading, |
16
|
|
|
} = useMatch<LocationGenerics>() |
17
|
|
|
|
18
|
|
|
const { results } = movie?.videos as IMovieDetailsVideos |
19
|
|
|
|
20
|
|
|
const HeroImage = `${import.meta.env.APP_IMAGE_URL}/${IMAGE_BACKDROP.L}${ |
21
|
|
|
movie?.backdrop_path |
22
|
|
|
}` |
23
|
|
|
|
24
|
|
|
console.log(movie) |
25
|
|
|
const trailer = results?.filter( |
26
|
|
|
({ type }: { type: string }) => type === 'Trailer', |
27
|
|
|
)[0] |
28
|
|
|
|
29
|
|
|
const renderedGenres = movie?.genres.map( |
30
|
|
|
({ id, name }: IGenres, idx: number, self: IGenres[]) => { |
31
|
|
|
return ( |
32
|
|
|
<span className={styles.genreItem} key={id}> |
|
|
|
|
33
|
|
|
<Text tag="h3">{name}</Text> |
|
|
|
|
34
|
|
|
{idx !== self.length - 1 && <Separator>⚪</Separator>} |
|
|
|
|
35
|
|
|
</span> |
36
|
|
|
) |
37
|
|
|
}, |
38
|
|
|
) |
39
|
|
|
|
40
|
|
|
const renderedCast = movie?.credits?.cast.map((item: IMovieCast) => {}) |
|
|
|
|
41
|
|
|
|
42
|
|
|
const SEO = () => ( |
|
|
|
|
43
|
|
|
<Helmet |
|
|
|
|
44
|
|
|
defaultTitle="Moviez Rules" |
|
|
|
|
45
|
|
|
titleTemplate="Moviez Rules - %s" |
|
|
|
|
46
|
|
|
title={movie?.title} |
|
|
|
|
47
|
|
|
meta={[{ name: 'description', content: `${movie?.overview}` }]} |
|
|
|
|
48
|
|
|
link={[ |
|
|
|
|
49
|
|
|
{ rel: 'preconnect', href: 'https://i.ytimg.com' }, |
50
|
|
|
{ rel: 'preconnect', href: 'https://www.youtube.com' }, |
51
|
|
|
{ rel: 'preload', as: 'image', href: `${HeroImage}` }, |
52
|
|
|
]} |
53
|
|
|
/> |
54
|
|
|
) |
55
|
|
|
|
56
|
|
|
return ( |
57
|
|
|
<> |
|
|
|
|
58
|
|
|
{SEO()} |
|
|
|
|
59
|
|
|
{isLoading ? ( |
|
|
|
|
60
|
|
|
<LoadingTape /> |
|
|
|
|
61
|
|
|
) : ( |
62
|
|
|
<div |
|
|
|
|
63
|
|
|
className={styles.wrapper} |
|
|
|
|
64
|
|
|
style={{ backgroundImage: `url(${HeroImage})` }} |
|
|
|
|
65
|
|
|
> |
66
|
|
|
<div className={styles.rowHalf}> |
|
|
|
|
67
|
|
|
{trailer && ( |
|
|
|
|
68
|
|
|
<YoutubeVideo embedId={trailer?.key} title={trailer?.name} /> |
|
|
|
|
69
|
|
|
)} |
70
|
|
|
<div className={styles.content}> |
|
|
|
|
71
|
|
|
<Text tag="h1">{movie?.title}</Text> |
|
|
|
|
72
|
|
|
<div className={styles.genres}>{renderedGenres}</div> |
|
|
|
|
73
|
|
|
<Text>{movie?.overview}</Text> |
|
|
|
|
74
|
|
|
</div> |
75
|
|
|
</div> |
76
|
|
|
</div> |
77
|
|
|
)} |
78
|
|
|
</> |
79
|
|
|
) |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
export default Movie |
83
|
|
|
|