({ product })
| 5 | import { useState } from "react" |
| 6 | |
| 7 | const ProductDescription = ({ product }) => { |
| 8 | |
| 9 | const [selectedTab, setSelectedTab] = useState('Description') |
| 10 | |
| 11 | return ( |
| 12 | <div className="my-18 text-sm text-slate-600"> |
| 13 | |
| 14 | {/* Tabs */} |
| 15 | <div className="flex border-b border-slate-200 mb-6 max-w-2xl"> |
| 16 | {['Description', 'Reviews'].map((tab, index) => ( |
| 17 | <button className={`${tab === selectedTab ? 'border-b-[1.5px] font-semibold' : 'text-slate-400'} px-3 py-2 font-medium`} key={index} onClick={() => setSelectedTab(tab)}> |
| 18 | {tab} |
| 19 | </button> |
| 20 | ))} |
| 21 | </div> |
| 22 | |
| 23 | {/* Description */} |
| 24 | {selectedTab === "Description" && ( |
| 25 | <p className="max-w-xl">{product.description}</p> |
| 26 | )} |
| 27 | |
| 28 | {/* Reviews */} |
| 29 | {selectedTab === "Reviews" && ( |
| 30 | <div className="flex flex-col gap-3 mt-14"> |
| 31 | {product.rating.map((item,index) => ( |
| 32 | <div key={index} className="flex gap-5 mb-10"> |
| 33 | <Image src={item.user.image} alt="" className="size-10 rounded-full" width={100} height={100} /> |
| 34 | <div> |
| 35 | <div className="flex items-center" > |
| 36 | {Array(5).fill('').map((_, index) => ( |
| 37 | <StarIcon key={index} size={18} className='text-transparent mt-0.5' fill={item.rating >= index + 1 ? "#00C950" : "#D1D5DB"} /> |
| 38 | ))} |
| 39 | </div> |
| 40 | <p className="text-sm max-w-lg my-4">{item.review}</p> |
| 41 | <p className="font-medium text-slate-800">{item.user.name}</p> |
| 42 | <p className="mt-3 font-light">{new Date(item.createdAt).toDateString()}</p> |
| 43 | </div> |
| 44 | </div> |
| 45 | ))} |
| 46 | </div> |
| 47 | )} |
| 48 | |
| 49 | {/* Store Page */} |
| 50 | <div className="flex gap-3 mt-14"> |
| 51 | <Image src={product.store.logo} alt="" className="size-11 rounded-full ring ring-slate-400" width={100} height={100} /> |
| 52 | <div> |
| 53 | <p className="font-medium text-slate-600">Product by {product.store.name}</p> |
| 54 | <Link href={`/shop/${product.store.username}`} className="flex items-center gap-1.5 text-green-500"> view store <ArrowRight size={14} /></Link> |
| 55 | </div> |
| 56 | </div> |
| 57 | </div> |
| 58 | ) |
| 59 | } |
| 60 | |
| 61 | export default ProductDescription |
nothing calls this directly
no outgoing calls
no test coverage detected