@@ -27,17 +27,12 @@ interface DetailScreenProps {
27
27
export default function DetailScreen ( { route, navigation } : DetailScreenProps ) {
28
28
const { index : productIndex } = route ?. params || { index : 0 }
29
29
const product = allProducts [ productIndex ]
30
- const {
31
- colors : productColors ,
32
- image_link : imgUrl ,
33
- average_rating : averageRating
34
- } = product
35
30
36
31
const [ liked , setLiked ] = useState ( false )
37
- const [ selectedColor , setSelectedColor ] = useState ( productColors [ 0 ] . color )
32
+ const [ selectedColor , setSelectedColor ] = useState ( product . colors [ 0 ] . color )
38
33
39
34
useEffect ( ( ) => {
40
- setSelectedColor ( productColors [ 0 ] . color )
35
+ setSelectedColor ( product . colors [ 0 ] . color )
41
36
} , [ productIndex ] )
42
37
43
38
function addToCart ( ) {
@@ -70,14 +65,14 @@ export default function DetailScreen({ route, navigation }: DetailScreenProps) {
70
65
< AppLayout fullHeight >
71
66
< View style = { styles . productVisual } >
72
67
< BlobBackground
73
- fill = { colors [ productColors [ 0 ] . blobBg ] }
68
+ fill = { colors [ product . colors [ 0 ] . blobBg ] }
74
69
style = { [
75
70
styles . productBlob ,
76
71
{ transform : [ { scaleX : productIndex % 2 === 0 ? 1 : - 1 } ] }
77
72
] }
78
73
/>
79
74
< Image
80
- source = { imgUrl }
75
+ source = { product . image_link }
81
76
style = { [
82
77
styles . productImg ,
83
78
{ maxWidth : product . brand === 'Beats' ? 138 : 200 }
@@ -111,13 +106,15 @@ export default function DetailScreen({ route, navigation }: DetailScreenProps) {
111
106
112
107
< View style = { styles . productInfo } >
113
108
< View style = { styles . starsContainer } >
114
- < StarsRating { ...{ averageRating, size : 12 } } />
109
+ < StarsRating
110
+ { ...{ averageRating : product . average_rating , size : 12 } }
111
+ />
115
112
</ View >
116
113
117
114
< Text style = { styles . productName } > { product . name } </ Text >
118
115
119
116
< Text style = { styles . productPrice } >
120
- { formatUSD ( productColors [ 0 ] . price ) }
117
+ { formatUSD ( product . colors [ 0 ] . price ) }
121
118
</ Text >
122
119
</ View >
123
120
@@ -126,7 +123,7 @@ export default function DetailScreen({ route, navigation }: DetailScreenProps) {
126
123
< Text style = { styles . label } > Colors</ Text >
127
124
128
125
< View style = { styles . colorsContainer } >
129
- { productColors . map ( ( item : ProductColor , index ) => (
126
+ { product . colors . map ( ( item : ProductColor , index ) => (
130
127
< TouchableOpacity
131
128
key = { index }
132
129
hitSlop = { { top : 10 , right : 10 , bottom : 10 , left : 10 } }
0 commit comments