add comments

This commit is contained in:
hamid zarghami
2025-09-07 15:37:00 +03:30
parent 42e5966e32
commit 554312ddc6
11 changed files with 460 additions and 12 deletions
+5 -2
View File
@@ -4,6 +4,7 @@ import { Button } from '@/components/ui/button'
import { Separator } from '@/components/ui/separator'
import { Star1 } from 'iconsax-react'
import { Product, Review } from '@/types/product.types'
import AddComment from './AddComment'
interface ReviewsProps {
product: Product
@@ -12,7 +13,7 @@ interface ReviewsProps {
const Reviews: FC<ReviewsProps> = ({ reviews = [] }) => {
const [sort, setSort] = useState<'new' | 'helpful'>('new')
const [open, setOpen] = useState(false)
const sortedReviews = useMemo(() => {
if (sort === 'new') {
return [...reviews].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
@@ -111,10 +112,12 @@ const Reviews: FC<ReviewsProps> = ({ reviews = [] }) => {
<div className="mt-3 sm:mt-4 text-xs text-[#7F7F7F] leading-5 sm:leading-6 text-justify">
شما هم درباره این کالا نظر خود را ثبت کنید. نظر شما پس از بررسی و تایید نمایش داده میشود.
</div>
<Button className="w-full mt-4 sm:mt-5 text-xs sm:text-sm">ثبت دیدگاه</Button>
<Button className="w-full mt-4 sm:mt-5 text-xs sm:text-sm" onClick={() => setOpen(true)}>ثبت دیدگاه</Button>
</div>
</div>
</div>
<AddComment open={open} close={() => setOpen(false)} />
</div>
)
}