list of reviews
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
import { Eye, Star1 } from 'iconsax-react'
|
||||
import type { ColumnType } from '@/components/types/TableTypes'
|
||||
import type { Review } from '../types/Types'
|
||||
import { formatOptionalDate } from '@/helpers/func'
|
||||
import Status from '@/components/Status'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Pages } from '@/config/Pages'
|
||||
|
||||
const getStatusVariant = (status: string): 'success' | 'error' | 'warning' | 'info' | 'pending' => {
|
||||
const variantMap: Record<string, 'success' | 'error' | 'warning' | 'info' | 'pending'> = {
|
||||
'pending': 'pending',
|
||||
'approved': 'success',
|
||||
'rejected': 'error',
|
||||
}
|
||||
return variantMap[status] || 'pending'
|
||||
}
|
||||
|
||||
export const getReviewTableColumns = (): ColumnType<Review>[] => {
|
||||
return [
|
||||
{
|
||||
key: 'user',
|
||||
title: 'کاربر',
|
||||
render: (item: Review) => {
|
||||
const name = [item.user.firstName, item.user.lastName].filter(Boolean).join(' ')
|
||||
return name || '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'food',
|
||||
title: 'غذا',
|
||||
render: (item: Review) => {
|
||||
return item.food.title || '-'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'rating',
|
||||
title: 'امتیاز',
|
||||
render: (item: Review) => {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<Star1
|
||||
size={16}
|
||||
color="black"
|
||||
variant="Bold"
|
||||
/>
|
||||
<div className='mt-1 text-sm'>{item.rating}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'comment',
|
||||
title: 'نظر',
|
||||
render: (item: Review) => {
|
||||
return (
|
||||
<div className="max-w-xs truncate" title={item.comment}>
|
||||
{item.comment || '-'}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
title: 'وضعیت',
|
||||
render: (item: Review) => {
|
||||
const statusLabels: Record<string, string> = {
|
||||
'pending': 'در انتظار',
|
||||
'approved': 'تایید شده',
|
||||
'rejected': 'رد شده',
|
||||
}
|
||||
return (
|
||||
<Status
|
||||
variant={getStatusVariant(item.status)}
|
||||
label={statusLabels[item.status] || item.status}
|
||||
/>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
title: 'تاریخ ثبت',
|
||||
render: (item: Review) => {
|
||||
return formatOptionalDate(item.createdAt, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'details',
|
||||
title: '',
|
||||
render: (item: Review) => {
|
||||
return (
|
||||
<Link to={Pages.reviews.detail + item.id}>
|
||||
<Eye size={20} color="#8C90A3" className="cursor-pointer" />
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user