Advertisement
varun1729

Untitled

Apr 27th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.21 KB | None | 0 0
  1. import React from "react";
  2. import { Card, Button } from "react-bootstrap";
  3. const products = [
  4. {
  5. p_id: 1,
  6. p_name: "Product 1",
  7. p_cost: 10.99,
  8. p_category: "Category A",
  9. p_desc: "Description for product 1",
  10. p_image: "https://m.media-amazon.com/images/I/41xNB9WGLDL._MCnd_AC_.jpg",
  11. },
  12. {
  13. p_id: 2,
  14. p_name: "Product 2",
  15. p_cost: 20.99,
  16. p_category: "Category B",
  17. p_desc: "Description for product 2",
  18. p_image: "https://m.media-amazon.com/images/I/51mwR4KYp9L._MCnd_AC_.jpg",
  19. },
  20. {
  21. p_id: 3,
  22. p_name: "Product 3",
  23. p_cost: 15.99,
  24. p_category: "Category A",
  25. p_desc: "Description for product 3",
  26. p_image: "https://m.media-amazon.com/images/I/41WVCHnJY7L._MCnd_AC_.jpg",
  27. },
  28. {
  29. p_id: 4,
  30. p_name: "Product 4",
  31. p_cost: 5.99,
  32. p_category: "Category C",
  33. p_desc: "Description for product 4",
  34. p_image: "https://m.media-amazon.com/images/I/41ar14TnikL._MCnd_AC_.jpg",
  35. },
  36. {
  37. p_id: 5,
  38. p_name: "Product 5",
  39. p_cost: 25.99,
  40. p_category: "Category B",
  41. p_desc: "Description for product 5",
  42. p_image:
  43. "https://m.media-amazon.com/images/I/717ghA3VdNL._AC_UY327_QL65_.jpg",
  44. },
  45. {
  46. p_id: 6,
  47. p_name: "Product 6",
  48. p_cost: 18.99,
  49. p_category: "Category A",
  50. p_desc: "Description for product 6",
  51. p_image:
  52. "https://m.media-amazon.com/images/I/510+3Km7MtL._AC_UY327_QL65_.jpg",
  53. },
  54. {
  55. p_id: 7,
  56. p_name: "Product 7",
  57. p_cost: 12.99,
  58. p_category: "Category C",
  59. p_desc: "Description for product 7",
  60. p_image:
  61. "https://rukminim1.flixcart.com/image/612/612/kr2e3680/smartwatch/i/i/t/1-4-rmw2008-android-ios-realme-original-imag4y6fynwz3ukt.jpeg?q=70",
  62. },
  63. {
  64. p_id: 8,
  65. p_name: "Product 8",
  66. p_cost: 9.99,
  67. p_category: "Category B",
  68. p_desc: "Description for product 8",
  69. p_image:
  70. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/m/z/6/-original-imagn8v87hfyfrdh.jpeg?q=70",
  71. },
  72. {
  73. p_id: 9,
  74. p_name: "Product 9",
  75. p_cost: 22.99,
  76. p_category: "Category A",
  77. p_desc: "Description for product 9",
  78. p_image:
  79. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/e/4/c/-original-imaghxg9hnk2bztm.jpeg?q=70",
  80. },
  81. {
  82. p_id: 10,
  83. p_name: "Product 10",
  84. p_cost: 7.99,
  85. p_category: "Category C",
  86. p_desc: "Description for product 10",
  87. p_image:
  88. "https://rukminim1.flixcart.com/image/612/612/kfeamq80/smartwatch/a/u/s/ios-mydr2hn-a-apple-original-imafvvev9qsvhhgt.jpeg?q=70",
  89. },
  90. {
  91. p_id: 11,
  92. p_name: "Product 11",
  93. p_cost: 14.99,
  94. p_category: "Category B",
  95. p_desc: "Description for product 11",
  96. p_image:
  97. "https://rukminim1.flixcart.com/image/612/612/ksxjs7k0/smartwatch/s/g/x/android-sm-r875fzkainu-samsung-yes-original-imag6dthwtevempm.jpeg?q=70",
  98. },
  99. {
  100. p_id: 12,
  101. p_name: "Product 12",
  102. p_cost: 17.99,
  103. p_category: "Category A",
  104. p_desc: "Description for product 12",
  105. p_image:
  106. "https://rukminim1.flixcart.com/image/612/612/ksxjs7k0/smartwatch/u/j/h/android-sm-r890nzkainu-samsung-yes-original-imag6dtg9shty8zf.jpeg?q=70",
  107. },
  108. {
  109. p_id: 13,
  110. p_name: "Product 13",
  111. p_cost: 11.99,
  112. p_category: "Category C",
  113. p_desc: "Description for product 13",
  114. p_image:
  115. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/g/7/l/-original-imagh932jrkynahy.jpeg?q=70",
  116. },
  117. {
  118. p_id: 14,
  119. p_name: "Product 14",
  120. p_cost: 6.99,
  121. p_category: "Category B",
  122. p_desc: "Description for product 14",
  123. p_image:
  124. "https://rukminim1.flixcart.com/image/612/612/ksxjs7k0/smartwatch/r/p/f/android-sm-r890nzsainu-samsung-yes-original-imag6dtgqd5bffrt.jpeg?q=70",
  125. },
  126. {
  127. p_id: 15,
  128. p_name: "Product 15",
  129. p_cost: 21.99,
  130. p_category: "Category A",
  131. p_desc: "Description for product 15",
  132. p_image:
  133. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/i/m/o/-original-imagkfm8nxr9bsuz.jpeg?q=70",
  134. },
  135. {
  136. p_id: 16,
  137. p_name: "Product 16",
  138. p_cost: 16.99,
  139. p_category: "Category C",
  140. p_desc: "Description for product 16",
  141. p_image:
  142. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/g/w/8/1-78-bsw052-android-ios-fire-boltt-yes-original-imaggqzn5zvjfw9m.jpeg?q=70",
  143. },
  144. {
  145. p_id: 17,
  146. p_name: "Product 17",
  147. p_cost: 8.99,
  148. p_category: "Category B",
  149. p_desc: "Description for product 17",
  150. p_image:
  151. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/s/h/x/-original-imagg5qjsgky8h8a.jpeg?q=70",
  152. },
  153. {
  154. p_id: 18,
  155. p_name: "Product 18",
  156. p_cost: 23.99,
  157. p_category: "Category A",
  158. p_desc: "Description for product 18",
  159. p_image:
  160. "https://rukminim1.flixcart.com/image/612/612/l3ahpjk0/smartwatch/c/w/8/-original-imagegyhw5gemgnv.jpeg?q=70",
  161. },
  162. {
  163. p_id: 19,
  164. p_name: "Product 19",
  165. p_cost: 13.99,
  166. p_category: "Category C",
  167. p_desc: "Description for product 19",
  168. p_image:
  169. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/g/8/3/-original-imaggtjvyydggq7k.jpeg?q=70",
  170. },
  171. {
  172. p_id: 20,
  173. p_name: "Product 20",
  174. p_cost: 19.99,
  175. p_category: "Category B",
  176. p_desc: "Description for product 20",
  177. p_image:
  178. "https://rukminim1.flixcart.com/image/612/612/xif0q/smartwatch/v/v/e/-original-imagkvyessegcmp5.jpeg?q=70",
  179. },
  180. ];
  181.  
  182. function Dashboard({ products }) {
  183. return (
  184. <div>
  185. <div className="row">
  186. <div className="col-10">
  187. <div className="row row-cols-3 my-3">
  188. {products.map((product, i) => (
  189. <div className="col my-3" key={i}>
  190. <div className="card">
  191. <div className="card-header">
  192. <img
  193. src={product.p_image}
  194. className="card-img-top"
  195. alt={product.p_name}
  196. />
  197. </div>
  198. <div className="card-body">
  199. <div className="h2 card-title">{product.p_name}</div>
  200. <div className="h4 card-subtitle text-muted">
  201. {product.p_cost}
  202. </div>
  203. </div>
  204. <div className="card-footer">
  205. <button
  206. onClick={() => {
  207. alert(product.p_desc);
  208. }}
  209. className="btn btn-outline-info btn-block btn-sm"
  210. data-toggle="tooltip"
  211. data-placement="bottom"
  212. title={product.p_desc}
  213. >
  214. Learn More
  215. </button>
  216. <button
  217. onClick={() => {
  218. console.log("Added to cart:", product);
  219. }}
  220. className="btn btn-outline-success btn-block btn-sm"
  221. >
  222. Add to Cart
  223. </button>
  224. </div>
  225. </div>
  226. </div>
  227. ))}
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. );
  233. }
  234.  
  235. export default Dashboard;
  236.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement