Feature work: events section, filters, form layouts, wizard fixes
- Record pages: collapsible Events table (GETLOG) with filters and an old/new values popup - New-password dialog with a copy button after "reset password immediately" - Confirmation tick box on create/edit forms for non-Nafith users - Entry permit requests: menu placement, create form fields, sender/receiver filters (dependent lists, role-limited), no record count under grid titles - Deposits, Users, Employees, Driver-Owner, Trucks and fleet layout changes - Plate code value in Arabic edit/view forms; audit fields on all fleet record pages - Logistics platform menu hidden; wizard hint lines and driver-documents message fixed - Session-ended redirect and other client fixes - Small syntax changes ahead of MUI 9 (sx instead of system props, slotProps, icon names) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dd179a2e30
commit
e1182bf4af
|
|
@ -54,7 +54,13 @@ export function parseBackendJson<T = unknown>(raw: string): T {
|
|||
let value: unknown = JSON.parse(text);
|
||||
if (typeof value === 'string') {
|
||||
text = clean(value);
|
||||
// some answers are just a word inside the JSON string (the receipt check says "VALID" or "RECEIPT_NUMBER_…"):
|
||||
// keep it as the text it is when it is not JSON itself
|
||||
try {
|
||||
value = JSON.parse(text);
|
||||
} catch {
|
||||
value = text;
|
||||
}
|
||||
}
|
||||
return value as T;
|
||||
}
|
||||
|
|
@ -67,6 +73,12 @@ export interface Envelope<T = unknown> {
|
|||
[k: string]: unknown;
|
||||
}
|
||||
|
||||
/** Called once when the backend says the session has ended (code 405 / SESSION_ENDED); the auth provider signs the user out of the app. */
|
||||
let sessionEndedHandler: (() => void) | undefined;
|
||||
export const onSessionEnded = (fn: (() => void) | undefined) => {
|
||||
sessionEndedHandler = fn;
|
||||
};
|
||||
|
||||
export async function rpc<T = unknown>(
|
||||
entity: string,
|
||||
method: string,
|
||||
|
|
@ -90,7 +102,10 @@ export async function rpc<T = unknown>(
|
|||
const env = data as Envelope;
|
||||
if (env && typeof env === 'object' && !Array.isArray(env)) {
|
||||
// 405 = session ended; 470 = request rejected by the regex guard.
|
||||
if (env.code === 405 || env.CODE === 405) throw new ApiError('SESSION_ENDED', 405);
|
||||
if (env.code === 405 || env.CODE === 405 || env.MESSAGE === 'SESSION_ENDED' || env.MESSAGECODE === 'SESSION_ENDED') {
|
||||
sessionEndedHandler?.();
|
||||
throw new ApiError('SESSION_ENDED', 405);
|
||||
}
|
||||
if (env.code === 470) throw new ApiError('ACCESS_DENIED', 470);
|
||||
}
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export interface PackageCard {
|
|||
id: string;
|
||||
title: string;
|
||||
/** description / duration / price lines, in the order the card shows them */
|
||||
lines: { kind: 'info' | 'duration' | 'price' | 'text'; text: string }[];
|
||||
lines: { kind: 'info' | 'duration' | 'price' | 'text' | 'hint'; text: string }[];
|
||||
/** arguments of the button's click handler, e.g. getServiceSubscriptions('MT0003','ACCESS',title,'FLEET') */
|
||||
args: string[];
|
||||
}
|
||||
|
|
@ -28,9 +28,11 @@ function parseColumn(html: unknown): PackageCard[] {
|
|||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
return [...doc.querySelectorAll('.card')].map((card) => {
|
||||
const click = card.querySelector('[onclick]')?.getAttribute('onclick') ?? '';
|
||||
const lines = [...card.querySelectorAll('p.card-text')].map((p) => {
|
||||
// the description / duration / price lines, plus the coloured ("pink") hint paragraphs some services carry (container hints)
|
||||
const lines = [...card.querySelectorAll('p.card-text, p.pink')].map((p) => {
|
||||
const icon = p.querySelector('i')?.className ?? '';
|
||||
return { kind: KIND.find(([c]) => icon.includes(c))?.[1] ?? 'text', text: p.textContent?.replace(/\s+/g, ' ').trim() ?? '' };
|
||||
const kind = p.classList.contains('pink') ? 'hint' : KIND.find(([c]) => icon.includes(c))?.[1] ?? 'text';
|
||||
return { kind, text: p.textContent?.replace(/\s+/g, ' ').trim() ?? '' };
|
||||
});
|
||||
return {
|
||||
id: card.id.replace(/_card$|_serviceCard$/, ''),
|
||||
|
|
@ -184,7 +186,10 @@ export interface CreateResult {
|
|||
|
||||
/** The request the old wizard's "Pay" button sends. */
|
||||
export async function createSubscription(p: SubscriptionRequest) {
|
||||
const r = await rpc<CreateResult>('subscriptions', 'CREATE', p as unknown as Record<string, unknown>, { post: true });
|
||||
// the old request layer sent every array argument as a comma list ("A,B"), and the backend reads the group codes as a
|
||||
// list (listLen): a real array makes it fail with "…cannot be converted to a simple value"
|
||||
const args: Record<string, unknown> = { ...p, packageGroupCode: Array.isArray(p.packageGroupCode) ? p.packageGroupCode.join(',') : p.packageGroupCode };
|
||||
const r = await rpc<CreateResult>('subscriptions', 'CREATE', args, { post: true });
|
||||
// one-trip requests report their outcome in RESULTCODE (handled by the wizard); everything else uses CODE
|
||||
if (r.RESULTCODE === undefined && String(r.CODE) !== '000') throw new ApiError(String(r.MESSAGE ?? 'ACTION_FAILED'), r.CODE);
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
|
||||
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { rpc } from '../api/client';
|
||||
import { onSessionEnded, rpc } from '../api/client';
|
||||
import { createExternalSession, fetchSessionUser, login as apiLogin, logout as apiLogout, type SessionUser } from '../api/session';
|
||||
import { getConfig, type AppConfig } from '../api/config';
|
||||
|
||||
|
|
@ -88,6 +88,22 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|||
document.documentElement.dir = lang === 'AR' || lang === 'URD' ? 'rtl' : 'ltr';
|
||||
}, [lang]);
|
||||
|
||||
// the backend ended the session (timeout, signed in elsewhere, server restart): leave the app and go to the login page,
|
||||
// exactly like a sign-out. Nothing happens when nobody is signed in (public sign-up pages, the login page itself).
|
||||
useEffect(() => {
|
||||
onSessionEnded(() => {
|
||||
if (!qc.getQueryData(['session'])) return;
|
||||
try {
|
||||
sessionStorage.setItem('mams.sessionEnded', '1');
|
||||
} catch {
|
||||
/* storage can be blocked */
|
||||
}
|
||||
qc.setQueryData(['session'], null);
|
||||
qc.removeQueries({ predicate: (q) => q.queryKey[0] !== 'session' });
|
||||
});
|
||||
return () => onSessionEnded(undefined);
|
||||
}, [qc]);
|
||||
|
||||
const signIn = async (u: string, p: string, rememberMe = false) => {
|
||||
await apiLogin(u, p, LANG_IDS[lang] ?? 1, rememberMe);
|
||||
await qc.invalidateQueries({ queryKey: ['session'] });
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { isRtl, useLabel, useT, useUi } from '../i18n';
|
|||
import { roleLabel } from '../i18n/roles';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useNotify } from '../notify/NotifyProvider';
|
||||
import { NewPasswordDialog, findNewPassword, isPasswordReset } from './NewPasswordDialog';
|
||||
import { WithdrawDialog } from '../features/gridActions/WithdrawDialog';
|
||||
import { CONFIRM_ROW_ACTIONS, DIALOG_ROW_ACTIONS, parseRowActions, runRowAction, type RowAction } from '../api/gridActions';
|
||||
import { StatusChip } from './StatusChip';
|
||||
|
|
@ -30,11 +31,31 @@ function GridLoading({ text }: { text: string }) {
|
|||
return () => clearTimeout(h);
|
||||
}, []);
|
||||
return (
|
||||
<Stack direction="row" spacing={2} alignItems="center" role="status" aria-live="polite" sx={{ px: 2, py: 1.5, bgcolor: 'action.hover', borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={2}
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
px: 2,
|
||||
py: 1.5,
|
||||
bgcolor: 'action.hover',
|
||||
borderBottom: 1,
|
||||
borderColor: 'divider'
|
||||
}}>
|
||||
<CircularProgress size={22} />
|
||||
<Box>
|
||||
<Typography fontWeight={700} fontSize={14}>{text}</Typography>
|
||||
{slow && <Typography fontSize={12.5} color="text.secondary">{ui('gridLoadingSlow')}</Typography>}
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
fontSize: 14
|
||||
}}>{text}</Typography>
|
||||
{slow && <Typography
|
||||
sx={{
|
||||
fontSize: 12.5,
|
||||
color: "text.secondary"
|
||||
}}>{ui('gridLoadingSlow')}</Typography>}
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
|
|
@ -74,11 +95,13 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
const [menu, setMenu] = useState<{ el: HTMLElement; actions: RowAction[] } | null>(null);
|
||||
const [confirmAction, setConfirmAction] = useState<RowAction | null>(null);
|
||||
const [withdrawId, setWithdrawId] = useState<string | null>(null);
|
||||
const [newPassword, setNewPassword] = useState<string | null>(null);
|
||||
const doAction = useMutation({
|
||||
meta: { loading: 'processing' },
|
||||
mutationFn: (a: RowAction) => runRowAction(entity, a, filter),
|
||||
onSuccess: (msg) => {
|
||||
notify.success(msg, ui('saved'));
|
||||
onSuccess: (msg, a) => {
|
||||
if (isPasswordReset(a.name) && findNewPassword(msg)) setNewPassword(msg);
|
||||
else notify.success(msg, ui('saved'));
|
||||
void data.refetch();
|
||||
},
|
||||
onError: (e) => notify.error(e),
|
||||
|
|
@ -161,7 +184,6 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
<TableCell padding="checkbox">
|
||||
<Checkbox
|
||||
size="small"
|
||||
inputProps={{ 'aria-label': ui('selectAll') }}
|
||||
checked={list.length > 0 && list.every((r) => rowId(r) in selected)}
|
||||
indeterminate={list.some((r) => rowId(r) in selected) && !list.every((r) => rowId(r) in selected)}
|
||||
onChange={(e) => {
|
||||
|
|
@ -172,6 +194,9 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
}
|
||||
onSelectedChange?.(next);
|
||||
}}
|
||||
slotProps={{
|
||||
input: { 'aria-label': ui('selectAll') }
|
||||
}}
|
||||
/>
|
||||
</TableCell>
|
||||
)}
|
||||
|
|
@ -216,7 +241,6 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
<TableCell padding="checkbox" onClick={(e) => e.stopPropagation()}>
|
||||
<Checkbox
|
||||
size="small"
|
||||
inputProps={{ 'aria-label': ui('selectRow') }}
|
||||
checked={rowId(r) in selected}
|
||||
onChange={(e) => {
|
||||
const next = { ...selected };
|
||||
|
|
@ -224,6 +248,9 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
else delete next[rowId(r)];
|
||||
onSelectedChange?.(next);
|
||||
}}
|
||||
slotProps={{
|
||||
input: { 'aria-label': ui('selectRow') }
|
||||
}}
|
||||
/>
|
||||
</TableCell>
|
||||
)}
|
||||
|
|
@ -255,7 +282,13 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
</TableBody>
|
||||
</Table>
|
||||
{!loading && !list.length && (
|
||||
<Stack alignItems="center" spacing={1} sx={{ py: 8, color: 'text.secondary' }}>
|
||||
<Stack
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
py: 8,
|
||||
color: 'text.secondary'
|
||||
}}>
|
||||
<SearchOffOutlined sx={{ fontSize: 40 }} />
|
||||
<Typography>{ui('noResults')}</Typography>
|
||||
</Stack>
|
||||
|
|
@ -294,6 +327,7 @@ export function EntityGrid({ entity, filter, canEdit, onTotal, onFilterRequired,
|
|||
))}
|
||||
</Menu>
|
||||
{withdrawId && <WithdrawDialog id={withdrawId} onClose={() => setWithdrawId(null)} onDone={() => { setWithdrawId(null); void data.refetch(); }} />}
|
||||
<NewPasswordDialog message={newPassword} onClose={() => setNewPassword(null)} />
|
||||
<Dialog open={!!confirmAction} onClose={() => setConfirmAction(null)}>
|
||||
<DialogTitle>{confirmAction?.label || t(confirmAction?.name ?? '')}</DialogTitle>
|
||||
<DialogContent>{t('CONFIRM_MSG')}</DialogContent>
|
||||
|
|
|
|||
|
|
@ -37,10 +37,16 @@ export function GlobalLoading() {
|
|||
{bar && <LinearProgress sx={{ position: 'fixed', top: 0, insetInline: 0, height: 3, zIndex: (t) => t.zIndex.tooltip + 2 }} />}
|
||||
<Backdrop open={card} sx={{ zIndex: (t) => t.zIndex.modal + 10, bgcolor: 'rgba(8, 16, 28, 0.45)', backdropFilter: 'blur(2px)' }}>
|
||||
<Paper sx={{ px: 4, py: 3, minWidth: 280, textAlign: 'center', borderRadius: 3 }} elevation={8}>
|
||||
<Stack spacing={1.5} alignItems="center">
|
||||
<Stack spacing={1.5} sx={{
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<CircularProgress />
|
||||
<Typography fontWeight={700}>{ui(pending[0] ?? 'processing')}</Typography>
|
||||
<Typography variant="body2" color="text.secondary">{slow ? ui('stillWorking') : ui('pleaseWait')}</Typography>
|
||||
<Typography sx={{
|
||||
fontWeight: 700
|
||||
}}>{ui(pending[0] ?? 'processing')}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{slow ? ui('stillWorking') : ui('pleaseWait')}</Typography>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Backdrop>
|
||||
|
|
|
|||
|
|
@ -13,12 +13,26 @@ export function LoadingScreen() {
|
|||
}, []);
|
||||
return (
|
||||
<Box sx={{ display: 'grid', placeItems: 'center', minHeight: '100vh', p: 2 }}>
|
||||
<Stack spacing={2.5} alignItems="center" textAlign="center">
|
||||
<Stack
|
||||
spacing={2.5}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
textAlign: "center"
|
||||
}}>
|
||||
<Logo height={48} />
|
||||
<CircularProgress size={36} />
|
||||
<Box>
|
||||
<Typography fontWeight={600}>{ui('loadingWorkspace')}</Typography>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ minHeight: 22, transition: 'opacity .4s', opacity: slow ? 1 : 0 }}>
|
||||
<Typography sx={{
|
||||
fontWeight: 600
|
||||
}}>{ui('loadingWorkspace')}</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
minHeight: 22,
|
||||
transition: 'opacity .4s',
|
||||
opacity: slow ? 1 : 0
|
||||
}}>
|
||||
{ui('firstLoad')}
|
||||
</Typography>
|
||||
</Box>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
import { useState } from 'react';
|
||||
import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Tooltip, Typography } from '@mui/material';
|
||||
import ContentCopyOutlined from '@mui/icons-material/ContentCopyOutlined';
|
||||
import CheckOutlined from '@mui/icons-material/CheckOutlined';
|
||||
import { useT, useUi } from '../i18n';
|
||||
|
||||
/** The "reset password immediately" action answers with the new password inside its message (the generated one: "p" + 6 digits). */
|
||||
export const isPasswordReset = (action: string) => action === 'RESET_PASSWORD_IMMEDIATELY';
|
||||
export const findNewPassword = (message: string) => message.match(/\bp\d{6}\b/)?.[0];
|
||||
|
||||
export function NewPasswordDialog({ message, onClose }: { message: string | null; onClose: () => void }) {
|
||||
const t = useT();
|
||||
const ui = useUi();
|
||||
const [copied, setCopied] = useState(false);
|
||||
const password = message ? findNewPassword(message) : undefined;
|
||||
|
||||
const copy = async () => {
|
||||
if (!password) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(password);
|
||||
} catch {
|
||||
// clipboard blocked (plain http): fall back to selecting a hidden text box
|
||||
const el = document.createElement('textarea');
|
||||
el.value = password;
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
el.remove();
|
||||
}
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={!!message} onClose={onClose} maxWidth="xs" fullWidth>
|
||||
<DialogTitle>{t('SUCCESSFUL.OPERATION')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
mb: password ? 1.5 : 0
|
||||
}}>{message ? t(message) : ''}</Typography>
|
||||
{password && (
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 1, p: 1, px: 1.5, border: 1, borderColor: 'divider', borderRadius: 1, bgcolor: 'action.hover' }}>
|
||||
<Typography
|
||||
dir="ltr"
|
||||
sx={{
|
||||
fontFamily: "monospace",
|
||||
fontSize: 18,
|
||||
fontWeight: 700,
|
||||
userSelect: 'all'
|
||||
}}>{password}</Typography>
|
||||
<Tooltip title={copied ? ui('copied') : ui('copy')}>
|
||||
<IconButton size="small" color={copied ? 'success' : 'primary'} onClick={() => void copy()} aria-label={ui('copy')}>
|
||||
{copied ? <CheckOutlined fontSize="small" /> : <ContentCopyOutlined fontSize="small" />}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
)}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={onClose}>{t('CLOSE') !== 'CLOSE' ? t('CLOSE') : ui('close')}</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -33,17 +33,41 @@ export function PageHeader({
|
|||
backTo?: string;
|
||||
}) {
|
||||
return (
|
||||
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5} alignItems={{ sm: 'center' }} justifyContent="space-between" sx={{ mb: 2 }}>
|
||||
<Stack direction="row" spacing={1.5} alignItems="center" sx={{ minWidth: 0 }}>
|
||||
<Stack
|
||||
direction={{ xs: 'column', sm: 'row' }}
|
||||
spacing={1.5}
|
||||
sx={{
|
||||
alignItems: { sm: 'center' },
|
||||
justifyContent: "space-between",
|
||||
mb: 2
|
||||
}}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1.5}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
minWidth: 0
|
||||
}}>
|
||||
{backTo && <BackButton to={backTo} />}
|
||||
{lead}
|
||||
<Box sx={{ minWidth: 0 }}>
|
||||
{/* the page's one h1: a screen reader's outline starts from it */}
|
||||
<Typography variant="h5" component="h1" fontWeight={800} noWrap sx={{ color: '#d1a233' }}>{title}</Typography>
|
||||
{subtitle && <Typography variant="body2" color="text.secondary" component="div">{subtitle}</Typography>}
|
||||
<Typography
|
||||
variant="h5"
|
||||
component="h1"
|
||||
noWrap
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
color: '#d1a233'
|
||||
}}>{title}</Typography>
|
||||
{subtitle && <Typography variant="body2" component="div" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{subtitle}</Typography>}
|
||||
</Box>
|
||||
</Stack>
|
||||
{actions && <Stack direction="row" spacing={1} flexShrink={0}>{actions}</Stack>}
|
||||
{actions && <Stack direction="row" spacing={1} sx={{
|
||||
flexShrink: 0
|
||||
}}>{actions}</Stack>}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { ElementType } from 'react';
|
||||
import InfoOutlined from '@mui/icons-material/InfoOutlined';
|
||||
import LocationOnOutlined from '@mui/icons-material/LocationOnOutlined';
|
||||
import PersonOutline from '@mui/icons-material/PersonOutline';
|
||||
import PersonOutline from '@mui/icons-material/PersonOutlineOutlined';
|
||||
import BadgeOutlined from '@mui/icons-material/BadgeOutlined';
|
||||
import AttachFileOutlined from '@mui/icons-material/AttachFileOutlined';
|
||||
import VerifiedUserOutlined from '@mui/icons-material/VerifiedUserOutlined';
|
||||
|
|
@ -9,7 +9,7 @@ import LocalShippingOutlined from '@mui/icons-material/LocalShippingOutlined';
|
|||
import DescriptionOutlined from '@mui/icons-material/DescriptionOutlined';
|
||||
import PaymentsOutlined from '@mui/icons-material/PaymentsOutlined';
|
||||
import ContactPhoneOutlined from '@mui/icons-material/ContactPhoneOutlined';
|
||||
import WorkOutline from '@mui/icons-material/WorkOutline';
|
||||
import WorkOutline from '@mui/icons-material/WorkOutlineOutlined';
|
||||
import ForumOutlined from '@mui/icons-material/ForumOutlined';
|
||||
import ReceiptLongOutlined from '@mui/icons-material/ReceiptLongOutlined';
|
||||
import BusinessOutlined from '@mui/icons-material/BusinessOutlined';
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ function GridPage({ entity, extraDefaults }: { entity: string; extraDefaults?: R
|
|||
<>
|
||||
<PageHeader
|
||||
title={labelOf(entity)}
|
||||
subtitle={total === null ? undefined : `${total.toLocaleString()} ${ui('records')}`}
|
||||
actions={
|
||||
<>
|
||||
{can('GETREPORT') && <ExportButton entity={entity} fields={fields} filter={filter} total={total} />}
|
||||
|
|
@ -187,7 +186,12 @@ function GridPage({ entity, extraDefaults }: { entity: string; extraDefaults?: R
|
|||
/>
|
||||
<SearchPanel entity={entity} fields={fields} filter={filter} onChange={(f) => setParams(filterToParams(f), { replace: true })} />
|
||||
{totalBalance !== undefined && (
|
||||
<Typography fontWeight={800} fontSize={18} sx={{ mb: 1 }}>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
fontSize: 18,
|
||||
mb: 1
|
||||
}}>
|
||||
{t('TOTAL_BALANCE')} : <bdi dir="ltr">{totalBalance.toFixed(3)}</bdi> {t('RO')}
|
||||
</Typography>
|
||||
)}
|
||||
|
|
@ -223,10 +227,19 @@ function NotAuthorized() {
|
|||
const ui = useUi();
|
||||
return (
|
||||
<Box sx={{ display: 'grid', placeItems: 'center', py: 10, textAlign: 'center' }}>
|
||||
<Stack spacing={2} alignItems="center" sx={{ maxWidth: 460 }}>
|
||||
<Stack
|
||||
spacing={2}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
maxWidth: 460
|
||||
}}>
|
||||
<LockOutlined sx={{ fontSize: 56, color: 'text.disabled' }} />
|
||||
<Typography variant="h5" fontWeight={800}>{ui('notAuthorizedTitle')}</Typography>
|
||||
<Typography color="text.secondary">{ui('notAuthorizedText')}</Typography>
|
||||
<Typography variant="h5" sx={{
|
||||
fontWeight: 800
|
||||
}}>{ui('notAuthorizedTitle')}</Typography>
|
||||
<Typography sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('notAuthorizedText')}</Typography>
|
||||
<Button variant="contained" component={RouterLink} to="/">{ui('home')}</Button>
|
||||
</Stack>
|
||||
</Box>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Link as RouterLink } from 'react-router-dom';
|
||||
import { Box, IconButton, Paper, Stack, Tooltip, Typography } from '@mui/material';
|
||||
import AddCircleOutline from '@mui/icons-material/AddCircleOutline';
|
||||
import AddCircleOutline from '@mui/icons-material/AddCircleOutlineOutlined';
|
||||
import { newRecordSx } from '../components/newRecordSx';
|
||||
import { useAuth } from '../auth/AuthContext';
|
||||
import { useNav } from '../layout/NavContext';
|
||||
|
|
@ -17,20 +17,47 @@ export function HomeLauncher() {
|
|||
return (
|
||||
<>
|
||||
<Typography variant="h5" component="h1" sx={{ mb: 0.5 }}>{user?.name}</Typography>
|
||||
<Typography color="text.secondary" sx={{ mb: 3 }}>{roleLabel(String(user?.job_title ?? user?.role_code ?? ''), t, humanize, isRtl(lang))}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
mb: 3
|
||||
}}>{roleLabel(String(user?.job_title ?? user?.role_code ?? ''), t, humanize, isRtl(lang))}</Typography>
|
||||
<Box sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', lg: 'repeat(3, 1fr)' } }}>
|
||||
{sections.map((s) => {
|
||||
const Icon = s.icon;
|
||||
return (
|
||||
<Paper key={s.key} variant="outlined" sx={{ p: 2.5 }}>
|
||||
<Stack direction="row" spacing={1.5} alignItems="center" sx={{ mb: 1.5 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1.5}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
mb: 1.5
|
||||
}}>
|
||||
<Box sx={{ display: 'grid', placeItems: 'center', width: 30, height: 30, borderRadius: 1.5, bgcolor: 'action.hover', color: 'primary.main' }}><Icon sx={{ fontSize: 18 }} /></Box>
|
||||
<Typography component="h2" fontWeight={700}>{title(s)}</Typography>
|
||||
<Typography component="h2" sx={{
|
||||
fontWeight: 700
|
||||
}}>{title(s)}</Typography>
|
||||
</Stack>
|
||||
<Stack spacing={0.25}>
|
||||
{s.items.map((i) => (
|
||||
<Stack key={i.entity} direction="row" alignItems="center" justifyContent="space-between">
|
||||
<Typography component={RouterLink} to={i.to} color="text.secondary" sx={{ textDecoration: 'none', py: 0.4, flex: 1, '&:hover': { color: 'primary.main' } }}>
|
||||
<Stack
|
||||
key={i.entity}
|
||||
direction="row"
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between"
|
||||
}}>
|
||||
<Typography
|
||||
component={RouterLink}
|
||||
to={i.to}
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
textDecoration: 'none',
|
||||
py: 0.4,
|
||||
flex: 1,
|
||||
'&:hover': { color: 'primary.main' }
|
||||
}}>
|
||||
{labelOf(i.entity)}
|
||||
</Typography>
|
||||
{/* the same "+" the menu shows beside a module that can create records */}
|
||||
|
|
|
|||
|
|
@ -91,8 +91,21 @@ function Tiles({ items }: { items: Item[] }) {
|
|||
<Icon fontSize="small" />
|
||||
</Avatar>
|
||||
<Box sx={{ minWidth: 0 }}>
|
||||
<Typography variant="h5" fontWeight={800} sx={{ color, lineHeight: 1.1 }}>{fmt(i.value)}</Typography>
|
||||
<Typography variant="body2" color="text.secondary" noWrap sx={{ unicodeBidi: 'plaintext', textAlign: 'start' }}>{i.label}</Typography>
|
||||
<Typography
|
||||
variant="h5"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
color,
|
||||
lineHeight: 1.1
|
||||
}}>{fmt(i.value)}</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
noWrap
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
unicodeBidi: 'plaintext',
|
||||
textAlign: 'start'
|
||||
}}>{i.label}</Typography>
|
||||
</Box>
|
||||
</Paper>
|
||||
);
|
||||
|
|
@ -120,7 +133,14 @@ function Pie({ items }: { items: Item[] }) {
|
|||
: theme.palette.action.hover;
|
||||
|
||||
return (
|
||||
<Stack direction="row" spacing={3} alignItems="center" flexWrap="wrap" useFlexGap>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={3}
|
||||
useFlexGap
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
flexWrap: "wrap"
|
||||
}}>
|
||||
<Box sx={{ position: 'relative', width: 150, height: 150, flexShrink: 0 }}>
|
||||
<Box sx={{ width: '100%', height: '100%', borderRadius: '50%', background: gradient }} />
|
||||
<Box
|
||||
|
|
@ -130,18 +150,35 @@ function Pie({ items }: { items: Item[] }) {
|
|||
}}
|
||||
>
|
||||
<Box sx={{ textAlign: 'center' }}>
|
||||
<Typography variant="h6" fontWeight={800} lineHeight={1.1}>{fmt(items.reduce((a, i) => a + i.value, 0))}</Typography>
|
||||
<Typography variant="caption" color="text.secondary">{ui('total')}</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
lineHeight: 1.1
|
||||
}}>{fmt(items.reduce((a, i) => a + i.value, 0))}</Typography>
|
||||
<Typography variant="caption" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('total')}</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
<Stack spacing={0.75} sx={{ flex: 1, minWidth: 160 }}>
|
||||
{stops.map((s) => (
|
||||
<Stack key={s.label} direction="row" alignItems="center" spacing={1}>
|
||||
<Stack key={s.label} direction="row" spacing={1} sx={{
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<Box sx={{ width: 10, height: 10, borderRadius: '50%', bgcolor: s.color, flexShrink: 0 }} />
|
||||
<Typography variant="body2" sx={{ flex: 1, unicodeBidi: 'plaintext', textAlign: 'start' }} noWrap title={s.label}>{s.label}</Typography>
|
||||
<Typography variant="body2" fontWeight={700}>{fmt(s.value)}</Typography>
|
||||
<Typography variant="caption" color="text.secondary" sx={{ width: 40, textAlign: 'end' }}>
|
||||
<Typography variant="body2" sx={{
|
||||
fontWeight: 700
|
||||
}}>{fmt(s.value)}</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
width: 40,
|
||||
textAlign: 'end'
|
||||
}}>
|
||||
{Math.round((s.value / total) * 100)}%
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
|
@ -157,9 +194,16 @@ function Bars({ items }: { items: Item[] }) {
|
|||
<Stack spacing={1}>
|
||||
{items.map((i) => (
|
||||
<Box key={i.label}>
|
||||
<Stack direction="row" justifyContent="space-between" sx={{ mb: 0.25 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
justifyContent: "space-between",
|
||||
mb: 0.25
|
||||
}}>
|
||||
<Typography variant="body2">{i.label}</Typography>
|
||||
<Typography variant="body2" fontWeight={700}>{fmt(i.value)}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
fontWeight: 700
|
||||
}}>{fmt(i.value)}</Typography>
|
||||
</Stack>
|
||||
<Box sx={{ height: 8, borderRadius: 4, bgcolor: 'action.hover', overflow: 'hidden' }}>
|
||||
<Box sx={{ width: `${(i.value / max) * 100}%`, height: '100%', bgcolor: 'primary.main', borderRadius: 4, minWidth: i.value ? 3 : 0 }} />
|
||||
|
|
@ -188,19 +232,32 @@ function Stacked({ items }: { items: Item[] }) {
|
|||
const max = Math.max(1, ...items.map((i) => i.value));
|
||||
return (
|
||||
<Stack spacing={1.25}>
|
||||
<Stack direction="row" spacing={1.5} useFlexGap flexWrap="wrap">
|
||||
<Stack direction="row" spacing={1.5} useFlexGap sx={{
|
||||
flexWrap: "wrap"
|
||||
}}>
|
||||
{keys.map((k) => (
|
||||
<Stack key={k} direction="row" spacing={0.5} alignItems="center">
|
||||
<Stack key={k} direction="row" spacing={0.5} sx={{
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<Box sx={{ width: 10, height: 10, borderRadius: 0.5, bgcolor: col(k) }} />
|
||||
<Typography variant="caption" color="text.secondary">{labels.get(k)}</Typography>
|
||||
<Typography variant="caption" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{labels.get(k)}</Typography>
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
{items.map((i) => (
|
||||
<Box key={i.label}>
|
||||
<Stack direction="row" justifyContent="space-between" sx={{ mb: 0.25 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
justifyContent: "space-between",
|
||||
mb: 0.25
|
||||
}}>
|
||||
<Typography variant="body2">{i.label}</Typography>
|
||||
<Typography variant="body2" fontWeight={700}>{fmt(i.value)}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
fontWeight: 700
|
||||
}}>{fmt(i.value)}</Typography>
|
||||
</Stack>
|
||||
<Box sx={{ display: 'flex', height: 10, width: `${Math.max(4, (i.value / max) * 100)}%`, borderRadius: 5, overflow: 'hidden', bgcolor: 'action.hover' }}>
|
||||
{i.segments?.filter((s) => s.value > 0).map((s) => (
|
||||
|
|
@ -223,13 +280,24 @@ function BlockCard({ block }: { block: Block }) {
|
|||
const tint = blockIcon(block.key);
|
||||
return (
|
||||
<Paper variant="outlined" sx={{ p: 2, height: '100%' }}>
|
||||
<Stack direction="row" alignItems="center" spacing={1} sx={{ mb: 1.5 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
mb: 1.5
|
||||
}}>
|
||||
{tint && (
|
||||
<Avatar sx={{ bgcolor: alpha(tint.color, 0.15), color: tint.color, width: 28, height: 28 }}>
|
||||
<tint.icon sx={{ fontSize: 16 }} />
|
||||
</Avatar>
|
||||
)}
|
||||
<Typography component="h2" fontWeight={700} fontSize={14.5}>{block.title}</Typography>
|
||||
<Typography
|
||||
component="h2"
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
fontSize: 14.5
|
||||
}}>{block.title}</Typography>
|
||||
</Stack>
|
||||
{body}
|
||||
</Paper>
|
||||
|
|
@ -287,7 +355,14 @@ export function DashboardPage() {
|
|||
<>
|
||||
<PageHeader title={title} />
|
||||
{page.locations && estates.length > 0 && (
|
||||
<Stack direction="row" spacing={0.75} useFlexGap flexWrap="wrap" sx={{ mb: 2 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.75}
|
||||
useFlexGap
|
||||
sx={{
|
||||
flexWrap: "wrap",
|
||||
mb: 2
|
||||
}}>
|
||||
<Chip label={lab('ALL_LOCATIONS')} color={loc === 0 ? 'primary' : 'default'} variant={loc === 0 ? 'filled' : 'outlined'} disabled={lockedTo !== null} onClick={() => setLocation(0)} />
|
||||
{estates.map((e) => (
|
||||
<Chip key={String(e.CODE)} label={lab(e.CAPTION_CODE ?? String(e.CODE))} color={Number(e.CODE) === loc ? 'primary' : 'default'} variant={Number(e.CODE) === loc ? 'filled' : 'outlined'} disabled={lockedTo !== null && Number(e.CODE) !== lockedTo} onClick={() => setLocation(Number(e.CODE))} />
|
||||
|
|
@ -295,7 +370,14 @@ export function DashboardPage() {
|
|||
</Stack>
|
||||
)}
|
||||
{model.nats.length > 0 && (
|
||||
<Stack direction="row" spacing={0.75} useFlexGap flexWrap="wrap" sx={{ mb: 2 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.75}
|
||||
useFlexGap
|
||||
sx={{
|
||||
flexWrap: "wrap",
|
||||
mb: 2
|
||||
}}>
|
||||
{model.nats.map((n) => (
|
||||
<Chip key={n} label={n === 'ALL' ? ui('all') : lab(n)} color={n === nat ? 'primary' : 'default'} variant={n === nat ? 'filled' : 'outlined'} onClick={() => setNat(n)} />
|
||||
))}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import GroupsOutlined from '@mui/icons-material/GroupsOutlined';
|
|||
import PeopleAltOutlined from '@mui/icons-material/PeopleAltOutlined';
|
||||
import WarehouseOutlined from '@mui/icons-material/WarehouseOutlined';
|
||||
import StoreOutlined from '@mui/icons-material/StoreOutlined';
|
||||
import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
|
||||
import CheckCircleOutline from '@mui/icons-material/CheckCircleOutlineOutlined';
|
||||
import ScheduleOutlined from '@mui/icons-material/ScheduleOutlined';
|
||||
import ErrorOutlineOutlined from '@mui/icons-material/ErrorOutlineOutlined';
|
||||
import UndoOutlined from '@mui/icons-material/UndoOutlined';
|
||||
|
|
@ -20,7 +20,7 @@ import AutorenewOutlined from '@mui/icons-material/AutorenewOutlined';
|
|||
import PublicOutlined from '@mui/icons-material/PublicOutlined';
|
||||
import MapOutlined from '@mui/icons-material/MapOutlined';
|
||||
import SchoolOutlined from '@mui/icons-material/SchoolOutlined';
|
||||
import WorkOutline from '@mui/icons-material/WorkOutline';
|
||||
import WorkOutline from '@mui/icons-material/WorkOutlineOutlined';
|
||||
import DashboardOutlined from '@mui/icons-material/DashboardOutlined';
|
||||
import CategoryOutlined from '@mui/icons-material/CategoryOutlined';
|
||||
|
||||
|
|
|
|||
|
|
@ -70,13 +70,24 @@ export function AttachmentField(props: {
|
|||
bgcolor: over ? 'action.selected' : 'action.hover',
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" fontWeight={600} sx={{ mb: 1 }}>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
fontWeight: 600,
|
||||
mb: 1
|
||||
}}>
|
||||
{label}
|
||||
{required ? ' *' : ''}
|
||||
</Typography>
|
||||
|
||||
{shown && (
|
||||
<Stack direction="row" spacing={1} alignItems="center" sx={{ mb: 1 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
mb: 1
|
||||
}}>
|
||||
{isImage(shown) && !broken ? (
|
||||
<Link href={attachmentUrl(baseUrl, shown)} target="_blank" rel="noopener noreferrer">
|
||||
<Box
|
||||
|
|
@ -101,7 +112,13 @@ export function AttachmentField(props: {
|
|||
)}
|
||||
|
||||
{pending && (
|
||||
<Stack direction="row" spacing={1} alignItems="center" sx={{ mb: 1 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
mb: 1
|
||||
}}>
|
||||
<Typography variant="body2" noWrap sx={{ flex: 1 }}>{pending.name}</Typography>
|
||||
<IconButton size="small" color="error" onClick={() => onPending(undefined)} aria-label={t('DELETE')}>
|
||||
<DeleteIcon fontSize="small" />
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { getExtraFields, getView, runAction, type ExtraSpec, type Option } from
|
|||
import { fetchRecaptchaSiteKey } from '../../api/session';
|
||||
import { useRecaptcha } from '../../auth/recaptcha';
|
||||
import { fromInputDate, resolveFields, toDisplayDate, toInputDate, toPayload, type Mode, type ResolvedField } from './fields';
|
||||
import { CREATE_HIDDEN, EDIT_HIDDEN_SECTIONS, FLEET_ENTITIES, HIDDEN_CREATE_TITLES, NON_OMANI_ONLY, getLayout, type DynamicLookup } from './layouts';
|
||||
import { CONFIRM_ENTITIES, CREATE_HIDDEN, EDIT_HIDDEN_FIELDS, aliasSource, EDIT_HIDDEN_SECTIONS, FLEET_ENTITIES, HIDDEN_CREATE_TITLES, NON_OMANI_ONLY, getLayout, type DynamicLookup } from './layouts';
|
||||
import { AttachmentField } from './AttachmentField';
|
||||
import { DateField } from '../../components/DateField';
|
||||
import { ExtraFieldsDialog } from './ExtraFieldsDialog';
|
||||
|
|
@ -141,15 +141,17 @@ function FieldInput(props: {
|
|||
error={!!error}
|
||||
helperText={error ?? (unavailable ? ui('notAvailableYet') : undefined)}
|
||||
slotProps={{
|
||||
...p.slotProps,
|
||||
|
||||
input: {
|
||||
...p.InputProps,
|
||||
...p.slotProps.input,
|
||||
endAdornment: (
|
||||
<>
|
||||
{dyn.isFetching && <CircularProgress size={16} />}
|
||||
{p.InputProps.endAdornment}
|
||||
{p.slotProps.input.endAdornment}
|
||||
</>
|
||||
),
|
||||
},
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -239,9 +241,9 @@ export function EntityForm({
|
|||
useEffect(() => {
|
||||
if (!view.data) return;
|
||||
const d = view.data.data;
|
||||
const aliased = Object.fromEntries(Object.entries(layout?.alias ?? {}).map(([f, src]) => [f, d[src]]));
|
||||
const aliased = Object.fromEntries(Object.entries(layout?.alias ?? {}).map(([f, src]) => [f, d[aliasSource(src, lang)]]));
|
||||
setValues({ ...d, ...aliased });
|
||||
}, [view.data, layout]);
|
||||
}, [view.data, layout, lang]);
|
||||
|
||||
const status = view.data ? String(view.data.data.STATUS_CODE ?? '').trim() : undefined;
|
||||
const fieldNames = useMemo(() => layout?.sections.flatMap((s) => s.fields) ?? [], [layout]);
|
||||
|
|
@ -297,9 +299,14 @@ export function EntityForm({
|
|||
plateHidden(name) ||
|
||||
(ownerToggle && (name === 'IS_OWNER' || (isOwner && OWNER_DOC.includes(name)))) ||
|
||||
(mode === 'CREATE' && !!CREATE_HIDDEN[entity]?.includes(name)) ||
|
||||
(mode === 'EDIT' && !!EDIT_HIDDEN_FIELDS[entity]?.includes(name)) ||
|
||||
(mode === 'EDIT' && !!layout?.sections.some((s) => EDIT_HIDDEN_SECTIONS[entity]?.includes(s.title) && s.fields.includes(name))) ||
|
||||
(!!nonOmaniOnly?.fields.includes(name) && !isNonOmani) ||
|
||||
(entity === 'OWNERS' && name === 'OWNER_RIYADAH_CARD_HOLDER_DOC' && !riyadaRole);
|
||||
(entity === 'OWNERS' && name === 'OWNER_RIYADAH_CARD_HOLDER_DOC' && !riyadaRole) ||
|
||||
// legacy asks for the POS receipt number only for the POS transaction type (6)
|
||||
(entity === 'DEPOSITS' && name === 'RECEIPT_ID' && String(values.TRANSACTION_TYPE ?? '').trim() !== '6') ||
|
||||
// stakeholder users deposit for themselves: the stakeholder picker is not shown to them
|
||||
(entity === 'DEPOSITS' && mode === 'CREATE' && user?.role_group === 'STAKEHOLDER' && ['STAKEHOLDER_ENTITY_NUMBER', 'STAKEHOLDER_ENTITY_RECORD_NAME', 'STAKEHOLDER_ENTITY_ID'].includes(name));
|
||||
// fields that become mandatory because of what was chosen
|
||||
const conditionallyRequired = (name: string) =>
|
||||
(!!nonOmaniOnly?.fields.includes(name) && isNonOmani && !(nonOmaniOnly.notRequiredWith && String(values[nonOmaniOnly.notRequiredWith] ?? '').trim() && name !== nonOmaniOnly.attachment)) ||
|
||||
|
|
@ -361,8 +368,16 @@ export function EntityForm({
|
|||
setErrors((e) => ({ ...e, [name]: '' }));
|
||||
};
|
||||
|
||||
// legacy: non-Nafith users confirm the data is correct before saving (role 45 is ticked for them and not shown)
|
||||
const confirmBox = !publicMode && !profile && CONFIRM_ENTITIES.includes(entity) && !!user && user.role_group !== 'NAFITH' && String(user.role_id ?? '') !== '45';
|
||||
const [confirmed, setConfirmed] = useState(false);
|
||||
|
||||
const validate = () => {
|
||||
const errs: Record<string, string> = {};
|
||||
if (confirmBox && !confirmed) {
|
||||
notify.error(new ApiError('MUST_CONFIRM'));
|
||||
return false;
|
||||
}
|
||||
for (const f of fields) {
|
||||
if (f.type === 'ATTACHMENT') {
|
||||
if ((f.required || conditionallyRequired(f.name)) && !f.hidden && !f.readOnly && !formHidden(f.name) && !pending[f.name] && !storedFor(f.name)) errs[f.name] = t('MUST_ATTACH_FILE');
|
||||
|
|
@ -559,6 +574,10 @@ export function EntityForm({
|
|||
|
||||
{blocked && <Alert severity="warning">{ui('blockedForm')}</Alert>}
|
||||
|
||||
{confirmBox && (
|
||||
<FormControlLabel control={<Checkbox checked={confirmed} onChange={(e) => setConfirmed(e.target.checked)} />} label={t('AGREE_NOTE')} />
|
||||
)}
|
||||
|
||||
{publicMode && (
|
||||
<Paper variant="outlined" sx={{ p: 2, ...sectionFrame }}>
|
||||
<Box ref={captcha.ref} sx={{ mb: 1.5 }} />
|
||||
|
|
|
|||
|
|
@ -214,7 +214,10 @@
|
|||
"CHASSES_NUMBER",
|
||||
"PASSENGER_NUMBER",
|
||||
"AXES_NUMBER",
|
||||
"ENGINE_NUMBER"
|
||||
"ENGINE_NUMBER",
|
||||
"CREATED_BY_NAME",
|
||||
"UPDATED_BY_NAME",
|
||||
"LAST_UPDATE_DATE_GRID"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -343,7 +346,6 @@
|
|||
"STAKEHOLDER_ENTITY_NUMBER",
|
||||
"STAKEHOLDER_ENTITY_RECORD_NAME",
|
||||
"STAKEHOLDER_ENTITY_ID",
|
||||
"NOTES",
|
||||
"DEPOSIT_REQUEST_NUMBER",
|
||||
"VOUCHER_NUMBER",
|
||||
"TRANSACTION_TYPE",
|
||||
|
|
@ -351,7 +353,8 @@
|
|||
"DEPOSIT_AMOUNT",
|
||||
"DEPOSIT_DATE",
|
||||
"REFERENCE_NUMBER",
|
||||
"RECEIPT_ID"
|
||||
"RECEIPT_ID",
|
||||
"NOTES"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -417,7 +420,10 @@
|
|||
"USE_DESCRIPTION",
|
||||
"MODEL_YEAR",
|
||||
"EXTREME_CAPACITY",
|
||||
"AXES_NUMBER"
|
||||
"AXES_NUMBER",
|
||||
"CREATED_BY_NAME",
|
||||
"UPDATED_BY_NAME",
|
||||
"LAST_UPDATE_DATE_GRID"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -502,7 +508,6 @@
|
|||
"RECEIVER_RELATED_ENTITY_ID",
|
||||
"LOCATION_IDS",
|
||||
"RECEIVER_RELATED_ENTITY_RECORD_ID",
|
||||
"NOTES",
|
||||
"DRIVER_NATIONALITY_CODE",
|
||||
"OMANI_DRIVER_GRID",
|
||||
"DRIVER_NAME",
|
||||
|
|
@ -519,7 +524,8 @@
|
|||
"NUMBER_OF_FLEET",
|
||||
"TRAILER_PLATE_NUMBER",
|
||||
"TRAILER_PLATE_CODE",
|
||||
"TRAILER_PLATE_CODE_AR"
|
||||
"TRAILER_PLATE_CODE_AR",
|
||||
"NOTES"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -1336,7 +1342,10 @@
|
|||
"PASSENGER_NUMBER",
|
||||
"AXES_NUMBER",
|
||||
"CHASSES_NUMBER",
|
||||
"ENGINE_NUMBER"
|
||||
"ENGINE_NUMBER",
|
||||
"CREATED_BY_NAME",
|
||||
"UPDATED_BY_NAME",
|
||||
"LAST_UPDATE_DATE_GRID"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ export const layouts: Record<string, EntityLayout> = {
|
|||
// License info leads, with the document nationality first in it: that picks whether FLEET_PLATE_CODE (Omani,
|
||||
// dropdown) or PLATE_CODE_AR (other nationalities, free text) is the active plate-code field — see EntityForm's plate toggle.
|
||||
// "Truck Info" and "Vehicle" are merged into one group, as requested.
|
||||
{ title: 'LICENSEINFO', fields: ['LICENCE_NATIONALITY', 'LICENSE_EXPIRY_FROM', 'LICENSE_EXPIRY_TO', 'FIRST_REGISTRATION_DATE', 'LICENSE_AUTHORITY', 'OPERATING_CARD_NO', 'CARD_EXPIRY_DATE'] },
|
||||
{ title: 'TRUCKS_INFO', fields: ['PLATE_NUMBER', 'FLEET_PLATE_CODE', 'PLATE_CODE_AR', 'PLATE_TYPE_CODE', 'TRUCK_TYPE', 'USE_DESCRIPTION', 'STATUS_CODE', 'VEHICLE_TYPE', 'COLOR_CODE', 'SUBCOLOR', 'ORIGIN_COUNTRY_CODE', 'MODEL_YEAR', 'MANUFACTURING_YEAR', 'ENGINE_CAPACITY', 'EMPTY_WEIGHT', 'EXTREME_CAPACITY', 'PASSENGER_NUMBER', 'AXES_NUMBER', 'CHASSES_NUMBER', 'ENGINE_NUMBER'] },
|
||||
{ title: 'LICENSEINFO', fields: ['LICENCE_NATIONALITY', 'LICENSE_EXPIRY_FROM', 'LICENSE_EXPIRY_TO', 'OPERATING_CARD_NO', 'CARD_EXPIRY_DATE', 'NOTES'] },
|
||||
{ title: 'TRUCKS_INFO', fields: ['PLATE_NUMBER', 'FLEET_PLATE_CODE', 'PLATE_CODE_AR', 'PLATE_TYPE_CODE', 'TRUCK_TYPE', 'USE_DESCRIPTION', 'STATUS_CODE', 'VEHICLE_TYPE', 'COLOR_CODE', 'SUBCOLOR', 'ORIGIN_COUNTRY_CODE', 'MODEL_YEAR', 'MANUFACTURING_YEAR', 'ENGINE_CAPACITY', 'EMPTY_WEIGHT', 'EXTREME_CAPACITY', 'PASSENGER_NUMBER', 'AXES_NUMBER', 'CHASSES_NUMBER', 'ENGINE_NUMBER', 'CREATED_BY_NAME', 'UPDATED_BY_NAME', 'LAST_UPDATE_DATE_GRID'] },
|
||||
{ title: 'OWNERINFO', fields: ['RELATED_ENTITY_ID', 'RELATED_ENTITY_RECORD_ID', 'LOCATION_IDS', 'OWNER_NAME', 'PERSONAL_DOCUMENT_TYPE', 'PERSONAL_DOC_NUMBER', 'NATIONALITY_LICENCE'] },
|
||||
{ title: 'INSURANCEINFO', fields: ['INSURANCE_DOCUMENT_NUMBER', 'INSURANCE_TYPE', 'INSURANCE_COMPANY'] },
|
||||
{ title: 'ADDRESS', fields: ['GOVERNORATE_CODE', 'STATE_CODE', 'CITY_CODE', 'ADDRESS', 'NATIONALITY_CODE', 'NOTES'] },
|
||||
{ title: 'INSURANCEINFO', fields: ['INSURANCE_DOCUMENT_NUMBER', 'INSURANCE_TYPE', 'INSURANCE_COMPANY', 'LICENSE_AUTHORITY', 'FIRST_REGISTRATION_DATE'] },
|
||||
{ title: 'ADDRESS', fields: ['GOVERNORATE_CODE', 'STATE_CODE', 'CITY_CODE', 'ADDRESS', 'NATIONALITY_CODE'] },
|
||||
{ title: 'ATTACHMENTS', fields: ['TRUCK_LICENSE_FRONT', 'TRUCK_LICENSE_BACK', 'OWNER_LICENSE_FRONT', 'OWNER_LICENSE_BACK', 'AUTHORIZATION', 'CARD_EXPIRY_FRONT', 'CARD_EXPIRY_BACK'] },
|
||||
],
|
||||
alias: { FLEET_PLATE_CODE: 'PLATE_CODE_EN' },
|
||||
|
|
@ -89,11 +89,35 @@ export const CREATE_HIDDEN: Record<string, string[]> = {
|
|||
COMPLAINTS_SUGGESTIONS: ['REPLY'],
|
||||
// a new ticket: no reply box, and none of the sender details or the support-side attachments (the system fills the
|
||||
// sender in; the old page showed those two groups only to the Nafith side)
|
||||
// a new entry permit request is the "stakeholder" shape: the driver and vehicle-plate fields and the driver / truck
|
||||
// licence attachments belong to the mobile-app shape and the legacy create page hides them
|
||||
FLEET_REQUEST: [
|
||||
'OMANI_DRIVER_GRID', 'DRIVER_NAME', 'DRIVER_MOBILE_NUMBER', 'DRIVER_AREA_CODE', 'DRIVER_CN', 'LOCAL_VEHICLE_GRID', 'TRAILER_TYPE',
|
||||
'PLATE_NUMBER', 'FLEET_PLATE_CODE', 'PLATE_CODE_AR', 'TRAILER_PLATE_NUMBER', 'TRAILER_PLATE_CODE', 'TRAILER_PLATE_CODE_AR',
|
||||
'DRIVER_ID_FRONT', 'DRIVER_ID_BACK', 'TRUCK_LICENSE_FRONT', 'TRUCK_LICENSE_BACK',
|
||||
],
|
||||
// a new user: no status yet, and the industrial area and language are not asked on the create page
|
||||
USERS: ['STATUS_CODE', 'LOCATION_IDS', 'LANGUAGE'],
|
||||
TICKETS: ['REPLY', 'TICKET_NUMBER', 'ENTITY_NAME', 'USER_TYPE', 'STAKEHOLDER_NAME', 'MOBILE_NUMBER', 'AREA_CODE', 'LOCATION_IDS', 'OPOFF_ATT_NO_1', 'OPOFF_ATT_NO_2', 'OPOFF_ATT_NO_3'],
|
||||
};
|
||||
|
||||
/** Legacy pages that carry the "I confirm the data is correct" tick box for every user outside Nafith. */
|
||||
export const CONFIRM_ENTITIES = [
|
||||
'DEPOSITS', 'BUSES', 'CARS', 'COMPANIES', 'EQUIPMENTS', 'FAMILY_MEMBERS', 'FREEZONE_CLEARING_COMPANIES', 'FREEZONE_DEPOSITORS', 'INVESTORS',
|
||||
'INVOICES', 'MFZ_PERMITS', 'NOTIFICATION_LOG', 'OTHER_STAKEHOLDERS', 'OWNERS', 'PARKING_YARD', 'PERMITS', 'PERSONNEL', 'RENTED_TRUCK',
|
||||
'RFID_TAGS', 'TRAILERS', 'TRUCKS', 'VIOLATIONS', 'VISITORS_PERMITS', 'AVAILABLE_ON_PLATFORM', 'AVAILABLE_ON_PLATFORM_SEARCH',
|
||||
];
|
||||
|
||||
/** Groups left out of the edit form (the record keeps its values; nothing in them is asked again). */
|
||||
export const EDIT_HIDDEN_SECTIONS: Record<string, string[]> = { COMPANIES: ['COMPANIES_INFO'] };
|
||||
export const EDIT_HIDDEN_SECTIONS: Record<string, string[]> = {
|
||||
COMPANIES: ['COMPANIES_INFO'],
|
||||
OWNERS: ['OWNERS_INFO'],
|
||||
// employees: the driver-licence group and the backend-required "Employee info" extras are not shown
|
||||
PERSONNEL: ['LICENSEINFO', 'PERSONNEL_INFO'],
|
||||
};
|
||||
|
||||
/** Single fields left out of the edit form (and the record page, see VIEW_HIDDEN_FIELDS). */
|
||||
export const EDIT_HIDDEN_FIELDS: Record<string, string[]> = { USERS: ['LOCATION_IDS'] };
|
||||
|
||||
/** Whole groups the legacy record page does not show (driver info; investor capacity and investor info). */
|
||||
export const VIEW_HIDDEN_SECTIONS: Record<string, string[]> = {
|
||||
|
|
@ -102,6 +126,7 @@ export const VIEW_HIDDEN_SECTIONS: Record<string, string[]> = {
|
|||
OTHER_STAKEHOLDERS: ['OTHER_STAKEHOLDERS_INFO'],
|
||||
FREEZONE_DEPOSITORS: ['FREEZONE_DEPOSITORS_INFO'],
|
||||
COMPANIES: ['COMPANIES_INFO'],
|
||||
PERSONNEL: ['LICENSEINFO', 'PERSONNEL_INFO'],
|
||||
// the reply box is a popup here; the answers are listed in their own table
|
||||
TICKETS: ['ADD_REPLY'],
|
||||
};
|
||||
|
|
@ -115,6 +140,13 @@ export const NON_OMANI_ONLY: Record<string, { nationality: string; fields: strin
|
|||
/** Sections whose heading is left out of the create form (the fields stay). */
|
||||
export const HIDDEN_CREATE_TITLES: Record<string, string> = { BLACKLISTS: 'BLACKLISTSINFO' };
|
||||
|
||||
/**
|
||||
* The value a form field takes from the record when the backend names it differently (see `alias`). The backend returns
|
||||
* language pairs (PLATE_CODE_EN / PLATE_CODE_AR) and the option lists carry the code in the session language, so the
|
||||
* pair member of the session language is the one that matches an option.
|
||||
*/
|
||||
export const aliasSource = (src: string, lang: string) => (lang.toUpperCase() === 'AR' && src.endsWith('_EN') ? `${src.slice(0, -3)}_AR` : src);
|
||||
|
||||
export const hasLayout =(entity: string) => entity in layouts;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
|
@ -133,7 +165,10 @@ const ENTITY_ALIAS: Record<string, Record<string, string>> = { POS_TRANSACTIONS:
|
|||
const SECTION_AFTER: Record<string, [string, string]> = { PERMITS: ['TRUCKS_INFO', 'PERMITS_INFO'] };
|
||||
|
||||
/** Fields the record page does not show, and fields it puts last in their group. */
|
||||
export const VIEW_HIDDEN_FIELDS: Record<string, string[]> = { DEPOSITS: ['RECEIPT_ID'] };
|
||||
export const VIEW_HIDDEN_FIELDS: Record<string, string[]> = {
|
||||
DEPOSITS: ['RECEIPT_ID'],
|
||||
USERS: ['LOCATION_IDS'],
|
||||
};
|
||||
export const VIEW_LAST_FIELDS: Record<string, string[]> = { DEPOSITS: ['NOTES'] };
|
||||
|
||||
/** Heading of the group that holds an entity's extra backend-required fields, when "<ENTITY>_INFO" would read wrongly. */
|
||||
|
|
|
|||
|
|
@ -110,7 +110,11 @@ export function PendingPayDialog({ id, data, onClose, onDone }: { id: string; da
|
|||
<Dialog open onClose={() => !pay.isPending && onClose()} maxWidth="md">
|
||||
<DialogTitle>{t('PAY_OFF_DEBIT_BALANCE')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography fontWeight={700} sx={{ mb: 1 }}>{t('ORDER_SUMMARY')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 1
|
||||
}}>{t('ORDER_SUMMARY')}</Typography>
|
||||
{nafith && (
|
||||
<FormControlLabel
|
||||
control={<Checkbox checked={withNafith} onChange={(e) => { setWithNafith(e.target.checked); setMethod(''); }} />}
|
||||
|
|
@ -127,12 +131,22 @@ export function PendingPayDialog({ id, data, onClose, onDone }: { id: string; da
|
|||
<Box sx={{ '& .card': { border: 1, borderColor: 'divider', borderRadius: 1.5, p: 1.5 }, '& h4': { fontSize: 15, m: 0, mb: 1 }, '& h1': { fontSize: 20, m: 0 }, '& p': { m: 0, mb: 0.5 }, '& i': { display: 'none' } }}
|
||||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(s.SUBSCRIPTIONDETAILSCARD ?? '') }} />
|
||||
<Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1.5, p: 1.5 }}>
|
||||
<Typography fontWeight={700} sx={{ mb: 0.5 }}>{t('PAYMENT_METHOD')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 0.5
|
||||
}}>{t('PAYMENT_METHOD')}</Typography>
|
||||
<RadioGroup value={method} onChange={(e) => setMethod(e.target.value)}>
|
||||
{methods.map((m) => (
|
||||
<Box key={m.ID}>
|
||||
<FormControlLabel value={String(m.ID)} disabled={m.ID === CARD_PAYMENT} control={<Radio size="small" />} label={m.NAME} />
|
||||
{m.ID === CARD_PAYMENT && <Typography variant="caption" color="text.secondary" sx={{ marginInlineStart: 4, display: 'block' }}>{ui('wizCardLater')}</Typography>}
|
||||
{m.ID === CARD_PAYMENT && <Typography
|
||||
variant="caption"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
marginInlineStart: 4,
|
||||
display: 'block'
|
||||
}}>{ui('wizCardLater')}</Typography>}
|
||||
{m.ID === POS_PAYMENT && method === String(POS_PAYMENT) && (
|
||||
<TextField size="small" label={t('RECEIPT_NUMBER')} value={receipt} onChange={(e) => setReceipt(e.target.value)} slotProps={{ htmlInput: { maxLength: 12 } }} sx={{ marginInlineStart: 4, mb: 1 }} />
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,9 @@ export function ReconciliationUpload({ entity, onClose, onDone }: { entity: 'REC
|
|||
sx={{ border: 2, borderStyle: 'dashed', borderColor: touched && !file ? 'error.main' : 'divider', borderRadius: 2, p: 3, textAlign: 'center', cursor: 'pointer' }}
|
||||
>
|
||||
<UploadFileIcon color="primary" />
|
||||
<Typography fontSize={14}>{file ? file.name : t('MUST_UPLOAD_FILE')}</Typography>
|
||||
<Typography sx={{
|
||||
fontSize: 14
|
||||
}}>{file ? file.name : t('MUST_UPLOAD_FILE')}</Typography>
|
||||
</Box>
|
||||
{fileError && <Alert severity="error">{fileError}</Alert>}
|
||||
{upload.error && <Alert severity="error">{failText(upload.error as Error)}</Alert>}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,11 @@ export function RenewSubscriptionDialog({ params, onClose, onDone }: { params: R
|
|||
<Dialog open onClose={() => !renew.isPending && onClose()} maxWidth="md">
|
||||
<DialogTitle>{t('RENEW_SUBSCRIPTION')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography fontWeight={700} sx={{ mb: 1 }}>{t('ORDER_SUMMARY')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 1
|
||||
}}>{t('ORDER_SUMMARY')}</Typography>
|
||||
{summary.isPending && <Box sx={{ display: 'grid', placeItems: 'center', py: 4 }}><CircularProgress size={28} /></Box>}
|
||||
{summary.error && <Alert severity="warning">{t((summary.error as Error).message)}</Alert>}
|
||||
{s && (
|
||||
|
|
@ -116,12 +120,22 @@ export function RenewSubscriptionDialog({ params, onClose, onDone }: { params: R
|
|||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(s.SUBSCRIPTIONDETAILSCARD ?? '') }}
|
||||
/>
|
||||
<Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1.5, p: 1.5 }}>
|
||||
<Typography fontWeight={700} sx={{ mb: 0.5 }}>{t('PAYMENT_METHOD')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 0.5
|
||||
}}>{t('PAYMENT_METHOD')}</Typography>
|
||||
<RadioGroup value={method} onChange={(e) => setMethod(e.target.value)}>
|
||||
{methods.map((m) => (
|
||||
<Box key={m.ID}>
|
||||
<FormControlLabel value={String(m.ID)} disabled={m.ID === CARD_PAYMENT} control={<Radio size="small" />} label={m.NAME} />
|
||||
{m.ID === CARD_PAYMENT && <Typography variant="caption" color="text.secondary" sx={{ marginInlineStart: 4, display: 'block' }}>{ui('wizCardLater')}</Typography>}
|
||||
{m.ID === CARD_PAYMENT && <Typography
|
||||
variant="caption"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
marginInlineStart: 4,
|
||||
display: 'block'
|
||||
}}>{ui('wizCardLater')}</Typography>}
|
||||
{m.ID === POS_PAYMENT && method === String(POS_PAYMENT) && (
|
||||
<TextField size="small" label={t('RECEIPT_NUMBER')} value={receipt} onChange={(e) => setReceipt(e.target.value)} slotProps={{ htmlInput: { maxLength: 12 } }} sx={{ marginInlineStart: 4, mb: 1 }} />
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -45,21 +45,31 @@ export function WithdrawDialog({ id, onClose, onDone }: { id: string; onClose: (
|
|||
<Stack spacing={1.5} sx={{ pt: 0.5 }}>
|
||||
{balance.error && <Alert severity="error">{t((balance.error as Error).message)}</Alert>}
|
||||
<div>
|
||||
<Typography variant="caption" color="text.secondary">{lab('RELATED_ENTITY_RECORD_ID')}</Typography>
|
||||
<Typography fontWeight={700}>{balance.data?.NAME ?? '…'}</Typography>
|
||||
<Typography variant="caption" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{lab('RELATED_ENTITY_RECORD_ID')}</Typography>
|
||||
<Typography sx={{
|
||||
fontWeight: 700
|
||||
}}>{balance.data?.NAME ?? '…'}</Typography>
|
||||
</div>
|
||||
<div>
|
||||
<Typography variant="caption" color="text.secondary">{lab('AVAILABLE_BALANCE')}</Typography>
|
||||
<Typography fontWeight={700}>{balance.data ? `${available.toFixed(3)} ${t('RO')}` : '…'}</Typography>
|
||||
<Typography variant="caption" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{lab('AVAILABLE_BALANCE')}</Typography>
|
||||
<Typography sx={{
|
||||
fontWeight: 700
|
||||
}}>{balance.data ? `${available.toFixed(3)} ${t('RO')}` : '…'}</Typography>
|
||||
</div>
|
||||
<TextField
|
||||
label={lab('WITHDRAWAL_AMOUNT')}
|
||||
value={amount}
|
||||
onChange={(e) => setAmount(e.target.value)}
|
||||
inputProps={{ inputMode: 'decimal' }}
|
||||
error={touched && !(Number(amount) > 0 && Number(amount) <= available)}
|
||||
helperText={touched && !(Number(amount) > 0 && Number(amount) <= available) ? t('CANT_WITHDRAW_BALANCE') : ' '}
|
||||
fullWidth
|
||||
slotProps={{
|
||||
htmlInput: { inputMode: 'decimal' }
|
||||
}}
|
||||
/>
|
||||
<TextField select label={lab('WITHDRAWAL_TYPE')} value={type} onChange={(e) => setType(e.target.value)} fullWidth>
|
||||
<MenuItem value="Cash">{t('CASH')}</MenuItem>
|
||||
|
|
|
|||
|
|
@ -161,7 +161,9 @@ export function OtpDialog({
|
|||
</>
|
||||
) : (
|
||||
<>
|
||||
<Typography variant="body2" color="text.secondary">{ui('otpCodeHint')}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('otpCodeHint')}</Typography>
|
||||
<TextField
|
||||
label={ui('otpCode')}
|
||||
fullWidth
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|||
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||
import { Box, Button, CircularProgress, Paper, Stack, Typography } from '@mui/material';
|
||||
import ArrowBack from '@mui/icons-material/ArrowBack';
|
||||
import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
|
||||
import CheckCircleOutline from '@mui/icons-material/CheckCircleOutlineOutlined';
|
||||
import { useAuth } from '../../auth/AuthContext';
|
||||
import { useT, useUi } from '../../i18n';
|
||||
import { Logo } from '../../components/Logo';
|
||||
|
|
@ -32,19 +32,32 @@ export function RegisterEntityPage() {
|
|||
return (
|
||||
<Box sx={{ minHeight: '100vh', bgcolor: 'background.default', py: { xs: 3, md: 6 }, px: 2 }}>
|
||||
<Box sx={{ maxWidth: 900, mx: 'auto' }}>
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ mb: 4 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
mb: 4
|
||||
}}>
|
||||
<Logo height={34} />
|
||||
{!done && (
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.5}
|
||||
alignItems="center"
|
||||
component="button"
|
||||
onClick={() => nav('/register')}
|
||||
sx={{ border: 0, bgcolor: 'transparent', cursor: 'pointer', color: 'primary.main', font: 'inherit' }}
|
||||
>
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
border: 0,
|
||||
bgcolor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
color: 'primary.main',
|
||||
font: 'inherit'
|
||||
}}>
|
||||
<ArrowBack fontSize="small" className="flip-rtl" />
|
||||
<Typography variant="body2" fontWeight={600}>{ui('back')}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
fontWeight: 600
|
||||
}}>{ui('back')}</Typography>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
|
|
@ -52,13 +65,29 @@ export function RegisterEntityPage() {
|
|||
{done ? (
|
||||
<Paper variant="outlined" sx={{ p: 5, textAlign: 'center', borderRadius: 3 }}>
|
||||
<CheckCircleOutline color="success" sx={{ fontSize: 56, mb: 2 }} />
|
||||
<Typography variant="h5" fontWeight={800} sx={{ mb: 1.5 }}>{ui('registerSuccessTitle')}</Typography>
|
||||
<Typography color="text.secondary" sx={{ maxWidth: 480, mx: 'auto', mb: 3 }}>{ui('registerSuccessBody')}</Typography>
|
||||
<Typography
|
||||
variant="h5"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
mb: 1.5
|
||||
}}>{ui('registerSuccessTitle')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
maxWidth: 480,
|
||||
mx: 'auto',
|
||||
mb: 3
|
||||
}}>{ui('registerSuccessBody')}</Typography>
|
||||
<Button variant="contained" onClick={() => nav('/login')}>{ui('backToLogin')}</Button>
|
||||
</Paper>
|
||||
) : (
|
||||
<>
|
||||
<Typography variant="h5" fontWeight={800} sx={{ mb: 3 }}>{t(entity)}</Typography>
|
||||
<Typography
|
||||
variant="h5"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
mb: 3
|
||||
}}>{t(entity)}</Typography>
|
||||
{registerReady ? (
|
||||
<EntityForm
|
||||
key={entity}
|
||||
|
|
@ -69,9 +98,16 @@ export function RegisterEntityPage() {
|
|||
onPublicSuccess={() => setDone(true)}
|
||||
/>
|
||||
) : (
|
||||
<Stack alignItems="center" spacing={2} sx={{ py: 10 }}>
|
||||
<Stack
|
||||
spacing={2}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
py: 10
|
||||
}}>
|
||||
<CircularProgress />
|
||||
<Typography color="text.secondary">{ui('registerLoading')}</Typography>
|
||||
<Typography sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('registerLoading')}</Typography>
|
||||
</Stack>
|
||||
)}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import ArrowBack from '@mui/icons-material/ArrowBack';
|
|||
import BusinessOutlined from '@mui/icons-material/BusinessOutlined';
|
||||
import BusinessCenterOutlined from '@mui/icons-material/BusinessCenterOutlined';
|
||||
import GroupsOutlined from '@mui/icons-material/GroupsOutlined';
|
||||
import PersonOutline from '@mui/icons-material/PersonOutline';
|
||||
import PersonOutline from '@mui/icons-material/PersonOutlineOutlined';
|
||||
import LocalShippingOutlined from '@mui/icons-material/LocalShippingOutlined';
|
||||
import { useAuth } from '../../auth/AuthContext';
|
||||
import { useT, useUi } from '../../i18n';
|
||||
|
|
@ -41,18 +41,46 @@ export function RegisterHub() {
|
|||
return (
|
||||
<Box sx={{ minHeight: '100vh', bgcolor: 'background.default', py: { xs: 3, md: 6 }, px: 2 }}>
|
||||
<Box sx={{ maxWidth: 980, mx: 'auto' }}>
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ mb: 4 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
mb: 4
|
||||
}}>
|
||||
<Logo height={34} />
|
||||
<Stack direction="row" spacing={0.5} alignItems="center" component="button" onClick={() => nav('/login')}
|
||||
sx={{ border: 0, bgcolor: 'transparent', cursor: 'pointer', color: 'primary.main', font: 'inherit' }}
|
||||
>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.5}
|
||||
component="button"
|
||||
onClick={() => nav('/login')}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
border: 0,
|
||||
bgcolor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
color: 'primary.main',
|
||||
font: 'inherit'
|
||||
}}>
|
||||
<ArrowBack fontSize="small" className="flip-rtl" />
|
||||
<Typography variant="body2" fontWeight={600}>{ui('backToLogin')}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
fontWeight: 600
|
||||
}}>{ui('backToLogin')}</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
<Typography variant="h4" fontWeight={800} sx={{ mb: 1 }}>{ui('registerHubTitle')}</Typography>
|
||||
<Typography color="text.secondary" sx={{ mb: 4, maxWidth: 640 }}>{ui('registerHubSubtitle')}</Typography>
|
||||
<Typography
|
||||
variant="h4"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
mb: 1
|
||||
}}>{ui('registerHubTitle')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
mb: 4,
|
||||
maxWidth: 640
|
||||
}}>{ui('registerHubSubtitle')}</Typography>
|
||||
|
||||
<Box sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', md: 'repeat(3, 1fr)' } }}>
|
||||
{CARDS.map(({ entity, icon: Icon, desc, otp }) => (
|
||||
|
|
@ -60,8 +88,14 @@ export function RegisterHub() {
|
|||
<CardActionArea onClick={() => pick(entity, otp)} sx={{ height: '100%', p: 0.5 }}>
|
||||
<CardContent>
|
||||
<Icon color="primary" sx={{ fontSize: 34, mb: 1.5 }} />
|
||||
<Typography fontWeight={700} sx={{ mb: 0.5 }}>{t(entity)}</Typography>
|
||||
<Typography variant="body2" color="text.secondary">{ui(desc)}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 0.5
|
||||
}}>{t(entity)}</Typography>
|
||||
<Typography variant="body2" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui(desc)}</Typography>
|
||||
</CardContent>
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
|
|
|
|||
|
|
@ -62,9 +62,18 @@ export function SearchPanel({ entity, fields, filter, onChange }: { entity: stri
|
|||
|
||||
return (
|
||||
<Paper variant="outlined" sx={{ p: 1.25, mb: 1.5 }}>
|
||||
<Stack direction={{ xs: 'column', md: 'row' }} spacing={1.5} alignItems={{ md: 'center' }}>
|
||||
<Stack direction={{ xs: 'column', md: 'row' }} spacing={1.5} sx={{
|
||||
alignItems: { md: 'center' }
|
||||
}}>
|
||||
{status?.options && (
|
||||
<Stack direction="row" spacing={0.75} useFlexGap flexWrap="wrap" sx={{ flex: 1 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.75}
|
||||
useFlexGap
|
||||
sx={{
|
||||
flexWrap: "wrap",
|
||||
flex: 1
|
||||
}}>
|
||||
<Chip label={ui('all')} color={filter[status.id] ? 'default' : 'primary'} variant={filter[status.id] ? 'outlined' : 'filled'} onClick={() => onChange(setKey(filter, status.id, ''))} />
|
||||
{status.options.map((o) => {
|
||||
const on = filter[status.id] === String(o.CODE);
|
||||
|
|
@ -78,8 +87,15 @@ export function SearchPanel({ entity, fields, filter, onChange }: { entity: stri
|
|||
const v = filter[f.id] ?? '';
|
||||
const [a, b] = rangeParts(v);
|
||||
return (
|
||||
<Stack key={f.id} direction="row" spacing={1} alignItems="center">
|
||||
<Typography variant="body2" color="text.secondary" sx={{ whiteSpace: 'nowrap' }}>{t(f.caption)}</Typography>
|
||||
<Stack key={f.id} direction="row" spacing={1} sx={{
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
whiteSpace: 'nowrap'
|
||||
}}>{t(f.caption)}</Typography>
|
||||
<DateField
|
||||
size="small" label={ui('from')} value={toInput(a)}
|
||||
onChange={(iso) => onChange(setKey(filter, f.id, toRange(fromInput(iso), b)))}
|
||||
|
|
@ -102,7 +118,14 @@ export function SearchPanel({ entity, fields, filter, onChange }: { entity: stri
|
|||
</Stack>
|
||||
|
||||
{activeAdvanced.length > 0 && (
|
||||
<Stack direction="row" spacing={0.75} useFlexGap flexWrap="wrap" sx={{ mt: 1.5 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.75}
|
||||
useFlexGap
|
||||
sx={{
|
||||
flexWrap: "wrap",
|
||||
mt: 1.5
|
||||
}}>
|
||||
{activeAdvanced.map((f) => (
|
||||
<Chip key={f.id} size="small" label={`${t(f.caption)}: ${label(f, filter[f.id])}`} onDelete={() => onChange(setWithChildren(filter, f.id, ''))} />
|
||||
))}
|
||||
|
|
@ -111,7 +134,13 @@ export function SearchPanel({ entity, fields, filter, onChange }: { entity: stri
|
|||
)}
|
||||
|
||||
<Drawer anchor="right" open={open} onClose={() => setOpen(false)} slotProps={{ paper: { sx: { width: { xs: '100%', sm: 400 }, p: 3 } } }}>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mb: 2 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
mb: 2
|
||||
}}>
|
||||
<Typography variant="h6">{ui('filters')}</Typography>
|
||||
<IconButton onClick={() => setOpen(false)}><CloseIcon /></IconButton>
|
||||
</Stack>
|
||||
|
|
@ -135,7 +164,12 @@ export function SearchPanel({ entity, fields, filter, onChange }: { entity: stri
|
|||
const [a, b] = rangeParts(v);
|
||||
return (
|
||||
<Box key={f.id}>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mb: 0.75 }}>{t(f.caption)}</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
mb: 0.75
|
||||
}}>{t(f.caption)}</Typography>
|
||||
<Stack direction="row" spacing={1}>
|
||||
<DateField label={ui('from')} value={toInput(a)} onChange={(iso) => set(toRange(fromInput(iso), b))} fullWidth />
|
||||
<DateField label={ui('to')} value={toInput(b)} onChange={(iso) => set(toRange(a, fromInput(iso)))} fullWidth />
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ interface Dependent {
|
|||
|
||||
const STAKEHOLDER_NAMES: Record<string, string> = { '7': 'INVESTORS', '10': 'OWNERS', '11': 'COMPANIES', '12': 'OTHER_STAKEHOLDERS' };
|
||||
|
||||
const fleetClass = (fleetType: string) => getOptions('getFleetSubscriptionClass', { fleetType });
|
||||
const stakeholders = (id: string) =>
|
||||
STAKEHOLDER_NAMES[id] ? getOptions('getStakeHoldersList', { STAKEHOLDER_ID: id, STAKEHOLDER_NAME: STAKEHOLDER_NAMES[id] }) : Promise.resolve([]);
|
||||
const fleetClass =(fleetType: string) => getOptions('getFleetSubscriptionClass', { fleetType });
|
||||
const fleetUsage = (fleetType: string) => getOptions('getFleetSubscriptionUsage', { fleetType });
|
||||
|
||||
export const DEPENDENT_SEARCH: Record<string, Record<string, Dependent>> = {
|
||||
|
|
@ -27,6 +29,11 @@ export const DEPENDENT_SEARCH: Record<string, Record<string, Dependent>> = {
|
|||
FLEET_SUBSCRIPTION_CLASS: { parent: 'FLEET_SUBSCRIPTION_TYPE', load: fleetClass },
|
||||
USAGE_TYPE: { parent: 'FLEET_SUBSCRIPTION_TYPE', load: fleetUsage },
|
||||
},
|
||||
// entry permit requests: the sender / receiver names are those of the chosen sender / receiver type
|
||||
FLEET_REQUEST: {
|
||||
SENDER_RELATED_ENTITY_RECORD_ID: { parent: 'SENDER_RELATED_ENTITY_ID', load: (id) => stakeholders(id) },
|
||||
RECEIVER_RELATED_ENTITY_RECORD_ID: { parent: 'RECEIVER_RELATED_ENTITY_ID', load: (id) => stakeholders(id) },
|
||||
},
|
||||
PERMITS: {
|
||||
FLEET_CATEGORY: { parent: 'FLEET_ENTITY_NAME', load: fleetClass },
|
||||
INDUSTRIAL_ESTATE_STAKEHOLDER_ID: { parent: 'INDUSTRIAL_ESTATE_ID', load: (locationId) => getOptions('getInvestorsInLocation', { locationId }) },
|
||||
|
|
|
|||
|
|
@ -29,9 +29,20 @@ interface Row {
|
|||
DDL_VALUES?: Option[];
|
||||
}
|
||||
|
||||
/** Filters only some roles get: entry permit requests offer the sender / receiver pickers to the shift supervisor and the operations office. */
|
||||
const ROLE_ONLY_FILTERS: Record<string, { roles: string[]; ids: string[] }> = {
|
||||
FLEET_REQUEST: {
|
||||
roles: ['SHIFT_SUPERVISOR', 'OPOFF'],
|
||||
ids: ['SENDER_RELATED_ENTITY_ID', 'SENDER_RELATED_ENTITY_RECORD_ID', 'RECEIVER_RELATED_ENTITY_ID', 'RECEIVER_RELATED_ENTITY_RECORD_ID'],
|
||||
},
|
||||
};
|
||||
|
||||
export function useSearchFields(config: AppConfig | undefined, entity: string): SearchField[] {
|
||||
const { lang } = useAuth();
|
||||
const { lang, user } = useAuth();
|
||||
const roleCode = user?.role_code;
|
||||
return useMemo(() => {
|
||||
const only = ROLE_ONLY_FILTERS[entity];
|
||||
const hidden = only && !only.roles.includes(roleCode ?? '') ? only.ids : [];
|
||||
// a grid page lists exactly the fields flagged APPEAR_IN_GRID_SEARCH — what the legacy grid's init_search renders.
|
||||
// APPEAR_IN_ADVANCE_SEARCH belongs to the "advanced search" of the plan/letter create pages, not to grids.
|
||||
const rows = ((config?.ROLE_SEARCH_FIELD_AUTHORITY_VIEW ?? []) as unknown as Row[]).filter(
|
||||
|
|
@ -39,7 +50,7 @@ export function useSearchFields(config: AppConfig | undefined, entity: string):
|
|||
);
|
||||
// the plate code is searchable in both spellings (…_AR / …_EN); the old grids showed only the page language's one
|
||||
const duplicate = lang === 'AR' ? 'IDX_PLATE_CODE_EN' : 'IDX_PLATE_CODE_AR';
|
||||
return rows.filter((r) => r.HTML_ID !== duplicate).map((r) => ({
|
||||
return rows.filter((r) => r.HTML_ID !== duplicate && !hidden.includes(r.HTML_ID)).map((r) => ({
|
||||
id: r.HTML_ID,
|
||||
type: r.FIELD_TYPE,
|
||||
caption: r.CAPTION_CODE,
|
||||
|
|
@ -49,7 +60,7 @@ export function useSearchFields(config: AppConfig | undefined, entity: string):
|
|||
advanced: true,
|
||||
defaultValue: r.DEFAULT_VALUE || undefined,
|
||||
}));
|
||||
}, [config, entity, lang]);
|
||||
}, [config, entity, lang, roleCode]);
|
||||
}
|
||||
|
||||
export type Filter = Record<string, string>;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {
|
|||
Alert, Autocomplete, Box, Button, Checkbox, CircularProgress, FormControlLabel, IconButton, Paper, Stack, Tab, Table, TableBody,
|
||||
TableCell, TableHead, TableRow, Tabs, TextField, Typography,
|
||||
} from '@mui/material';
|
||||
import DeleteOutline from '@mui/icons-material/DeleteOutline';
|
||||
import DeleteOutline from '@mui/icons-material/DeleteOutlineOutlined';
|
||||
import EditOutlined from '@mui/icons-material/EditOutlined';
|
||||
import { useAuth } from '../../auth/AuthContext';
|
||||
import { useNotify } from '../../notify/NotifyProvider';
|
||||
|
|
@ -118,6 +118,8 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
const [stakeholder, setStakeholder] = useState('');
|
||||
const [approvalLocked, setApprovalLocked] = useState(false);
|
||||
const [driverFilesRequired, setDriverFilesRequired] = useState(false);
|
||||
// set only when the backend's driver check found the driver registered; until then the driver documents can be attached
|
||||
const [driverRegistered, setDriverRegistered] = useState(false);
|
||||
const [gatePassRequired, setGatePassRequired] = useState(false);
|
||||
const [matching, setMatching] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
|
@ -264,7 +266,10 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
{ ...ctx, approvalNumberId: approvalId.current },
|
||||
);
|
||||
const first = r.RESULTDATA?.[0] ?? {};
|
||||
if (r.RESULTCODE === 'FAILED') return notify.error(new Error(first.response_error_codes ?? 'ACTION_FAILED'));
|
||||
if (r.RESULTCODE === 'FAILED') {
|
||||
setDriverRegistered(false);
|
||||
return notify.error(new Error(first.response_error_codes ?? 'ACTION_FAILED'));
|
||||
}
|
||||
if (first.DRIVER_NAME !== undefined) {
|
||||
setForm((cur) => ({
|
||||
...cur,
|
||||
|
|
@ -274,7 +279,11 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
areaCode: first.DRIVER_MOBILE_AREA_CODE ?? cur.areaCode,
|
||||
}));
|
||||
setDriverFilesRequired(false);
|
||||
} else setDriverFilesRequired(true);
|
||||
setDriverRegistered(true);
|
||||
} else {
|
||||
setDriverFilesRequired(true);
|
||||
setDriverRegistered(false);
|
||||
}
|
||||
} catch (e) {
|
||||
notify.error(e);
|
||||
}
|
||||
|
|
@ -291,6 +300,7 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
setErrors({});
|
||||
setMatching(false);
|
||||
setDriverFilesRequired(false);
|
||||
setDriverRegistered(false);
|
||||
};
|
||||
|
||||
const fail = (msg: string, tabIndex?: number) => {
|
||||
|
|
@ -439,7 +449,11 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
|
||||
return (
|
||||
<Stack spacing={2}>
|
||||
<Typography color="text.secondary" fontSize={13.5}>{lab('ONE_TRIP_PERMIT_ADD_HINT')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
fontSize: 13.5
|
||||
}}>{lab('ONE_TRIP_PERMIT_ADD_HINT')}</Typography>
|
||||
<Paper variant="outlined" sx={{ p: 2 }}>
|
||||
<Tabs value={tab} onChange={(_, v: number) => setTab(v)} sx={{ mb: 2, borderBottom: 1, borderColor: 'divider' }}>
|
||||
<Tab label={lab('TRUCKS_INFO')} />
|
||||
|
|
@ -530,21 +544,36 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
|
||||
{tab === 2 && (
|
||||
<Box sx={grid}>
|
||||
{driverFilesRequired
|
||||
{!driverRegistered
|
||||
? DRIVER_ATT.map((f) => att(f, DRIVER_ATT_CAPTION[f]))
|
||||
: <Typography color="text.secondary" fontSize={13.5} sx={{ gridColumn: '1 / -1' }}>{ui('wizNoDriverFiles')}</Typography>}
|
||||
: <Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
fontSize: 13.5,
|
||||
gridColumn: '1 / -1'
|
||||
}}>{ui('wizNoDriverFiles')}</Typography>}
|
||||
{gatePassRequired && att(GATE_PASS, packageCode === 'ISD0001' ? 'GATE_PASS_WAYBILL' : 'ATTACHMENT')}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Stack direction="row" spacing={1} justifyContent="flex-end" sx={{ mt: 2 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{
|
||||
justifyContent: "flex-end",
|
||||
mt: 2
|
||||
}}>
|
||||
<Button color="inherit" onClick={clearForm} disabled={busy}>{ui('clear')}</Button>
|
||||
<Button variant="contained" color="success" onClick={() => void add()} disabled={busy}>{lab('ADD')}</Button>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<Paper variant="outlined" sx={{ p: 2 }}>
|
||||
<Typography fontWeight={700} sx={{ mb: 1 }}>{lab('ADDED_VEHICLES')} ({entries.length}{maxTrucks ? ` / ${maxTrucks}` : ''})</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 1
|
||||
}}>{lab('ADDED_VEHICLES')} ({entries.length}{maxTrucks ? ` / ${maxTrucks}` : ''})</Typography>
|
||||
<Box sx={{ overflowX: 'auto' }}>
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
|
|
@ -555,7 +584,9 @@ export function OneTripTrucks({ packageCode, subscriptionCode, packageGroupType,
|
|||
</TableHead>
|
||||
<TableBody>
|
||||
{entries.length === 0 && (
|
||||
<TableRow><TableCell colSpan={heads.length + 1}><Typography color="text.secondary">{lab('NO_INFO')}</Typography></TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={heads.length + 1}><Typography sx={{
|
||||
color: "text.secondary"
|
||||
}}>{lab('NO_INFO')}</Typography></TableCell></TableRow>
|
||||
)}
|
||||
{entries.map((e) => (
|
||||
<TableRow key={String(e.payload.ID)}>
|
||||
|
|
|
|||
|
|
@ -30,14 +30,40 @@ function Cards({ cards, action, onPick }: { cards: PackageCard[]; action: string
|
|||
{cards.map((c) => (
|
||||
<Card key={c.id} variant="outlined" sx={{ display: 'flex', flexDirection: 'column' }}>
|
||||
<CardContent sx={{ flex: 1 }}>
|
||||
<Typography fontWeight={700} fontSize={14.5} sx={{ mb: c.lines.length ? 1 : 0 }}>{c.title}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
fontSize: 14.5,
|
||||
mb: c.lines.length ? 1 : 0
|
||||
}}>{c.title}</Typography>
|
||||
<Stack spacing={0.5}>
|
||||
{c.lines.map((l, i) => {
|
||||
// the legacy cards print service hints in the accent colour ("pink"), without an icon
|
||||
if (l.kind === 'hint') return (
|
||||
<Typography
|
||||
key={i}
|
||||
sx={{
|
||||
fontSize: 13,
|
||||
fontWeight: 600,
|
||||
color: "secondary.main"
|
||||
}}>{l.text}</Typography>
|
||||
);
|
||||
const Icon = ICON[l.kind];
|
||||
return (
|
||||
<Stack key={i} direction="row" spacing={0.75} alignItems="center" color={l.kind === 'price' ? 'primary.main' : 'text.secondary'}>
|
||||
<Stack
|
||||
key={i}
|
||||
direction="row"
|
||||
spacing={0.75}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
color: l.kind === 'price' ? 'primary.main' : 'text.secondary'
|
||||
}}>
|
||||
<Icon sx={{ fontSize: 16 }} />
|
||||
<Typography fontSize={13} fontWeight={l.kind === 'price' ? 700 : 400}>{l.text}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: 13,
|
||||
fontWeight: l.kind === 'price' ? 700 : 400
|
||||
}}>{l.text}</Typography>
|
||||
</Stack>
|
||||
);
|
||||
})}
|
||||
|
|
@ -61,7 +87,13 @@ function Picker({ items, selected, onChange }: { items: Selectable[]; selected:
|
|||
const toggle = (v: string) => onChange(chosen.has(v) ? selected.filter((x) => x !== v) : [...selected, v]);
|
||||
return (
|
||||
<Paper variant="outlined" sx={{ p: 2 }}>
|
||||
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={1} alignItems={{ sm: 'center' }} sx={{ mb: 1 }}>
|
||||
<Stack
|
||||
direction={{ xs: 'column', sm: 'row' }}
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: { sm: 'center' },
|
||||
mb: 1
|
||||
}}>
|
||||
<TextField size="small" label={ui('wizSearchList')} value={q} onChange={(e) => setQ(e.target.value)} sx={{ flex: 1 }} />
|
||||
<Button size="small" onClick={() => onChange([...new Set([...selected, ...filtered.map((i) => i.VALUE)])])}>{ui('wizSelectShown')}</Button>
|
||||
<Button size="small" color="inherit" disabled={!selected.length} onClick={() => onChange([])}>{ui('clear')}</Button>
|
||||
|
|
@ -74,7 +106,13 @@ function Picker({ items, selected, onChange }: { items: Selectable[]; selected:
|
|||
<ListItemText primary={i.TEXT} />
|
||||
</ListItemButton>
|
||||
))}
|
||||
{filtered.length > 200 && <Typography variant="caption" color="text.secondary" sx={{ p: 1.5, display: 'block' }}>{ui('wizRefine')} ({filtered.length})</Typography>}
|
||||
{filtered.length > 200 && <Typography
|
||||
variant="caption"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
p: 1.5,
|
||||
display: 'block'
|
||||
}}>{ui('wizRefine')} ({filtered.length})</Typography>}
|
||||
</List>
|
||||
</Paper>
|
||||
);
|
||||
|
|
@ -268,7 +306,13 @@ export function SubscriptionWizard() {
|
|||
];
|
||||
const current = [groups, packages, services, subs][step];
|
||||
const empty = (cards?: PackageCard[]) =>
|
||||
cards && !cards.length && <Typography variant="h6" color="text.secondary" textAlign="center" sx={{ py: 4 }}>{t('NO_AVAILABLE_SERVICES')}</Typography>;
|
||||
cards && !cards.length && <Typography
|
||||
variant="h6"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
textAlign: "center",
|
||||
py: 4
|
||||
}}>{t('NO_AVAILABLE_SERVICES')}</Typography>;
|
||||
|
||||
const reset = (to: number) => {
|
||||
if (to <= 1) setPkg(null);
|
||||
|
|
@ -311,7 +355,15 @@ export function SubscriptionWizard() {
|
|||
))}
|
||||
</Stepper>
|
||||
{(group || pkg || service) && step < 4 && (
|
||||
<Stack direction="row" spacing={0.75} flexWrap="wrap" useFlexGap sx={{ mt: 2, justifyContent: 'center' }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.75}
|
||||
useFlexGap
|
||||
sx={{
|
||||
flexWrap: "wrap",
|
||||
mt: 2,
|
||||
justifyContent: 'center'
|
||||
}}>
|
||||
{[group, pkg, service].filter(Boolean).map((p) => <Chip key={p!.id} size="small" label={p!.title} />)}
|
||||
</Stack>
|
||||
)}
|
||||
|
|
@ -372,17 +424,38 @@ export function SubscriptionWizard() {
|
|||
|
||||
{step >= 4 && sub && (
|
||||
<Paper variant="outlined" sx={{ p: 2 }}>
|
||||
<Typography fontWeight={700} sx={{ mb: 1 }}>{ui('wizSummary')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 1
|
||||
}}>{ui('wizSummary')}</Typography>
|
||||
<Stack spacing={0.5}>
|
||||
{[group, pkg, service].filter(Boolean).map((p) => <Typography key={p!.id} fontSize={13.5}>{p!.title}</Typography>)}
|
||||
<Typography fontSize={14} fontWeight={700}>{sub.title}</Typography>
|
||||
{sub.lines.map((l, i) => <Typography key={i} fontSize={13} color="text.secondary">{l.text}</Typography>)}
|
||||
{[group, pkg, service].filter(Boolean).map((p) => <Typography key={p!.id} sx={{
|
||||
fontSize: 13.5
|
||||
}}>{p!.title}</Typography>)}
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
fontWeight: 700
|
||||
}}>{sub.title}</Typography>
|
||||
{sub.lines.map((l, i) => <Typography key={i} color={l.kind === 'hint' ? 'secondary.main' : 'text.secondary'} sx={{
|
||||
fontSize: 13
|
||||
}}>{l.text}</Typography>)}
|
||||
{estateValue && !unowned && !oneTrip && (
|
||||
<Typography fontSize={13} color="text.secondary">
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: 13,
|
||||
color: "text.secondary"
|
||||
}}>
|
||||
{ui('wizEstate')}: {t(estates.find((e) => String(e.CODE) === estateValue)?.CAPTION_CODE ?? estateValue)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography fontSize={14} color="primary.main" fontWeight={700}>{ui('wizPrice')}: {sub.price + sub.platformPrice} {t('RO') !== 'RO' ? t('RO') : ui('wizOmr')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
color: "primary.main",
|
||||
fontWeight: 700
|
||||
}}>{ui('wizPrice')}: {sub.price + sub.platformPrice} {t('RO') !== 'RO' ? t('RO') : ui('wizOmr')}</Typography>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)}
|
||||
|
|
@ -430,21 +503,46 @@ export function SubscriptionWizard() {
|
|||
|
||||
{step === 5 && sub && (
|
||||
<Paper variant="outlined" sx={{ p: 2 }}>
|
||||
<Stack direction="row" spacing={4} sx={{ mb: 2 }} flexWrap="wrap" useFlexGap>
|
||||
<Box><Typography color="text.secondary" fontSize={13}>{ui('wizCount')}</Typography><Typography variant="h5" color="primary">{count}</Typography></Box>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={4}
|
||||
useFlexGap
|
||||
sx={{
|
||||
flexWrap: "wrap",
|
||||
mb: 2
|
||||
}}>
|
||||
<Box><Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
fontSize: 13
|
||||
}}>{ui('wizCount')}</Typography><Typography variant="h5" color="primary">{count}</Typography></Box>
|
||||
<Box>
|
||||
<Typography color="text.secondary" fontSize={13}>{cap('TOTAL_PRICE', 'Total price', 'السعر الإجمالي')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
fontSize: 13
|
||||
}}>{cap('TOTAL_PRICE', 'Total price', 'السعر الإجمالي')}</Typography>
|
||||
<Typography variant="h5" color="primary">{total} {t('RO') !== 'RO' ? t('RO') : ui('wizOmr')}</Typography>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
<Typography fontWeight={700} sx={{ mb: 0.5 }}>{cap('PAYMENT_METHOD', 'Payment method', 'طريقة الدفع')}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
mb: 0.5
|
||||
}}>{cap('PAYMENT_METHOD', 'Payment method', 'طريقة الدفع')}</Typography>
|
||||
{methods.isPending && <CircularProgress size={20} />}
|
||||
<RadioGroup value={method} onChange={(e) => setMethod(e.target.value)}>
|
||||
{(methods.data ?? []).map((m) => (
|
||||
<Box key={m.ID}>
|
||||
<FormControlLabel value={String(m.ID)} disabled={m.ID === CARD_PAYMENT} control={<Radio size="small" />} label={m.NAME} />
|
||||
{m.ID === CARD_PAYMENT && <Typography variant="caption" color="text.secondary" sx={{ marginInlineStart: 4, display: 'block' }}>{ui('wizCardLater')}</Typography>}
|
||||
{m.ID === CARD_PAYMENT && <Typography
|
||||
variant="caption"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
marginInlineStart: 4,
|
||||
display: 'block'
|
||||
}}>{ui('wizCardLater')}</Typography>}
|
||||
{m.ID === 6 && method === '6' && (
|
||||
<TextField size="small" label={cap('RECEIPT_NUMBER', 'Receipt number', 'رقم الإيصال')} value={receipt} onChange={(e) => setReceipt(e.target.value)} slotProps={{ htmlInput: { maxLength: 12 } }} sx={{ marginInlineStart: 4, mb: 1 }} />
|
||||
)}
|
||||
|
|
@ -471,7 +569,9 @@ export function SubscriptionWizard() {
|
|||
<DialogTitle>{cap('PAY', 'Pay', 'دفع')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography>{sub?.title}</Typography>
|
||||
<Typography color="text.secondary">{ui('wizCount')}: {count} · {total} {t('RO') !== 'RO' ? t('RO') : ui('wizOmr')}</Typography>
|
||||
<Typography sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('wizCount')}: {count} · {total} {t('RO') !== 'RO' ? t('RO') : ui('wizOmr')}</Typography>
|
||||
<Typography sx={{ mt: 1 }}>{t('CONFIRM_MSG')}</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,199 @@
|
|||
import { useMemo, useState } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import {
|
||||
Alert, Box, Button, CircularProgress, Collapse, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, MenuItem, Paper, Stack, Table, TableBody,
|
||||
TableCell, TableHead, TablePagination, TableRow, TextField, Tooltip,
|
||||
} from '@mui/material';
|
||||
import ExpandMore from '@mui/icons-material/ExpandMore';
|
||||
import OpenInNewOutlined from '@mui/icons-material/OpenInNewOutlined';
|
||||
import HistoryOutlined from '@mui/icons-material/HistoryOutlined';
|
||||
import { rpc, type Envelope } from '../../api/client';
|
||||
import { useAuth } from '../../auth/AuthContext';
|
||||
import { useLabel, useT, useUi } from '../../i18n';
|
||||
import { sectionFrame } from '../../components/SectionTitle';
|
||||
|
||||
/**
|
||||
* The old record pages ended with a collapsed "Events" card: who did what to the record and when, with a popup that
|
||||
* compares the old and the new values. It loads only when it is opened.
|
||||
*/
|
||||
const ROWS = 5;
|
||||
|
||||
interface Filters { action: string; login: string; from: string; to: string }
|
||||
const EMPTY: Filters = { action: '', login: '', from: '', to: '' };
|
||||
|
||||
/** yyyy-mm-dd (date box) -> yyyymmdd (what the backend's "from-to" date range compares) */
|
||||
const yyyymmdd = (d: string) => d.replace(/-/g, '');
|
||||
|
||||
type Row = [id: string, action: string, user: string, date: string, details: string];
|
||||
|
||||
/** The details icon carries the old / new data as base64 JSON inside its click handler; read it, never run it. */
|
||||
function parseDetails(html: string): { oldData: Record<string, unknown>; newData: Record<string, unknown> } | null {
|
||||
const b64 = html.match(/"logModal",\s*0,\s*\\?"([A-Za-z0-9+/=]+)\\?"/)?.[1];
|
||||
if (!b64) return null;
|
||||
try {
|
||||
const bin = atob(b64);
|
||||
const text = new TextDecoder().decode(Uint8Array.from(bin, (c) => c.charCodeAt(0)));
|
||||
const outer = JSON.parse(text.replace(/^\/\//, '')) as { OLD?: string; NEW?: string };
|
||||
const inner = (s?: string) => (s ? (JSON.parse(s.replace(/^\/\//, '')) as Record<string, unknown>) : {});
|
||||
return { oldData: inner(outer.OLD), newData: inner(outer.NEW) };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function EntityEvents({ entity, id }: { entity: string; id: string }) {
|
||||
const { config } = useAuth();
|
||||
const t = useT();
|
||||
const ui = useUi();
|
||||
const lab = useLabel();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [draft, setDraft] = useState<Filters>(EMPTY);
|
||||
const [applied, setApplied] = useState<Filters>(EMPTY);
|
||||
const [page, setPage] = useState(0);
|
||||
const [detail, setDetail] = useState<{ oldData: Record<string, unknown>; newData: Record<string, unknown> } | null>(null);
|
||||
|
||||
const allowed = !!config?.AUTHORITY.some((a) => a.ENTITY_NAME === entity && a.ACTION_NAME === 'GETLOG');
|
||||
const actions = useMemo(
|
||||
() => ((config?.LOG_ACTION_LIST as { ENTITY_NAME: string; ACTION_CODE: string; CAPTION_CODE: string }[] | undefined) ?? []).filter((a) => a.ENTITY_NAME === entity),
|
||||
[config, entity],
|
||||
);
|
||||
|
||||
const events = useQuery({
|
||||
queryKey: ['events', entity, id, applied, page],
|
||||
enabled: open && allowed,
|
||||
queryFn: async () => {
|
||||
const r = await rpc<Envelope<Row[]> & { RECORDS?: number }>(entity, 'GETLOG', {
|
||||
data: {
|
||||
ENTITY_ID: id,
|
||||
ACTION_CODE: applied.action,
|
||||
LOGIN: applied.login,
|
||||
...(applied.from && applied.to ? { CREATION_DATE: `${yyyymmdd(applied.from)}-${yyyymmdd(applied.to)}` } : {}),
|
||||
},
|
||||
page: page + 1,
|
||||
rows: ROWS,
|
||||
});
|
||||
return { rows: (r.DATA ?? []) as Row[], records: Number(r.RECORDS ?? 0), total: Number(r.TOTAL ?? 0) };
|
||||
},
|
||||
});
|
||||
|
||||
if (!allowed) return null;
|
||||
|
||||
const search = () => { setPage(0); setApplied(draft); };
|
||||
const reset = () => { setPage(0); setDraft(EMPTY); setApplied(EMPTY); };
|
||||
const rows = events.data?.rows ?? [];
|
||||
const count = events.data?.records ?? 0;
|
||||
|
||||
return (
|
||||
<Paper variant="outlined" sx={{ p: 2, ...sectionFrame }}>
|
||||
<Box
|
||||
component="button"
|
||||
type="button"
|
||||
onClick={() => setOpen((o) => !o)}
|
||||
aria-expanded={open}
|
||||
sx={{
|
||||
all: 'unset', boxSizing: 'border-box', width: '100%', display: 'flex', alignItems: 'center', gap: 1, cursor: 'pointer',
|
||||
fontSize: 15, fontWeight: 800, color: 'text.primary', pb: open ? 0.75 : 0, borderBottom: open ? 1 : 0, borderColor: 'divider',
|
||||
}}
|
||||
>
|
||||
<HistoryOutlined sx={{ fontSize: 20 }} />
|
||||
<Box sx={{ flex: 1 }}>{t('EVENT_TABLE')}</Box>
|
||||
<ExpandMore sx={{ transition: 'transform .2s', transform: open ? 'rotate(180deg)' : 'none' }} />
|
||||
</Box>
|
||||
|
||||
<Collapse in={open} unmountOnExit>
|
||||
<Stack
|
||||
direction={{ xs: 'column', md: 'row' }}
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: { md: 'center' },
|
||||
my: 1.5
|
||||
}}>
|
||||
<TextField select size="small" label={t('ACTION_CODE')} value={draft.action} onChange={(e) => setDraft({ ...draft, action: e.target.value })} sx={{ minWidth: 200 }}>
|
||||
<MenuItem value="">---</MenuItem>
|
||||
{actions.map((a) => <MenuItem key={a.ACTION_CODE} value={a.ACTION_CODE}>{t(a.CAPTION_CODE)}</MenuItem>)}
|
||||
</TextField>
|
||||
<TextField size="small" label={t('USERNAME')} value={draft.login} onChange={(e) => setDraft({ ...draft, login: e.target.value })} />
|
||||
<TextField size="small" type="date" label={ui('from')} value={draft.from} onChange={(e) => setDraft({ ...draft, from: e.target.value })} slotProps={{ inputLabel: { shrink: true } }} />
|
||||
<TextField size="small" type="date" label={ui('to')} value={draft.to} onChange={(e) => setDraft({ ...draft, to: e.target.value })} slotProps={{ inputLabel: { shrink: true } }} />
|
||||
<Button variant="contained" onClick={search}>{t('SEARCH')}</Button>
|
||||
<Button onClick={reset}>{t('CANCEL_SEARCH')}</Button>
|
||||
</Stack>
|
||||
|
||||
{events.isPending && <Box sx={{ display: 'grid', placeItems: 'center', py: 3 }}><CircularProgress size={24} /></Box>}
|
||||
{events.error && <Alert severity="error">{t((events.error as Error).message)}</Alert>}
|
||||
{events.data && (
|
||||
<Box sx={{ overflowX: 'auto' }}>
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell align="center">{t('ACTION_CODE')}</TableCell>
|
||||
<TableCell align="center">{t('USERNAME')}</TableCell>
|
||||
<TableCell align="center">{t('CREATION_DATE')}</TableCell>
|
||||
<TableCell />
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{rows.length === 0 && <TableRow><TableCell colSpan={4} align="center" sx={{ color: 'text.secondary' }}>{t('NO_INFO')}</TableCell></TableRow>}
|
||||
{rows.map((r) => {
|
||||
const d = parseDetails(String(r[4] ?? ''));
|
||||
return (
|
||||
<TableRow key={r[0]}>
|
||||
<TableCell align="center">{r[1]}</TableCell>
|
||||
<TableCell align="center">{r[2]}</TableCell>
|
||||
<TableCell align="center" dir="ltr">{r[3]}</TableCell>
|
||||
<TableCell align="center">
|
||||
{d && Object.keys(d.newData).length + Object.keys(d.oldData).length > 0 && (
|
||||
<Tooltip title={t('EVENTS_DETAILS')}>
|
||||
<IconButton size="small" color="primary" onClick={() => setDetail(d)} aria-label={t('EVENTS_DETAILS')}><OpenInNewOutlined fontSize="small" /></IconButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<TablePagination
|
||||
component="div"
|
||||
count={count}
|
||||
page={page}
|
||||
rowsPerPage={ROWS}
|
||||
rowsPerPageOptions={[ROWS]}
|
||||
labelDisplayedRows={({ from, to }) => `${from}–${to}`}
|
||||
onPageChange={(_, p) => setPage(p)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Collapse>
|
||||
|
||||
<Dialog open={!!detail} onClose={() => setDetail(null)} fullWidth maxWidth="md">
|
||||
<DialogTitle>{t('EVENTS_DETAILS')}</DialogTitle>
|
||||
<DialogContent>
|
||||
<Box sx={{ overflowX: 'auto' }}>
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell align="center">{t('INFO_TYPE')}</TableCell>
|
||||
<TableCell align="center">{t('OLD_DATA')}</TableCell>
|
||||
<TableCell align="center">{t('NEW_DATA')}</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{detail && Object.entries(detail.newData).map(([k, v]) => (
|
||||
<TableRow key={k}>
|
||||
<TableCell align="center">{lab(k)}</TableCell>
|
||||
<TableCell align="center">{detail.oldData[k] === undefined ? '' : String(detail.oldData[k])}</TableCell>
|
||||
<TableCell align="center">{String(v)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setDetail(null)}>{t('CLOSE')}</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import { StatusChip } from '../../components/StatusChip';
|
|||
import { getExtraFields, getView, runAction, type EntityAction, type ExtraSpec } from '../../api/entity';
|
||||
import type { StoredAttachment } from '../../api/attachments';
|
||||
import { resolveFields, toDisplayDate, toPayload, type ResolvedField } from '../forms/fields';
|
||||
import { getLayout, VIEW_HIDDEN_FIELDS, VIEW_HIDDEN_SECTIONS, VIEW_LAST_FIELDS, type EntityLayout } from '../forms/layouts';
|
||||
import { aliasSource, getLayout, VIEW_HIDDEN_FIELDS, VIEW_HIDDEN_SECTIONS, VIEW_LAST_FIELDS, type EntityLayout } from '../forms/layouts';
|
||||
import { AttachmentField } from '../forms/AttachmentField';
|
||||
import { ExtraFieldsDialog } from '../forms/ExtraFieldsDialog';
|
||||
import { roleLabel } from '../../i18n/roles';
|
||||
|
|
@ -26,6 +26,8 @@ import { actionNeedsEmail, isDangerous, isSimpleAction } from './actions';
|
|||
import { FLEET_REQUEST_ORDER, fleetRequestView } from './fleetRequest';
|
||||
import { PendingPayDialog } from '../gridActions/PendingPayDialog';
|
||||
import { InvoiceSummary } from './InvoiceSummary';
|
||||
import { EntityEvents } from './EntityEvents';
|
||||
import { NewPasswordDialog, findNewPassword, isPasswordReset } from '../../components/NewPasswordDialog';
|
||||
import { RenewSubscriptionDialog } from '../gridActions/RenewSubscriptionDialog';
|
||||
|
||||
type Data = Record<string, unknown>;
|
||||
|
|
@ -35,7 +37,7 @@ function Value({ field, data, layout }: { field: ResolvedField; data: Data; layo
|
|||
const { lang } = useAuth();
|
||||
const t = useT();
|
||||
const ui = useUi();
|
||||
const raw = data[layout.alias?.[field.name] ?? field.name];
|
||||
const raw = data[aliasSource(layout.alias?.[field.name] ?? field.name, lang)];
|
||||
const dynamic = layout.dynamic?.[field.name];
|
||||
const textKey = layout.viewText?.[field.name];
|
||||
const humanize = useLabel();
|
||||
|
|
@ -48,7 +50,9 @@ function Value({ field, data, layout }: { field: ResolvedField; data: Data; layo
|
|||
});
|
||||
|
||||
const empty = raw === undefined || raw === null || String(raw).trim() === '' || (Array.isArray(raw) && !raw.length);
|
||||
const none = <Typography component="span" color="text.disabled">—</Typography>;
|
||||
const none = <Typography component="span" sx={{
|
||||
color: "text.disabled"
|
||||
}}>—</Typography>;
|
||||
if (textKey && String(data[textKey] ?? '').trim()) return <>{String(data[textKey])}</>;
|
||||
const forced = (data.__TEXT as Record<string, string> | undefined)?.[field.name];
|
||||
if (forced) return <>{forced}</>;
|
||||
|
|
@ -132,14 +136,17 @@ export function EntityView({ entity, id }: { entity: string; id: string }) {
|
|||
);
|
||||
const byName = useMemo(() => new Map(fields.map((f) => [f.name, f])), [fields]);
|
||||
|
||||
const [newPassword, setNewPassword] = useState<string | null>(null);
|
||||
const run = useMutation({
|
||||
meta: { loading: 'processing' },
|
||||
mutationFn: async (v: { a: EntityAction; reason?: Record<string, string> }) => {
|
||||
const values = { ...data, ...Object.fromEntries(Object.entries(layout?.alias ?? {}).map(([f, src]) => [f, data[src]])) };
|
||||
const values = { ...data, ...Object.fromEntries(Object.entries(layout?.alias ?? {}).map(([f, src]) => [f, data[aliasSource(src, lang)]])) };
|
||||
return runAction(entity, v.a.ACTION_NAME, toPayload(fields, values), id, [], v.reason);
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
notify.success(String(res.MESSAGE ?? 'SUCCESSFUL.OPERATION'), ui('saved'));
|
||||
onSuccess: (res, v) => {
|
||||
// the new password is shown in a box with a copy button, not in a toast that disappears
|
||||
if (isPasswordReset(v.a.ACTION_NAME) && findNewPassword(String(res.MESSAGE ?? ''))) setNewPassword(String(res.MESSAGE));
|
||||
else notify.success(String(res.MESSAGE ?? 'SUCCESSFUL.OPERATION'), ui('saved'));
|
||||
// print / invoice actions answer with the generated file's location
|
||||
const file = typeof res.DATA === 'string' ? res.DATA : (res.DATA as { FILE?: string } | undefined)?.FILE;
|
||||
if (file && /downloadFiles/i.test(file)) void downloadReport(file).catch((e) => notify.error(e));
|
||||
|
|
@ -255,10 +262,23 @@ export function EntityView({ entity, id }: { entity: string; id: string }) {
|
|||
// font (a plate badge where the entity is a vehicle), and the status beside it
|
||||
title={t(entity)}
|
||||
subtitle={
|
||||
<Stack direction="row" spacing={1} alignItems="center" flexWrap="wrap" useFlexGap>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
useFlexGap
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
flexWrap: "wrap"
|
||||
}}>
|
||||
{header.lead}
|
||||
{header.title && header.title !== t(entity) && (
|
||||
<Typography component="span" fontSize={16} fontWeight={700} color="text.primary">{header.title}</Typography>
|
||||
<Typography
|
||||
component="span"
|
||||
sx={{
|
||||
fontSize: 16,
|
||||
fontWeight: 700,
|
||||
color: "text.primary"
|
||||
}}>{header.title}</Typography>
|
||||
)}
|
||||
{header.status && <StatusChip status={header.status} />}
|
||||
{header.subtitle && header.subtitle !== t(entity) && <span>{header.subtitle}</span>}
|
||||
|
|
@ -327,8 +347,19 @@ export function EntityView({ entity, id }: { entity: string; id: string }) {
|
|||
<Box sx={{ display: 'grid', gap: 1.5, gridTemplateColumns: { xs: '1fr', md: 'repeat(2, 1fr)', lg: 'repeat(3, 1fr)' } }}>
|
||||
{shown.map((f) => (
|
||||
<Box key={f.name} sx={{ minWidth: 0 }}>
|
||||
<Typography component="div" fontSize={13.5} fontWeight={600} color="primary.main" lineHeight={1.4}>{lab(f.caption)}</Typography>
|
||||
<Typography fontSize={14} sx={{ wordBreak: 'break-word' }}><Value field={f} data={data} layout={layout} /></Typography>
|
||||
<Typography
|
||||
component="div"
|
||||
sx={{
|
||||
fontSize: 13.5,
|
||||
fontWeight: 600,
|
||||
color: "primary.main",
|
||||
lineHeight: 1.4
|
||||
}}>{lab(f.caption)}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
wordBreak: 'break-word'
|
||||
}}><Value field={f} data={data} layout={layout} /></Typography>
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
|
|
@ -459,6 +490,8 @@ export function EntityView({ entity, id }: { entity: string; id: string }) {
|
|||
</Stack>
|
||||
)}
|
||||
|
||||
<Box sx={{ mt: 1.5 }}><EntityEvents entity={entity} id={id} /></Box>
|
||||
|
||||
<Dialog open={!!action} onClose={() => setAction(null)}>
|
||||
<DialogTitle>{t(String(action?.ACTION_CAPTION_CODE ?? action?.ACTION_NAME ?? ''))}</DialogTitle>
|
||||
<DialogContent>
|
||||
|
|
@ -537,6 +570,8 @@ export function EntityView({ entity, id }: { entity: string; id: string }) {
|
|||
/>
|
||||
)}
|
||||
|
||||
<NewPasswordDialog message={newPassword} onClose={() => setNewPassword(null)} />
|
||||
|
||||
{extra && (
|
||||
<ExtraFieldsDialog
|
||||
spec={extra.spec}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,27 @@ function Tile({ caption, value, unit, strong, tone }: { caption: string; value:
|
|||
color: strong ? 'primary.contrastText' : 'text.primary',
|
||||
}}
|
||||
>
|
||||
<Typography fontSize={12.5} sx={{ opacity: strong ? 0.85 : 1 }} color={strong ? 'inherit' : 'text.secondary'}>{caption}</Typography>
|
||||
<Typography fontSize={22} fontWeight={800} lineHeight={1.3} color={tone === 'neg' && !strong ? 'error.main' : 'inherit'}>
|
||||
<bdi dir="ltr">{value}</bdi> <Typography component="span" fontSize={12.5} fontWeight={600} color="inherit" sx={{ opacity: 0.8 }}>{unit}</Typography>
|
||||
<Typography
|
||||
color={strong ? 'inherit' : 'text.secondary'}
|
||||
sx={{
|
||||
fontSize: 12.5,
|
||||
opacity: strong ? 0.85 : 1
|
||||
}}>{caption}</Typography>
|
||||
<Typography
|
||||
color={tone === 'neg' && !strong ? 'error.main' : 'inherit'}
|
||||
sx={{
|
||||
fontSize: 22,
|
||||
fontWeight: 800,
|
||||
lineHeight: 1.3
|
||||
}}>
|
||||
<bdi dir="ltr">{value}</bdi> <Typography
|
||||
component="span"
|
||||
sx={{
|
||||
fontSize: 12.5,
|
||||
fontWeight: 600,
|
||||
color: "inherit",
|
||||
opacity: 0.8
|
||||
}}>{unit}</Typography>
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
|
|
@ -62,7 +80,12 @@ export function InvoiceSummary({ id, data }: { id: string; data: Record<string,
|
|||
<Paper variant="outlined" sx={{ p: 2 }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 1.5 }}>
|
||||
<ReceiptLongOutlined color="primary" fontSize="small" />
|
||||
<Typography component="h2" fontWeight={700} fontSize={14.5}>{ui('invoiceSummary')}</Typography>
|
||||
<Typography
|
||||
component="h2"
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
fontSize: 14.5
|
||||
}}>{ui('invoiceSummary')}</Typography>
|
||||
</Box>
|
||||
|
||||
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1.25, mb: 2 }}>
|
||||
|
|
@ -74,7 +97,12 @@ export function InvoiceSummary({ id, data }: { id: string; data: Record<string,
|
|||
|
||||
{lines.isPending && <Box sx={{ display: 'grid', placeItems: 'center', py: 3 }}><CircularProgress size={26} /></Box>}
|
||||
{lines.error && <Alert severity="error">{t((lines.error as Error).message)}</Alert>}
|
||||
{lines.data && !rows.length && <Typography color="text.secondary" textAlign="center" sx={{ py: 2 }}>{t('NO_INFO')}</Typography>}
|
||||
{lines.data && !rows.length && <Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
textAlign: "center",
|
||||
py: 2
|
||||
}}>{t('NO_INFO')}</Typography>}
|
||||
{rows.length > 0 && (
|
||||
<Box sx={{ overflowX: 'auto' }}>
|
||||
<Table size="small">
|
||||
|
|
@ -134,7 +162,9 @@ function TransactionsDialog({ invoiceId, row, title, unit, onClose }: { invoiceI
|
|||
<DialogContent>
|
||||
{list.isPending && <Box sx={{ display: 'grid', placeItems: 'center', py: 4 }}><CircularProgress size={26} /></Box>}
|
||||
{list.error && <Alert severity="error">{t((list.error as Error).message)}</Alert>}
|
||||
{list.data && !data.length && <Typography color="text.secondary">{t('NO_INFO')}</Typography>}
|
||||
{list.data && !data.length && <Typography sx={{
|
||||
color: "text.secondary"
|
||||
}}>{t('NO_INFO')}</Typography>}
|
||||
{data.length > 0 && (
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
|
|
|
|||
|
|
@ -27,9 +27,23 @@ function Item({ caption, children }: { caption: string; children: React.ReactNod
|
|||
const empty = children === undefined || children === null || children === '';
|
||||
return (
|
||||
<Box sx={{ minWidth: 0 }}>
|
||||
<Typography component="div" fontSize={13.5} fontWeight={600} color="primary.main" lineHeight={1.4}>{caption}</Typography>
|
||||
<Typography component="div" fontSize={14} sx={{ wordBreak: 'break-word' }}>
|
||||
{empty ? <Typography component="span" color="text.disabled">—</Typography> : children}
|
||||
<Typography
|
||||
component="div"
|
||||
sx={{
|
||||
fontSize: 13.5,
|
||||
fontWeight: 600,
|
||||
color: "primary.main",
|
||||
lineHeight: 1.4
|
||||
}}>{caption}</Typography>
|
||||
<Typography
|
||||
component="div"
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
wordBreak: 'break-word'
|
||||
}}>
|
||||
{empty ? <Typography component="span" sx={{
|
||||
color: "text.disabled"
|
||||
}}>—</Typography> : children}
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export const UI = {
|
|||
darkMode: { en: 'Dark mode', ar: 'الوضع الداكن' },
|
||||
lightMode: { en: 'Light mode', ar: 'الوضع الفاتح' },
|
||||
noFile: { en: 'No file', ar: 'لا يوجد ملف' },
|
||||
sessionEnded: { en: 'Your session has ended. Please sign in again.', ar: 'انتهت جلستك. يرجى تسجيل الدخول مرة أخرى.' },
|
||||
notProvided: { en: 'Not provided', ar: 'غير مدخل' },
|
||||
invoiceSummary: { en: 'Invoice summary', ar: 'ملخص الفاتورة' },
|
||||
wrongFileType: { en: 'Wrong file type. Choose a CSV or Excel file (.csv, .xls, .xlsx).', ar: 'نوع الملف غير صحيح. اختر ملف CSV أو Excel (.csv، .xls، .xlsx).' },
|
||||
|
|
@ -36,6 +37,9 @@ export const UI = {
|
|||
exportAll: { en: 'No filters are applied: every record will be exported.', ar: 'لا توجد عوامل تصفية: سيتم تصدير جميع السجلات.' },
|
||||
exportReady: { en: 'The file is ready and is downloading', ar: 'الملف جاهز ويجري تنزيله' },
|
||||
saved: { en: 'Saved successfully', ar: 'تم الحفظ بنجاح' },
|
||||
copy: { en: 'Copy', ar: 'نسخ' },
|
||||
copied: { en: 'Copied', ar: 'تم النسخ' },
|
||||
close: { en: 'Close', ar: 'إغلاق' },
|
||||
cancel: { en: 'Cancel', ar: 'إلغاء' },
|
||||
notAvailableYet: { en: 'Not available in the new screen yet', ar: 'غير متاح في الشاشة الجديدة بعد' },
|
||||
blockedForm: {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import DarkModeOutlined from '@mui/icons-material/DarkModeOutlined';
|
|||
import LightModeOutlined from '@mui/icons-material/LightModeOutlined';
|
||||
import TranslateIcon from '@mui/icons-material/Translate';
|
||||
import LogoutIcon from '@mui/icons-material/Logout';
|
||||
import PersonOutline from '@mui/icons-material/PersonOutline';
|
||||
import PersonOutline from '@mui/icons-material/PersonOutlineOutlined';
|
||||
import BusinessOutlined from '@mui/icons-material/BusinessOutlined';
|
||||
import LockOutlined from '@mui/icons-material/LockOutlined';
|
||||
import NavigateNext from '@mui/icons-material/NavigateNext';
|
||||
|
|
@ -36,9 +36,19 @@ function Crumbs() {
|
|||
const section = sectionOf(key);
|
||||
return (
|
||||
<Breadcrumbs separator={<NavigateNext fontSize="small" className="flip-rtl" />} sx={{ '& .MuiBreadcrumbs-li': { fontSize: 13.5 } }}>
|
||||
<Link component={RouterLink} to="/" color="text.secondary" underline="hover">{ui('home')}</Link>
|
||||
{section && <Typography color="text.secondary" fontSize="inherit">{title(section)}</Typography>}
|
||||
<Typography fontSize="inherit" fontWeight={600}>{labelOf(key)}</Typography>
|
||||
<Link component={RouterLink} to="/" underline="hover" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('home')}</Link>
|
||||
{section && <Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
fontSize: "inherit"
|
||||
}}>{title(section)}</Typography>}
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "inherit",
|
||||
fontWeight: 600
|
||||
}}>{labelOf(key)}</Typography>
|
||||
</Breadcrumbs>
|
||||
);
|
||||
}
|
||||
|
|
@ -51,14 +61,30 @@ function Crumbs() {
|
|||
const leaf = view === 'view' ? ui('view') : view === 'create' ? (id ? ui('edit') : ui('new')) : null;
|
||||
return (
|
||||
<Breadcrumbs separator={<NavigateNext fontSize="small" className="flip-rtl" />} sx={{ '& .MuiBreadcrumbs-li': { fontSize: 13.5 } }}>
|
||||
<Link component={RouterLink} to="/" color="text.secondary" underline="hover">{ui('home')}</Link>
|
||||
{section && <Typography color="text.secondary" fontSize="inherit">{title(section)}</Typography>}
|
||||
<Link component={RouterLink} to="/" underline="hover" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{ui('home')}</Link>
|
||||
{section && <Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
fontSize: "inherit"
|
||||
}}>{title(section)}</Typography>}
|
||||
{leaf ? (
|
||||
<Link component={RouterLink} to={`/e/${entity}/grid`} color="text.secondary" underline="hover">{labelOf(entity)}</Link>
|
||||
<Link component={RouterLink} to={`/e/${entity}/grid`} underline="hover" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{labelOf(entity)}</Link>
|
||||
) : (
|
||||
<Typography fontSize="inherit" fontWeight={600}>{labelOf(entity)}</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "inherit",
|
||||
fontWeight: 600
|
||||
}}>{labelOf(entity)}</Typography>
|
||||
)}
|
||||
{leaf && <Typography fontSize="inherit" fontWeight={600}>{leaf}</Typography>}
|
||||
{leaf && <Typography
|
||||
sx={{
|
||||
fontSize: "inherit",
|
||||
fontWeight: 600
|
||||
}}>{leaf}</Typography>}
|
||||
</Breadcrumbs>
|
||||
);
|
||||
}
|
||||
|
|
@ -158,8 +184,12 @@ function Shell() {
|
|||
|
||||
<Menu anchorEl={menuEl} open={!!menuEl} onClose={() => setMenuEl(null)} slotProps={{ paper: { sx: { minWidth: 220 } } }}>
|
||||
<Box sx={{ px: 2, py: 1 }}>
|
||||
<Typography fontWeight={700}>{user?.name}</Typography>
|
||||
<Typography variant="caption" color="text.secondary">{roleLabel(String(user?.job_title ?? user?.role_code ?? ''), t, humanize, isRtl(lang))}</Typography>
|
||||
<Typography sx={{
|
||||
fontWeight: 700
|
||||
}}>{user?.name}</Typography>
|
||||
<Typography variant="caption" sx={{
|
||||
color: "text.secondary"
|
||||
}}>{roleLabel(String(user?.job_title ?? user?.role_code ?? ''), t, humanize, isRtl(lang))}</Typography>
|
||||
</Box>
|
||||
<Divider />
|
||||
{can('GETVIEW') && user && (
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|||
import { Box, Dialog, IconButton, InputAdornment, List, ListItemButton, ListItemText, TextField, Tooltip, Typography } from '@mui/material';
|
||||
import SearchIcon from '@mui/icons-material/Search';
|
||||
import { useUi } from '../i18n';
|
||||
import AddCircleOutline from '@mui/icons-material/AddCircleOutline';
|
||||
import AddCircleOutline from '@mui/icons-material/AddCircleOutlineOutlined';
|
||||
import { newRecordSx } from '../components/newRecordSx';
|
||||
import { useNav } from './NavContext';
|
||||
|
||||
|
|
@ -72,7 +72,11 @@ export function CommandPalette({ open, onClose }: { open: boolean; onClose: () =
|
|||
)}
|
||||
</Box>
|
||||
))}
|
||||
{!results.length && <Typography color="text.secondary" sx={{ p: 2 }}>{ui('noResults')}</Typography>}
|
||||
{!results.length && <Typography
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
p: 2
|
||||
}}>{ui('noResults')}</Typography>}
|
||||
</List>
|
||||
</Dialog>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,16 @@ export function NavProvider({ children }: { children: ReactNode }) {
|
|||
const menu = buildNav(parseMenu(config?.MENU_STRUCTURE_VIEW ?? ''));
|
||||
const dash = buildDashboardSection(user?.dashboard_name, rtl);
|
||||
const extra = buildTopBarSection(config?.AUTHORITY ?? [], new Set(menu.flatMap((s) => s.items.map((i) => i.entity))));
|
||||
const all = extra ? [...menu, extra] : menu;
|
||||
// the entry permit requests screen is the last item of the Permits group
|
||||
const permits = menu.find((s) => s.items.some((i) => i.entity === 'PERMITS'));
|
||||
const entry = extra?.items.find((i) => i.entity === 'FLEET_REQUEST');
|
||||
if (permits && extra && entry) {
|
||||
permits.rows.push({ item: entry });
|
||||
permits.items.push(entry);
|
||||
extra.rows = extra.rows.filter((r) => !('item' in r) || r.item !== entry);
|
||||
extra.items = extra.items.filter((i) => i !== entry);
|
||||
}
|
||||
const all = extra?.items.length ? [...menu, extra] : menu;
|
||||
return dash ? [dash, ...all] : all;
|
||||
}, [config, user, rtl]);
|
||||
const value = useMemo<NavState>(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import ExpandMore from '@mui/icons-material/ExpandMore';
|
|||
import HomeOutlined from '@mui/icons-material/HomeOutlined';
|
||||
import ChevronLeft from '@mui/icons-material/ChevronLeft';
|
||||
import ChevronRight from '@mui/icons-material/ChevronRight';
|
||||
import AddCircleOutline from '@mui/icons-material/AddCircleOutline';
|
||||
import AddCircleOutline from '@mui/icons-material/AddCircleOutlineOutlined';
|
||||
import { newRecordSx } from '../components/newRecordSx';
|
||||
import { useUi } from '../i18n';
|
||||
import { useNav } from './NavContext';
|
||||
|
|
@ -47,8 +47,8 @@ export function Sidebar({ collapsed, onToggle, onNavigate }: { collapsed: boolea
|
|||
{i > 0 && <Divider sx={{ mb: 1 }} />}
|
||||
<Typography
|
||||
variant="caption"
|
||||
fontWeight={800}
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
display: 'block',
|
||||
px: 1.25,
|
||||
py: 0.5,
|
||||
|
|
@ -56,9 +56,8 @@ export function Sidebar({ collapsed, onToggle, onNavigate }: { collapsed: boolea
|
|||
bgcolor: alpha(s.color, 0.14),
|
||||
color: s.color,
|
||||
textTransform: 'uppercase',
|
||||
letterSpacing: '.04em',
|
||||
}}
|
||||
>
|
||||
letterSpacing: '.04em'
|
||||
}}>
|
||||
{headingTitle(r.heading)}
|
||||
</Typography>
|
||||
</Box>
|
||||
|
|
@ -93,7 +92,7 @@ export function Sidebar({ collapsed, onToggle, onNavigate }: { collapsed: boolea
|
|||
onClick={onNavigate}
|
||||
sx={{ py: 0.6, ps: 2.5, pe: 1, mx: 1, justifyContent: 'space-between' }}
|
||||
>
|
||||
<ListItemText primary={labelOf(r.item.entity)} slotProps={{ primary: { fontSize: 14 } }} />
|
||||
<ListItemText primary={labelOf(r.item.entity)} slotProps={{ primary: { sx: { fontSize: 14 } } }} />
|
||||
{r.item.canCreate && (
|
||||
<Tooltip title={ui('new')}>
|
||||
<IconButton
|
||||
|
|
@ -128,7 +127,7 @@ export function Sidebar({ collapsed, onToggle, onNavigate }: { collapsed: boolea
|
|||
<Tooltip title={collapsed ? ui('home') : ''} placement="right">
|
||||
<ListItemButton component={RouterLink} to="/" selected={pathname === '/'} onClick={onNavigate} sx={{ mb: 0.5, justifyContent: collapsed ? 'center' : 'flex-start' }}>
|
||||
<ListItemIcon sx={{ minWidth: 0, width: 28, justifyContent: 'center', marginInlineEnd: collapsed ? 0 : 1.5, color: 'inherit' }}><HomeOutlined sx={{ fontSize: 19 }} /></ListItemIcon>
|
||||
{!collapsed && <ListItemText primary={ui('home')} slotProps={{ primary: { fontWeight: 600 } }} />}
|
||||
{!collapsed && <ListItemText primary={ui('home')} slotProps={{ primary: { sx: { fontWeight: 600 } } }} />}
|
||||
</ListItemButton>
|
||||
</Tooltip>
|
||||
|
||||
|
|
@ -163,7 +162,7 @@ export function Sidebar({ collapsed, onToggle, onNavigate }: { collapsed: boolea
|
|||
</ListItemIcon>
|
||||
{!collapsed && (
|
||||
<>
|
||||
<ListItemText primary={title(s)} slotProps={{ primary: { fontWeight: 600, fontSize: 14.5 } }} />
|
||||
<ListItemText primary={title(s)} slotProps={{ primary: { sx: { fontWeight: 600, fontSize: 14.5 } } }} />
|
||||
<ExpandMore sx={{ transition: 'transform .2s', transform: expanded ? 'rotate(180deg)' : 'none', opacity: 0.6 }} />
|
||||
</>
|
||||
)}
|
||||
|
|
@ -182,9 +181,22 @@ export function Sidebar({ collapsed, onToggle, onNavigate }: { collapsed: boolea
|
|||
|
||||
<Menu anchorEl={pop?.el} open={!!pop} onClose={() => setPop(null)} anchorOrigin={{ vertical: 'top', horizontal: 'right' }} slotProps={{ paper: { sx: { minWidth: 220, maxHeight: '70vh' } } }}>
|
||||
{pop && (
|
||||
<Stack direction="row" alignItems="center" spacing={1} sx={{ px: 2, py: 1, bgcolor: alpha(pop.section.color, 0.12) }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={1}
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
px: 2,
|
||||
py: 1,
|
||||
bgcolor: alpha(pop.section.color, 0.12)
|
||||
}}>
|
||||
<pop.section.icon sx={{ fontSize: 18, color: pop.section.color }} />
|
||||
<Typography variant="subtitle2" fontWeight={800} sx={{ color: pop.section.color }}>{title(pop.section)}</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
color: pop.section.color
|
||||
}}>{title(pop.section)}</Typography>
|
||||
</Stack>
|
||||
)}
|
||||
{pop && renderRows(pop.section, true)}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import LightbulbOutlined from '@mui/icons-material/LightbulbOutlined';
|
|||
import LocalParkingOutlined from '@mui/icons-material/LocalParkingOutlined';
|
||||
import LinkOutlined from '@mui/icons-material/LinkOutlined';
|
||||
import LocalShippingOutlined from '@mui/icons-material/LocalShippingOutlined';
|
||||
import MailOutline from '@mui/icons-material/MailOutline';
|
||||
import MailOutline from '@mui/icons-material/MailOutlineOutlined';
|
||||
import AppRegistrationOutlined from '@mui/icons-material/AppRegistrationOutlined';
|
||||
import CardMembershipOutlined from '@mui/icons-material/CardMembershipOutlined';
|
||||
import FolderOutlined from '@mui/icons-material/FolderOutlined';
|
||||
|
|
@ -85,8 +85,8 @@ export interface NavSection {
|
|||
groupEntity?: string;
|
||||
}
|
||||
|
||||
/** Menu entries the business asked to hide (the goods-tracking service). */
|
||||
export const HIDDEN_ENTITIES = new Set(['FLEET_TRACKING_SERVICES', 'WAITING_PLAN', 'SCHEDULING_PLAN', 'CAPACITY_PLAN_DETAILS']);
|
||||
/** Menu entries the business asked to hide (the goods-tracking service and the logistics platform). */
|
||||
export const HIDDEN_ENTITIES = new Set(['FLEET_TRACKING_SERVICES', 'WAITING_PLAN', 'SCHEDULING_PLAN', 'CAPACITY_PLAN_DETAILS', 'AVAILABLE_ON_PLATFORM', 'AVAILABLE_ON_PLATFORM_SEARCH']);
|
||||
|
||||
/** Entities that leave their own group and sit right after another entity: Permits status (CAPACITY) goes under Fleet permits. */
|
||||
const MOVE_AFTER: Record<string, string> = { CAPACITY: 'PERMITS' };
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@ export function LoginPage() {
|
|||
const [touched, setTouched] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [forgotOpen, setForgotOpen] = useState(false);
|
||||
// the backend ended the session while the user was working: say so once on the login page
|
||||
const [ended] = useState(() => {
|
||||
try {
|
||||
const v = sessionStorage.getItem('mams.sessionEnded') === '1';
|
||||
sessionStorage.removeItem('mams.sessionEnded');
|
||||
return v;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (user) return <Navigate to="/" replace />;
|
||||
// no caption table exists before sign-in, so backend login codes are shown through our own text; wrong user
|
||||
// and wrong password read the same, which also stops the page from telling which usernames exist
|
||||
|
|
@ -102,7 +112,12 @@ export function LoginPage() {
|
|||
<Logo height={52} on="dark" />
|
||||
</Box>
|
||||
<Box sx={{ position: 'relative', maxWidth: 440 }}>
|
||||
<Typography variant="h4" fontWeight={800} sx={{ mb: 2 }}>
|
||||
<Typography
|
||||
variant="h4"
|
||||
sx={{
|
||||
fontWeight: 800,
|
||||
mb: 2
|
||||
}}>
|
||||
{ui('loginWelcome')}
|
||||
</Typography>
|
||||
<Typography sx={{ opacity: 0.9, fontSize: 16, lineHeight: 1.8 }}>{ui('loginTagline')}</Typography>
|
||||
|
|
@ -136,10 +151,13 @@ export function LoginPage() {
|
|||
<Logo height={36} />
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography variant="h5" component="h1" fontWeight={800}>
|
||||
<Typography variant="h5" component="h1" sx={{
|
||||
fontWeight: 800
|
||||
}}>
|
||||
{ui('loginTitle')}
|
||||
</Typography>
|
||||
</Box>
|
||||
{ended && !err && <Alert severity="info">{ui('sessionEnded')}</Alert>}
|
||||
{err && <Alert severity="error">{loginMessage(err)}</Alert>}
|
||||
<TextField
|
||||
label={ui('loginUsername')}
|
||||
|
|
@ -180,7 +198,13 @@ export function LoginPage() {
|
|||
},
|
||||
}}
|
||||
/>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mt: -1 }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
sx={{
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
mt: -1
|
||||
}}>
|
||||
<FormControlLabel
|
||||
control={<Checkbox size="small" checked={remember} onChange={(e) => setRemember(e.target.checked)} />}
|
||||
label={ui('rememberMe')}
|
||||
|
|
@ -194,8 +218,16 @@ export function LoginPage() {
|
|||
{busy ? <CircularProgress size={22} color="inherit" /> : ui('loginSubmit')}
|
||||
</Button>
|
||||
|
||||
<Stack direction="row" spacing={0.5} justifyContent="center" alignItems="center">
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={0.5}
|
||||
sx={{
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<Typography variant="body2" sx={{
|
||||
color: "text.secondary"
|
||||
}}>
|
||||
{ui('newToNafith')}
|
||||
</Typography>
|
||||
<Button size="small" component={RouterLink} to="/register">
|
||||
|
|
@ -208,11 +240,15 @@ export function LoginPage() {
|
|||
</Button>
|
||||
|
||||
<Divider sx={{ pt: 1 }}>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
<Typography variant="caption" sx={{
|
||||
color: "text.secondary"
|
||||
}}>
|
||||
{ui('followUs')}
|
||||
</Typography>
|
||||
</Divider>
|
||||
<Stack direction="row" spacing={1} justifyContent="center">
|
||||
<Stack direction="row" spacing={1} sx={{
|
||||
justifyContent: "center"
|
||||
}}>
|
||||
{SOCIAL_LINKS.map(({ icon: Icon, label, href }) => (
|
||||
<Tooltip key={label} title={label}>
|
||||
<IconButton component="a" href={href} target="_blank" rel="noopener noreferrer" size="small" color="primary">
|
||||
|
|
@ -221,7 +257,12 @@ export function LoginPage() {
|
|||
</Tooltip>
|
||||
))}
|
||||
</Stack>
|
||||
<Typography variant="caption" color="text.secondary" textAlign="center">
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
textAlign: "center"
|
||||
}}>
|
||||
© {new Date().getFullYear()} Nafith@Madayn — {ui('allRightsReserved')}
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
|
|
|||
Loading…
Reference in New Issue