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
+31 -23
View File
@@ -13,10 +13,12 @@ import { toast } from '../../components/Toast';
import { ErrorType } from '../../helpers/types'
import Pagination from '../../components/Pagination'
import TrashWithConfrim from '../../components/TrashWithConfrim'
import { usePermissions } from '../../hooks/usePermissions'
const UsersList: FC = () => {
const navigate = useNavigate()
const { t } = useTranslation('global')
const { canCreate, canUpdate, canDelete } = usePermissions()
const [page, setPage] = useState<number>(1)
const [search, setSearch] = useState<string>('')
const getUsers = useGetUsers(search, undefined, page)
@@ -40,20 +42,22 @@ const UsersList: FC = () => {
<div>
{t('user.users_list')}
</div>
<div>
<Button
className='px-5'
onClick={() => navigate(Pages.users.create)}
>
<div className='flex gap-2'>
<Add
className='size-5'
color='#fff'
/>
<div>{t('user.add_user')}</div>
</div>
</Button>
</div>
{canCreate('admins') && (
<div>
<Button
className='px-5'
onClick={() => navigate(Pages.users.create)}
>
<div className='flex gap-2'>
<Add
className='size-5'
color='#fff'
/>
<div>{t('user.add_user')}</div>
</div>
</Button>
</div>
)}
</div>
<div className='flex justify-between items-center mt-12'>
@@ -103,16 +107,20 @@ const UsersList: FC = () => {
</Td>
<Td text={''}>
<div className='flex gap-2'>
<Link to={Pages.users.detail + item.id}>
<Eye size={20} color='#8C90A3' />
</Link>
{canUpdate('admins') && (
<Link to={Pages.users.detail + item.id}>
<Eye size={20} color='#8C90A3' />
</Link>
)}
<TrashWithConfrim
size={20}
color='#8C90A3'
onDelete={() => handleDeleteUser(item.id)}
isLoading={deleteUser.isPending}
/>
{canDelete('admins') && (
<TrashWithConfrim
size={20}
color='#8C90A3'
onDelete={() => handleDeleteUser(item.id)}
isLoading={deleteUser.isPending}
/>
)}
</div>
</Td>
<Td text={''} />