Permits list: shortcuts to the tender order permits and distribution summary reports

Shown per report permission, same as the orders report shortcut.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Samer Salameh 2026-11-18 15:01:25 +03:00
parent e487c05248
commit 2a339afee3
1 changed files with 11 additions and 1 deletions

View File

@ -42,6 +42,8 @@ import { formatDate, formatNumber } from '@/components/meta/format';
import { elementToPdfUrl, type PdfOrientation } from '@/lib/pdf'; import { elementToPdfUrl, type PdfOrientation } from '@/lib/pdf';
import { useFeatureUi } from '@/i18n/useUi'; import { useFeatureUi } from '@/i18n/useUi';
import { useAuth } from '@/providers/AuthProvider'; import { useAuth } from '@/providers/AuthProvider';
import AssessmentIcon from '@mui/icons-material/Assessment';
import reportStrings from '../grains-reports/strings';
import { useConfirm } from '@/providers/ConfirmProvider'; import { useConfirm } from '@/providers/ConfirmProvider';
import { useToast } from '@/providers/ToastProvider'; import { useToast } from '@/providers/ToastProvider';
import { import {
@ -211,7 +213,10 @@ function usePermitActions() {
// ================================================================= permit list (GNPermits.cfm) // ================================================================= permit list (GNPermits.cfm)
export function PermitsPage() { export function PermitsPage() {
const { t, lang } = useFeatureUi(strings); const { t, lang } = useFeatureUi(strings);
const { user } = useAuth(); const { user, can } = useAuth();
const navigate = useNavigate();
// shortcuts to the reports of this screen, shown with the permission of each report menu entry
const reportLinks = (['tender-order', 'distribution-summary'] as const).filter((k) => can(`grains.reports.t.${k}`));
const { run, element } = usePermitActions(); const { run, element } = usePermitActions();
const companyUser = Number(user?.stkId) === 62; // legacy session.stkid = 62 const companyUser = Number(user?.stkId) === 62; // legacy session.stkid = 62
const showRevoked = String(user?.userId ?? '').toUpperCase() === 'GTOM1'; // legacy: only this login sees "ملغي" const showRevoked = String(user?.userId ?? '').toUpperCase() === 'GTOM1'; // legacy: only this login sees "ملغي"
@ -238,6 +243,11 @@ export function PermitsPage() {
title={t('pm.list.title')} subtitle={t('pm.list.subtitle')} title={t('pm.list.title')} subtitle={t('pm.list.subtitle')}
actions={( actions={(
<> <>
{reportLinks.map((k) => (
<Button key={k} variant="outlined" startIcon={<AssessmentIcon />} onClick={() => navigate(`/grains/reports/t/${k}`)}>
{reportStrings[`rpt.t.${k}`]![lang]}
</Button>
))}
{canVoiceCall && ( {canVoiceCall && (
<Button <Button
variant="outlined" startIcon={<PhoneInTalkIcon />} disabled={voiceCall.isPending} variant="outlined" startIcon={<PhoneInTalkIcon />} disabled={voiceCall.isPending}