1
1
import React from 'react' ;
2
+ import Link from 'next/link' ;
2
3
import Rupee from '../Icons/Rupee' ;
4
+ import PropTypes from 'prop-types' ;
3
5
4
6
const Item = props => (
5
7
< React . Fragment >
@@ -78,17 +80,17 @@ const Item = props => (
78
80
}
79
81
` } </ style >
80
82
< li className = "product_card" >
81
- < a href = "#" >
82
- < img width = "100%" src = { props . imageUrl } alt = { props . name } />
83
- </ a >
83
+ < Link href = { `/product/ ${ props . id } ` } >
84
+ < img width = "100%" src = { props . imageUrls [ 0 ] } alt = { props . name } />
85
+ </ Link >
84
86
< div className = "product_body" >
85
87
< div className = "product_name" >
86
88
< a href = "#" > { props . name } </ a >
87
89
</ div >
88
90
< div className = "product_price" >
89
- { /*This code handles price.*/ }
90
- { /*If discounted price is available, it displays discounted price and strikes-through original price.*/ }
91
- { /*If discounted price is not available, it displays original price.*/ }
91
+ { /* This code handles price. */ }
92
+ { /* If discounted price is available, it displays discounted price and strikes-through original price. */ }
93
+ { /* If discounted price is not available, it displays original price. */ }
92
94
{ props . discountedPrice && (
93
95
< span >
94
96
< Rupee height = ".8em" />
@@ -109,12 +111,19 @@ const Item = props => (
109
111
</ div >
110
112
</ div >
111
113
< div className = "product_buttons" >
112
- { /*Add the buttons later*/ }
114
+ { /* Add the buttons later */ }
113
115
< div className = "add_button" > Add</ div >
114
116
< div className = "save_for_later" > SaveForLater</ div >
115
117
</ div >
116
118
</ li >
117
119
</ React . Fragment >
118
120
) ;
119
121
122
+ Item . propTypes = {
123
+ id : PropTypes . number ,
124
+ name : PropTypes . string ,
125
+ originalPrice : PropTypes . number ,
126
+ discountedPrice : PropTypes . number ,
127
+ imageUrls : PropTypes . arrayOf ( PropTypes . string ) ,
128
+ } ;
120
129
export default Item ;
0 commit comments