permission

This commit is contained in:
hamid zarghami
2026-07-26 08:45:44 +03:30
parent b60a38e21d
commit 185961c162
35 changed files with 764 additions and 497 deletions
+32 -24
View File
@@ -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>