src/pages/movie/index.tsx   A
last analyzed

Complexity

Total Complexity 13
Complexity/F 0

Size

Lines of Code 83
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 68
mnd 13
bc 13
fnc 0
dl 0
loc 83
rs 10
bpm 0
cpm 0
noi 49
c 0
b 0
f 0
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 = () => {
0 ignored issues
show
introduced by
Function component is not a function declaration
Loading history...
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}>
0 ignored issues
show
introduced by
Expected indentation of 10 space characters but found 8.
Loading history...
introduced by
JSX not allowed in files with extension '.tsx'
Loading history...
introduced by
Prop key must be placed on a new line
Loading history...
33
          <Text tag="h3">{name}</Text>
0 ignored issues
show
introduced by
Expected indentation of 12 space characters but found 10.
Loading history...
introduced by
{name} must be placed on a new line
Loading history...
34
          {idx !== self.length - 1 && <Separator>&#9898;</Separator>}
0 ignored issues
show
introduced by
Expected indentation of 12 space characters but found 10.
Loading history...
introduced by
JSX element should start in a new line
Loading history...
introduced by
&#9898; must be placed on a new line
Loading history...
35
        </span>
36
      )
37
    },
38
  )
39
40
  const renderedCast = movie?.credits?.cast.map((item: IMovieCast) => {})
0 ignored issues
show
introduced by
'renderedCast' is assigned a value but never used.
Loading history...
introduced by
'item' is defined but never used.
Loading history...
introduced by
Unexpected empty arrow function.
Loading history...
41
42
  const SEO = () => (
0 ignored issues
show
introduced by
Function component is not a function declaration
Loading history...
introduced by
Declare this component outside parent component "Movie" or memoize it.
Loading history...
introduced by
Declare only one React component per file
Loading history...
43
    <Helmet
0 ignored issues
show
introduced by
Expected indentation of 6 space characters but found 4.
Loading history...
44
      defaultTitle="Moviez Rules"
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
45
      titleTemplate="Moviez Rules - %s"
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
46
      title={movie?.title}
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
introduced by
Props should be sorted alphabetically
Loading history...
47
      meta={[{ name: 'description', content: `${movie?.overview}` }]}
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
introduced by
Props should be sorted alphabetically
Loading history...
introduced by
JSX attribute values should not contain Arrays created in the same scope
Loading history...
48
      link={[
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
introduced by
Props should be sorted alphabetically
Loading history...
introduced by
JSX attribute values should not contain Arrays created in the same scope
Loading history...
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
    <>
0 ignored issues
show
introduced by
Expected indentation of 6 space characters but found 4.
Loading history...
58
      {SEO()}
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
59
      {isLoading ? (
0 ignored issues
show
introduced by
Expected indentation of 8 space characters but found 6.
Loading history...
introduced by
JSX element should start in a new line
Loading history...
60
        <LoadingTape />
0 ignored issues
show
introduced by
Expected indentation of 10 space characters but found 8.
Loading history...
61
      ) : (
62
        <div
0 ignored issues
show
introduced by
Expected indentation of 10 space characters but found 8.
Loading history...
63
          className={styles.wrapper}
0 ignored issues
show
introduced by
Expected indentation of 12 space characters but found 10.
Loading history...
64
          style={{ backgroundImage: `url(${HeroImage})` }}
0 ignored issues
show
introduced by
Expected indentation of 12 space characters but found 10.
Loading history...
introduced by
JSX attribute values should not contain objects created in the same scope
Loading history...
65
        >
66
          <div className={styles.rowHalf}>
0 ignored issues
show
introduced by
Expected indentation of 12 space characters but found 10.
Loading history...
67
            {trailer && (
0 ignored issues
show
introduced by
Expected indentation of 14 space characters but found 12.
Loading history...
68
              <YoutubeVideo embedId={trailer?.key} title={trailer?.name} />
0 ignored issues
show
introduced by
Expected indentation of 12 space characters but found 14.
Loading history...
introduced by
Prop title must be placed on a new line
Loading history...
69
            )}
70
            <div className={styles.content}>
0 ignored issues
show
introduced by
Expected indentation of 14 space characters but found 12.
Loading history...
introduced by
JSX element should start in a new line
Loading history...
71
              <Text tag="h1">{movie?.title}</Text>
0 ignored issues
show
introduced by
Expected indentation of 16 space characters but found 14.
Loading history...
introduced by
{movie?.title} must be placed on a new line
Loading history...
72
              <div className={styles.genres}>{renderedGenres}</div>
0 ignored issues
show
introduced by
Expected indentation of 16 space characters but found 14.
Loading history...
introduced by
JSX element should start in a new line
Loading history...
introduced by
{renderedGenres} must be placed on a new line
Loading history...
73
              <Text>{movie?.overview}</Text>
0 ignored issues
show
introduced by
Expected indentation of 16 space characters but found 14.
Loading history...
introduced by
JSX element should start in a new line
Loading history...
introduced by
{movie?.overview} must be placed on a new line
Loading history...
74
            </div>
75
          </div>
76
        </div>
77
      )}
78
    </>
79
  )
80
}
81
82
export default Movie
83