@@ -25,49 +25,61 @@ export default function ItemCards({ items, onItemClick }: ItemCardsProps) {
2525
2626 return (
2727 < div className = "w-full px-4 pb-4 gap-4 flex flex-wrap justify-center" >
28- { items . map ( ( item ) => (
29- < div key = { item . id } className = "w-48" >
30- < Button
31- variant = "ghost"
32- className = "p-0 w-full min-h-68"
33- onClick = { ( ) => handleClick ( item ) }
34- >
35- < Card className = "w-full h-full" >
36- < CardContent className = "pt-2 px-4 pb-2 h-full flex flex-col items-center justify-center" >
37- < div className = "aspect-square rounded-md overflow-hidden flex-shrink-0 w-full" >
38- { item . image ? (
39- < Image
40- src = { item . image }
41- alt = {
42- item . variant
43- ? `${ item . name } ${ item . variant } `
44- : item . name
45- }
46- className = "object-contain h-full w-full"
47- width = { 100 }
48- height = { 100 }
49- />
50- ) : (
51- < div className = "flex items-center justify-center h-full w-full" >
52- < span className = "text-gray-400 text-[4rem] font-bold" >
53- ?
54- </ span >
55- </ div >
56- ) }
57- </ div >
58- < div className = "flex flex-col items-center justify-center text-center mt-3 flex-grow w-full" >
59- < CardTitle className = "mt-2 text-center text-base leading-normal w-full whitespace-normal break-words" >
60- { item . variant ? `${ item . name } ${ item . variant } ` : item . name }
61- </ CardTitle >
62- < span className = "text-xs text-gray-500 mt-1" >
63- { ( item . price / 100 ) . toFixed ( 2 ) } € / { item . volume } ml
64- </ span >
65- </ div >
66- </ CardContent >
67- </ Card >
68- </ Button >
69- </ div >
70- ) ) }
28+ { items . map ( ( item ) => {
29+ const isInactive =
30+ item . is_active === false ||
31+ item . is_active === null ||
32+ item . is_active === undefined ;
33+ return (
34+ < div key = { item . id } className = "w-48" >
35+ < Button
36+ variant = "ghost"
37+ className = "p-0 w-full min-h-68"
38+ onClick = { ( ) => handleClick ( item ) }
39+ >
40+ < Card
41+ className = { `w-full h-full ${
42+ isInactive ? "opacity-50 bg-gray-100 dark:bg-gray-800" : ""
43+ } `}
44+ >
45+ < CardContent className = "pt-2 px-4 pb-2 h-full flex flex-col items-center justify-center" >
46+ < div className = "aspect-square rounded-md overflow-hidden flex-shrink-0 w-full" >
47+ { item . image ? (
48+ < Image
49+ src = { item . image }
50+ alt = {
51+ item . variant
52+ ? `${ item . name } ${ item . variant } `
53+ : item . name
54+ }
55+ className = "object-contain h-full w-full"
56+ width = { 100 }
57+ height = { 100 }
58+ />
59+ ) : (
60+ < div className = "flex items-center justify-center h-full w-full" >
61+ < span className = "text-gray-400 text-[4rem] font-bold" >
62+ ?
63+ </ span >
64+ </ div >
65+ ) }
66+ </ div >
67+ < div className = "flex flex-col items-center justify-center text-center mt-3 flex-grow w-full" >
68+ < CardTitle className = "mt-2 text-center text-base leading-normal w-full whitespace-normal break-words" >
69+ { item . variant
70+ ? `${ item . name } ${ item . variant } `
71+ : item . name }
72+ </ CardTitle >
73+ < span className = "text-xs text-gray-500 mt-1" >
74+ { ( item . price / 100 ) . toFixed ( 2 ) } € / { item . volume } ml
75+ </ span >
76+ </ div >
77+ </ CardContent >
78+ </ Card >
79+ </ Button >
80+ </ div >
81+ ) ;
82+ } ) }
7183 </ div >
7284 ) ;
7385}
0 commit comments