Total Complexity | 3 |
Complexity/F | 0 |
Lines of Code | 64 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Link } from 'react-location' |
||
2 | import { Text } from 'shared/ui' |
||
3 | import { convertDateFormat } from 'shared/lib/convertDateFormat' |
||
4 | |||
5 | import styles from './Thumb.module.scss' |
||
6 | |||
7 | interface IProps { |
||
8 | image: string |
||
9 | movieId: number |
||
10 | title: string |
||
11 | release: string |
||
12 | alt: string |
||
13 | clickable: boolean |
||
14 | genres?: string |
||
|
|||
15 | rating: number |
||
16 | isLazy: boolean |
||
17 | } |
||
18 | |||
19 | const Thumb = ({ |
||
20 | image: imgSrc, |
||
21 | movieId, |
||
22 | title, |
||
23 | release, |
||
24 | alt, |
||
25 | clickable, |
||
26 | genres, |
||
27 | rating, |
||
28 | isLazy, |
||
29 | }: IProps) => { |
||
30 | const renderPoster = clickable ? ( |
||
31 | <Link to={`movie/${movieId}`}> |
||
32 | <img src={imgSrc} alt={alt} width={342} height={512} /> |
||
33 | </Link> |
||
34 | ) : ( |
||
35 | <img src={imgSrc} alt={alt} width={342} height={512} /> |
||
36 | ) |
||
37 | |||
38 | const renderReleaseDate = release ? convertDateFormat(release) : '' |
||
39 | |||
40 | return ( |
||
41 | <div className={styles.thumb}> |
||
42 | <div className={styles.imageWrapper}> |
||
43 | <div className={styles.image}>{renderPoster}</div> |
||
44 | <div className={styles.rating}>{rating > 0 ? rating : '-'}</div> |
||
45 | </div> |
||
46 | <div className={styles.movieInfo}> |
||
47 | <Text className={styles.movieTitle} tag="h3"> |
||
48 | <Link to={`movie/${movieId}`}>{title}</Link> |
||
49 | </Text> |
||
50 | <Text className={styles.genres} tag="p"> |
||
51 | {genres} |
||
52 | </Text> |
||
53 | <time dateTime={release}> |
||
54 | <Text className={styles.releaseDate} tag="p"> |
||
55 | {renderReleaseDate} |
||
56 | </Text> |
||
57 | </time> |
||
58 | </div> |
||
59 | </div> |
||
60 | ) |
||
61 | } |
||
62 | |||
63 | export { Thumb } |
||
64 |