Issues (576)

src/entities/MoviesCardsGrid/index.tsx (26 issues)

Severity
1
import { FC } from 'react'
2
import { useQuery } from 'react-query'
3
import { Helmet } from 'react-helmet'
4
import { fetchMoviesList } from './model'
5
import { Grid, LoadingTape, Thumb } from 'shared/ui'
6
import { IMAGE_THUMB } from 'shared/config/images'
7
8
import NoImage from 'shared/assets/images/no_image.jpg'
9
10
interface IProps {
11
  currentPage: number
12
}
13
14
const MoviesCardsGrid: FC<IProps> = ({ currentPage }) => {
0 ignored issues
show
Function component is not a function declaration
Loading history...
15
  const { isLoading, error, data } = useQuery(
0 ignored issues
show
'error' is assigned a value but never used.
Loading history...
16
    ['moviesList', currentPage],
17
    () => fetchMoviesList(currentPage),
18
    {
19
      keepPreviousData: true,
20
    },
21
  )
22
23
  const IMAGE_URL = import.meta.env.APP_IMAGE_URL
24
25
  const imageLinksPreload = data?.movies?.map(({ poster_path }) => ({
26
    href: `${IMAGE_URL}/${IMAGE_THUMB.L}${poster_path}`,
27
    rel: 'preload',
28
    as: 'image',
29
  }))
30
31
  const renderedMoviesCards = data?.movies?.map(
32
    ({ genre_ids, id, title, poster_path, release_date, vote_average }) => {
33
      const moviePoster = poster_path
34
        ? `${IMAGE_URL}/${IMAGE_THUMB.L}${poster_path}`
35
        : NoImage
36
37
      return (
38
        <Thumb
0 ignored issues
show
Expected indentation of 10 space characters but found 8.
Loading history...
JSX not allowed in files with extension '.tsx'
Loading history...
39
          clickable
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
40
          key={id}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
41
          alt={title}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
Props should be sorted alphabetically
Loading history...
42
          movieId={id}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
43
          title={title}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
44
          release={release_date}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
Props should be sorted alphabetically
Loading history...
45
          genres={genre_ids.join(', ')}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
Props should be sorted alphabetically
Loading history...
46
          rating={vote_average}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
Props should be sorted alphabetically
Loading history...
47
          image={moviePoster}
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
Props should be sorted alphabetically
Loading history...
48
          isLazy
0 ignored issues
show
Expected indentation of 12 space characters but found 10.
Loading history...
Props should be sorted alphabetically
Loading history...
49
        />
50
      )
51
    },
52
  )
53
54
  return isLoading ? (
55
    <LoadingTape />
0 ignored issues
show
Expected indentation of 6 space characters but found 4.
Loading history...
56
  ) : (
57
    <>
0 ignored issues
show
Expected indentation of 6 space characters but found 4.
Loading history...
58
      <Helmet link={imageLinksPreload} />
0 ignored issues
show
Expected indentation of 8 space characters but found 6.
Loading history...
59
      <Grid>{renderedMoviesCards}</Grid>
0 ignored issues
show
Expected indentation of 8 space characters but found 6.
Loading history...
JSX element should start in a new line
Loading history...
{renderedMoviesCards} must be placed on a new line
Loading history...
60
    </>
61
  )
62
}
63
64
export { MoviesCardsGrid }
65