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
+29 -21
View File
@@ -14,10 +14,12 @@ import PageLoading from '../../components/PageLoading'
import { NumberFormat } from '../../config/func'
import { toast } from '../../components/Toast';
import { ErrorType } from '../../helpers/types'
import { usePermissions } from '../../hooks/usePermissions'
const DiscountList: FC = () => {
const { t } = useTranslation('global')
const { canCreate, canUpdate, canDelete } = usePermissions()
const [search, setSearch] = useState<string>('')
const getDiscounts = useGetDiscounts(search)
const deleteDiscount = useDeleteDiscount()
@@ -40,18 +42,20 @@ const DiscountList: FC = () => {
{t('discount.list')}
</div>
<Link to={Pages.discount.create}>
<Button
className='w-[172px]'
>
<div className='flex gap-2 items-center'>
<Add size={20} color='white' />
<div>
{t('discount.add_new_discount')}
{canCreate('discounts') &&
<Link to={Pages.discount.create}>
<Button
className='w-[172px]'
>
<div className='flex gap-2 items-center'>
<Add size={20} color='white' />
<div>
{t('discount.add_new_discount')}
</div>
</div>
</div>
</Button>
</Link>
</Button>
</Link>
}
</div>
@@ -114,17 +118,21 @@ const DiscountList: FC = () => {
</Td>
<Td text={t('')}>
<div className='flex gap-2 items-center'>
<Link
to={Pages.discount.detail + item.id}
>
<Edit size={20} color='#888888' />
</Link>
{canUpdate('discounts') &&
<Link
to={Pages.discount.detail + item.id}
>
<Edit size={20} color='#888888' />
</Link>
}
<Trash
size={20}
color='#888888'
onClick={() => handleDelete(item.id)}
/>
{canDelete('discounts') &&
<Trash
size={20}
color='#888888'
onClick={() => handleDelete(item.id)}
/>
}
</div>
</Td>
</tr>