permission
This commit is contained in:
+32
-24
@@ -11,6 +11,7 @@ import { BlogItemType } from './types/BlogTypes'
|
||||
import moment from 'moment-jalaali'
|
||||
import TrashWithConfrim from '../../components/TrashWithConfrim'
|
||||
import Pagination from '../../components/Pagination'
|
||||
import { usePermissions } from '../../hooks/usePermissions'
|
||||
const BlogList: FC = () => {
|
||||
|
||||
const { t } = useTranslation('global')
|
||||
@@ -18,6 +19,7 @@ const BlogList: FC = () => {
|
||||
const [search, setSearch] = useState<string>('')
|
||||
const getBlogs = useGetBlogs(search, page);
|
||||
const deleteBlog = useDeleteBlog()
|
||||
const { canCreate, canUpdate, canDelete } = usePermissions()
|
||||
|
||||
return (
|
||||
<div className='mt-4 min-h-[500px]'>
|
||||
@@ -26,18 +28,20 @@ const BlogList: FC = () => {
|
||||
{t('blog.blog')}
|
||||
</div>
|
||||
|
||||
<Link to={Pages.blog.create}>
|
||||
<Button
|
||||
className='w-[172px]'
|
||||
>
|
||||
<div className='flex gap-2 items-center'>
|
||||
<Add size={20} color='white' />
|
||||
<div>
|
||||
{t('blog.new_blog')}
|
||||
{canCreate('blogs') && (
|
||||
<Link to={Pages.blog.create}>
|
||||
<Button
|
||||
className='w-[172px]'
|
||||
>
|
||||
<div className='flex gap-2 items-center'>
|
||||
<Add size={20} color='white' />
|
||||
<div>
|
||||
{t('blog.new_blog')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Button>
|
||||
</Link>
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -139,19 +143,23 @@ const BlogList: FC = () => {
|
||||
</Td> */}
|
||||
<Td text={''}>
|
||||
<div className='flex gap-2'>
|
||||
<Link to={Pages.blog.detail + item.id}>
|
||||
<Eye size={20} color='#8C90A3' />
|
||||
</Link>
|
||||
<TrashWithConfrim
|
||||
onDelete={() => {
|
||||
deleteBlog.mutate(item.id, {
|
||||
onSuccess: () => {
|
||||
getBlogs.refetch()
|
||||
}
|
||||
})
|
||||
}}
|
||||
isLoading={deleteBlog.isPending}
|
||||
/>
|
||||
{canUpdate('blogs') && (
|
||||
<Link to={Pages.blog.detail + item.id}>
|
||||
<Eye size={20} color='#8C90A3' />
|
||||
</Link>
|
||||
)}
|
||||
{canDelete('blogs') && (
|
||||
<TrashWithConfrim
|
||||
onDelete={() => {
|
||||
deleteBlog.mutate(item.id, {
|
||||
onSuccess: () => {
|
||||
getBlogs.refetch()
|
||||
}
|
||||
})
|
||||
}}
|
||||
isLoading={deleteBlog.isPending}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</Td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user