@@ -10,7 +10,6 @@ import { HiOutlinePlus } from "react-icons/hi2";
10
10
import { AddUpdateMovieModal } from ".." ;
11
11
import { NotAuthenticatedModal } from ".." ;
12
12
13
-
14
13
type CardProps = {
15
14
title : string ;
16
15
movies : Movie [ ] ;
@@ -19,7 +18,13 @@ type CardProps = {
19
18
rank ?: boolean ;
20
19
} ;
21
20
22
- export const Card = ( { title, movies, isAuthenticated, userId, rank } : CardProps ) => {
21
+ export const Card = ( {
22
+ title,
23
+ movies,
24
+ isAuthenticated,
25
+ userId,
26
+ rank,
27
+ } : CardProps ) => {
23
28
type ExpandedMovies = {
24
29
[ key : string ] : boolean ;
25
30
} ;
@@ -39,99 +44,93 @@ export const Card = ({ title, movies, isAuthenticated, userId, rank }: CardProps
39
44
40
45
return (
41
46
< >
42
-
43
47
< section className = "bg-gray-50 dark:bg-gray-900 " >
44
-
45
- < div className = " mx-auto flex flex-col items-center justify-center px-6 py-6 lg:py-0" >
46
- < div className = "flex justify-between space-x-5" >
47
- < h3 className = "p-10 text-center text-3xl font-semibold italic dark:text-white lg:text-4xl" >
48
- { title }
49
- </ h3 >
50
- < Button
51
- title = { `` }
52
- color = "green"
53
- size = { "md" }
54
- className = "h-10 w-10 self-center"
55
- isProcessing = { false }
56
- onClick = { ( ) => {
57
- isAuthenticated
58
- ? handleShowAddModal ( )
59
- : handleShowNotAuthenticatedModal ( ) ;
60
- } }
61
- >
62
- < HiOutlinePlus />
63
- </ Button >
64
- </ div >
65
-
66
-
67
-
68
- < div className = " w-full flex flex-wrap items-start justify-center gap-5 lg:gap-10" >
69
- { movies . map ( ( movie ) => {
70
- const isExpanded = expandedMovies [ movie . id as string ] ;
71
- return (
72
- < Component
73
- horizontal
74
- key = { movie . id }
75
- className = "w-full rounded-md border-2 border-gray-300 shadow-xl dark:border-gray-700 lg:h-[387px]"
76
- renderImage = { ( ) => (
77
- < img
78
- loading = "lazy"
79
- src = { movie . poster }
80
- alt = { `${ movie . title } + poster picture` }
81
- className = "h-64 w-auto rounded-l md:h-full lg:h-96 lg:w-64"
82
- />
83
- ) }
84
- >
85
- < div className = " flex h-full flex-col justify-start gap-5 md:gap-0 lg:gap-0" >
86
- < div className = "flex flex-col " >
87
- < h5 className = "flex space-x-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white lg:block" >
88
- { movie . title }
89
- { rank && ` (${ movie . _count ?. reviews } )` }
90
- </ h5 >
48
+ < div className = " mx-auto flex flex-col items-center justify-center px-6 py-6 lg:py-0" >
49
+ < div className = "flex justify-between space-x-5" >
50
+ < h3 className = "p-10 text-center text-3xl font-semibold italic dark:text-white lg:text-4xl" >
51
+ { title }
52
+ </ h3 >
53
+ < Button
54
+ title = { `` }
55
+ color = "green"
56
+ size = { "md" }
57
+ className = "h-10 w-10 self-center"
58
+ isProcessing = { false }
59
+ onClick = { ( ) => {
60
+ isAuthenticated
61
+ ? handleShowAddModal ( )
62
+ : handleShowNotAuthenticatedModal ( ) ;
63
+ } }
64
+ >
65
+ < HiOutlinePlus />
66
+ </ Button >
67
+ </ div >
91
68
69
+ < div className = " flex w-full flex-wrap items-start justify-center gap-5 lg:gap-10" >
70
+ { movies . map ( ( movie ) => {
71
+ const isExpanded = expandedMovies [ movie . id as string ] ;
72
+ return (
73
+ < Component
74
+ horizontal
75
+ key = { movie . id }
76
+ className = "w-full rounded-md border-2 border-gray-300 shadow-xl dark:border-gray-700 lg:h-[387px]"
77
+ renderImage = { ( ) => (
78
+ < img
79
+ loading = "lazy"
80
+ src = { movie . poster }
81
+ alt = { `${ movie . title } + poster picture` }
82
+ className = "h-64 w-auto rounded-l md:h-full lg:h-96 lg:w-64"
83
+ />
84
+ ) }
85
+ >
86
+ < div className = " flex h-full flex-col justify-start gap-5 md:gap-0 lg:gap-0" >
87
+ < div className = "flex flex-col " >
88
+ < h5 className = "flex space-x-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white lg:block" >
89
+ { movie . title }
90
+ { rank && ` (${ movie . _count ?. reviews } )` }
91
+ </ h5 >
92
92
93
- < Star />
94
- < p className = "font-normal text-gray-700 dark:text-gray-400" >
95
- { isExpanded
96
- ? `${ movie . description . substring ( 0 , 200 ) } ...`
97
- : `${ movie . description . substring ( 0 , 100 ) } ...` }
98
- < button
99
- className = "flex flex-col text-sm hover:underline"
100
- onClick = { ( ) =>
101
- setExpandedMovies ( {
102
- ...expandedMovies ,
103
- [ movie . id as string ] : ! isExpanded ,
104
- } )
105
- }
106
- >
107
- { isExpanded ? "Read Less" : "Read More" }
108
- </ button >
109
- </ p >
110
- </ div >
111
- < div className = "mt-auto w-full " >
112
- < Button
93
+ < Star />
94
+ < p className = "font-normal text-gray-700 dark:text-gray-400" >
95
+ { isExpanded
96
+ ? `${ movie . description . substring ( 0 , 200 ) } ...`
97
+ : `${ movie . description . substring ( 0 , 100 ) } ...` }
98
+ < button
99
+ className = "flex flex-col text-sm hover:underline"
113
100
onClick = { ( ) =>
114
- navigate ( `/movie/${ titleToSlug ( movie . title ) } ` )
101
+ setExpandedMovies ( {
102
+ ...expandedMovies ,
103
+ [ movie . id as string ] : ! isExpanded ,
104
+ } )
115
105
}
116
- title = { "Watch Now" }
117
- color = "failure"
118
- className = { `w-full lg:w-[270px] rounded-md ${ isExpanded ? "lg:mt-10" : "md:mt-10 lg:mt-24"
119
- } `}
120
- isProcessing = { false }
121
106
>
122
- < HiOutlineArrowRight className = "ml-2 h-5 w-5" />
123
- </ Button >
124
- </ div >
107
+ { isExpanded ? "Read Less" : "Read More" }
108
+ </ button >
109
+ </ p >
110
+ </ div >
111
+ < div className = "mt-auto w-full " >
112
+ < Button
113
+ onClick = { ( ) =>
114
+ navigate ( `/movie/${ titleToSlug ( movie . title ) } ` )
115
+ }
116
+ title = { "Watch Now" }
117
+ color = "failure"
118
+ className = { `w-full rounded-md lg:w-[270px] ${
119
+ isExpanded ? "lg:mt-10" : "md:mt-10 lg:mt-24"
120
+ } `}
121
+ isProcessing = { false }
122
+ >
123
+ < HiOutlineArrowRight className = "ml-2 h-5 w-5" />
124
+ </ Button >
125
125
</ div >
126
- </ Component >
127
- ) ;
128
- } ) }
129
- </ div >
126
+ </ div >
127
+ </ Component >
128
+ ) ;
129
+ } ) }
130
130
</ div >
131
-
131
+ </ div >
132
132
</ section >
133
133
134
-
135
134
{ showAddModal && (
136
135
< AddUpdateMovieModal
137
136
movie = { {
0 commit comments