This commit is contained in:
2026-03-08 14:27:16 +03:00
parent 66c151653e
commit 11b58b68c3
22 changed files with 4652 additions and 204 deletions

View File

@@ -196,7 +196,8 @@ export function CustomerList({
</div>
) : (
<>
<div className="overflow-x-auto">
{/* Desktop Table View */}
<div className="hidden lg:block overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
@@ -226,6 +227,96 @@ export function CustomerList({
</tbody>
</table>
</div>
{/* Mobile Card View */}
<div className="lg:hidden divide-y divide-gray-200">
{customers.map((customer) => (
<div key={customer.id} className="p-4 hover:bg-gray-50">
<div className="space-y-3">
<div className="flex justify-between items-start">
<div className="flex-1">
<div className="font-medium text-gray-900">{customer.name}</div>
{customer.phone && (
<div className="text-sm text-gray-600 mt-1" dir="ltr">
📞 {customer.phone}
</div>
)}
{customer.email && (
<div className="text-sm text-gray-500 mt-1" dir="ltr">
{customer.email}
</div>
)}
</div>
</div>
{customer.address && (
<div className="text-sm text-gray-600">
<span className="font-medium">العنوان: </span>
{customer.address}
</div>
)}
<div className="flex gap-4 text-sm">
<div>
<span className="font-medium text-gray-700">المركبات: </span>
<span className="text-gray-900">{customer.vehicles.length}</span>
</div>
<div>
<span className="font-medium text-gray-700">الزيارات: </span>
<span className="text-gray-900">{customer.maintenanceVisits.length}</span>
</div>
</div>
<div className="text-xs text-gray-500">
{formatDate(customer.createdDate)}
</div>
<Flex className="flex-wrap gap-2 pt-2">
<Button
size="sm"
variant="outline"
className="bg-blue-50 text-blue-600 border-blue-300 hover:bg-blue-100 flex-1 min-w-[80px]"
disabled={isLoading}
onClick={() => onViewCustomer(customer)}
>
عرض
</Button>
<Button
size="sm"
variant="outline"
onClick={() => onEditCustomer(customer)}
disabled={isLoading}
className="flex-1 min-w-[80px]"
>
تعديل
</Button>
<Form method="post" className="flex-1 min-w-[80px]">
<input type="hidden" name="_action" value="delete" />
<input type="hidden" name="id" value={customer.id} />
<Button
type="submit"
size="sm"
variant="outline"
className="text-red-600 border-red-300 hover:bg-red-50 w-full"
disabled={isLoading || deletingCustomerId === customer.id}
onClick={(e) => {
e.preventDefault();
if (window.confirm("هل أنت متأكد من حذف هذا العميل؟")) {
setDeletingCustomerId(customer.id);
(e.target as HTMLButtonElement).form?.submit();
}
}}
>
{deletingCustomerId === customer.id ? "جاري الحذف..." : "حذف"}
</Button>
</Form>
</Flex>
</div>
</div>
))}
</div>
{/* Pagination */}
{totalPages > 1 && (

View File

@@ -4,6 +4,7 @@ import { Sidebar } from './Sidebar';
import { Container } from './Container';
import { Flex } from './Flex';
import { Text, Button } from '../ui';
import { designTokens } from '~/lib/design-tokens';
interface DashboardLayoutProps {
children: ReactNode;
@@ -12,20 +13,29 @@ interface DashboardLayoutProps {
name: string;
authLevel: number;
};
title?: string; // Optional page title for mobile header
}
export function DashboardLayout({ children, user }: DashboardLayoutProps) {
export function DashboardLayout({ children, user, title }: DashboardLayoutProps) {
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [isMobile, setIsMobile] = useState(false);
const [isClient, setIsClient] = useState(false);
// Set client-side flag
useEffect(() => {
setIsClient(true);
}, []);
// Handle responsive behavior
useEffect(() => {
if (!isClient) return;
const checkMobile = () => {
const mobile = window.innerWidth < 768;
const mobile = window.innerWidth < 768; // md breakpoint
setIsMobile(mobile);
// Auto-collapse sidebar on mobile
// Auto-collapse sidebar on mobile and tablet
if (mobile) {
setSidebarCollapsed(true);
}
@@ -35,15 +45,17 @@ export function DashboardLayout({ children, user }: DashboardLayoutProps) {
window.addEventListener('resize', checkMobile);
return () => window.removeEventListener('resize', checkMobile);
}, []);
}, [isClient]);
// Load sidebar state from localStorage
useEffect(() => {
if (!isClient) return;
const savedState = localStorage.getItem('sidebarCollapsed');
if (savedState !== null && !isMobile) {
setSidebarCollapsed(JSON.parse(savedState));
}
}, [isMobile]);
}, [isMobile, isClient]);
// Save sidebar state to localStorage
const handleSidebarToggle = () => {
@@ -84,66 +96,87 @@ export function DashboardLayout({ children, user }: DashboardLayoutProps) {
/>
{/* Main Content */}
<div className={`
flex-1 min-h-screen transition-all duration-300 ease-in-out
${!isMobile ? (sidebarCollapsed ? 'mr-16' : 'mr-64') : 'mr-0'}
`}>
<div
className="flex-1 min-h-screen transition-all duration-300 ease-out"
style={{
marginRight: isClient ? (isMobile ? '0' : (sidebarCollapsed ? '4rem' : '16rem')) : '16rem'
}}
>
{/* Header */}
<div className="bg-white shadow-sm border-b border-gray-200 sticky top-0 z-10">
<header
className="bg-white shadow-sm border-b border-gray-200 sticky top-0"
style={{ zIndex: designTokens.zIndex.header }}
>
<div className="max-w-full mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between items-center py-4">
{/* Mobile menu button and title */}
<div className="flex items-center gap-4">
{isMobile && (
<button
onClick={() => setMobileMenuOpen(true)}
className="p-2 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
<div className="flex justify-between items-center h-16">
{/* Mobile menu button and title - Always render, hide with CSS */}
<div className="flex items-center gap-3 md:gap-4">
<button
onClick={() => setMobileMenuOpen(true)}
className="md:hidden p-2 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors"
aria-label="فتح القائمة"
aria-expanded={mobileMenuOpen}
>
<svg
className="h-6 w-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
aria-hidden="true"
>
<svg
className="h-6 w-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
</button>
)}
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
</button>
{/* Page title - only show on mobile when sidebar is closed */}
{isMobile && (
<h1 className="text-lg font-semibold text-gray-900">
لوحة التحكم
</h1>
)}
{/* Page title - show on mobile */}
<h1 className="text-base font-bold text-gray-900 md:hidden">
{title || 'لوحة التحكم'}
</h1>
</div>
{/* User info and actions */}
<div className="flex items-center gap-4">
<div className="text-right">
<div className="text-sm text-gray-600">
مرحباً، <span className="font-medium text-gray-900">{user.name}</span>
<div className="flex items-center gap-2 sm:gap-3 md:gap-4">
{/* Desktop: Full user info */}
<div className="hidden lg:block text-right">
<div className="text-sm font-medium text-gray-900">
مرحباً، {user.name}
</div>
<div className="text-xs text-gray-500">
{getAuthLevelText(user.authLevel)}
</div>
</div>
{/* Tablet: Name only */}
<div className="hidden md:block lg:hidden text-right">
<div className="text-sm font-medium text-gray-900">
{user.name}
</div>
</div>
{/* Mobile: Compact display */}
<div className="md:hidden text-right">
<div className="text-xs font-medium text-gray-900">
{user.name}
</div>
</div>
<Form action="/logout" method="post">
<button
type="submit"
className="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors duration-150"
className="inline-flex items-center px-2.5 py-1.5 sm:px-3 sm:py-2 border border-transparent text-xs sm:text-sm leading-4 font-medium rounded-lg text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors duration-150"
aria-label="تسجيل الخروج"
>
<svg
className="h-4 w-4 mr-1"
className="h-4 w-4 sm:mr-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
aria-hidden="true"
>
<path
strokeLinecap="round"
@@ -152,16 +185,16 @@ export function DashboardLayout({ children, user }: DashboardLayoutProps) {
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
/>
</svg>
خروج
<span className="hidden sm:inline">خروج</span>
</button>
</Form>
</div>
</div>
</div>
</div>
</header>
{/* Page Content */}
<main className="flex-1 p-6">
<main className="flex-1 p-4 sm:p-5 md:p-6 lg:p-8">
{children}
</main>
</div>

View File

@@ -5,7 +5,13 @@ interface GridProps {
children: ReactNode;
className?: string;
config?: Partial<LayoutConfig>;
cols?: 1 | 2 | 3 | 4 | 6 | 12;
cols?: 1 | 2 | 3 | 4 | 6 | 12 | {
xs?: 1 | 2 | 3 | 4 | 6 | 12;
sm?: 1 | 2 | 3 | 4 | 6 | 12;
md?: 1 | 2 | 3 | 4 | 6 | 12;
lg?: 1 | 2 | 3 | 4 | 6 | 12;
xl?: 1 | 2 | 3 | 4 | 6 | 12;
};
gap?: 'sm' | 'md' | 'lg' | 'xl';
responsive?: {
sm?: 1 | 2 | 3 | 4 | 6 | 12;
@@ -35,19 +41,45 @@ export function Grid({
};
const gapClasses = {
sm: 'gap-2',
md: 'gap-4',
lg: 'gap-6',
xl: 'gap-8',
sm: 'gap-2 sm:gap-2.5 md:gap-3',
md: 'gap-3 sm:gap-4 md:gap-5 lg:gap-6',
lg: 'gap-4 sm:gap-5 md:gap-6 lg:gap-8',
xl: 'gap-6 sm:gap-7 md:gap-8 lg:gap-10',
};
const responsiveClasses = Object.entries(responsive)
.map(([breakpoint, cols]) => `${breakpoint}:${colsClasses[cols]}`)
.join(' ');
// Handle both old responsive prop and new cols object format
let gridColsClass = '';
if (typeof cols === 'object') {
// New format: cols={{ xs: 1, sm: 2, md: 3, lg: 4 }}
const xs = cols.xs || 1;
const sm = cols.sm || cols.xs || 1;
const md = cols.md || cols.sm || cols.xs || 2;
const lg = cols.lg || cols.md || cols.sm || 3;
const xl = cols.xl || cols.lg || cols.md || 4;
gridColsClass = `
${colsClasses[xs]}
sm:${colsClasses[sm]}
md:${colsClasses[md]}
lg:${colsClasses[lg]}
xl:${colsClasses[xl]}
`;
} else {
// Old format: cols={4} with responsive prop
gridColsClass = colsClasses[cols];
if (Object.keys(responsive).length > 0) {
const responsiveClasses = Object.entries(responsive)
.map(([breakpoint, cols]) => `${breakpoint}:${colsClasses[cols]}`)
.join(' ');
gridColsClass = `${gridColsClass} ${responsiveClasses}`;
}
}
return (
<div
className={`grid-rtl ${colsClasses[cols]} ${gapClasses[gap]} ${responsiveClasses} ${className}`}
className={`grid ${gridColsClass} ${gapClasses[gap]} ${className}`}
dir={layoutConfig.direction}
>
{children}

View File

@@ -1,6 +1,7 @@
import { ReactNode, useState, useEffect } from 'react';
import { ReactNode, useState, useEffect, useRef } from 'react';
import { Link, useLocation } from '@remix-run/react';
import { getResponsiveClasses, defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils';
import { useFocusTrap } from '~/hooks/useFocusTrap';
import { designTokens } from '~/lib/design-tokens';
interface SidebarProps {
isCollapsed: boolean;
@@ -103,112 +104,193 @@ const navigationItems: NavigationItem[] = [
export function Sidebar({ isCollapsed, onToggle, isMobile, isOpen, onClose, userAuthLevel }: SidebarProps) {
const location = useLocation();
const sidebarRef = useRef<HTMLElement>(null);
const [announcement, setAnnouncement] = useState('');
const [isClient, setIsClient] = useState(false);
// Set client-side flag
useEffect(() => {
setIsClient(true);
}, []);
// Filter navigation items based on user auth level
const filteredNavItems = navigationItems.filter(item =>
!item.authLevel || userAuthLevel <= item.authLevel
);
// Close sidebar on route change for mobile
// Enable focus trap for mobile menu when open
useFocusTrap(sidebarRef, isOpen && isClient);
// Close sidebar on route change
useEffect(() => {
if (isMobile && isOpen) {
if (isOpen) {
onClose();
}
}, [location.pathname, isMobile, isOpen, onClose]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.pathname]);
if (isMobile) {
return (
<>
{/* Mobile overlay */}
{isOpen && (
<div
className="fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300"
onClick={onClose}
/>
)}
// Handle Escape key to close mobile menu
useEffect(() => {
if (!isClient) return;
{/* Mobile Sidebar */}
<div className={`
fixed top-0 right-0 h-full w-64 bg-white shadow-lg z-50 transform transition-transform duration-300 ease-in-out
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape' && isOpen) {
onClose();
setAnnouncement('القائمة مغلقة');
}
};
document.addEventListener('keydown', handleEscape);
return () => document.removeEventListener('keydown', handleEscape);
}, [isOpen, onClose, isClient]);
// Announce menu state changes for screen readers
useEffect(() => {
if (isOpen && isClient) {
setAnnouncement('القائمة مفتوحة');
}
}, [isOpen, isClient]);
// Render both mobile and desktop sidebars, use CSS to show/hide
return (
<>
{/* Screen reader announcement */}
<div
role="status"
aria-live="polite"
aria-atomic="true"
className="sr-only"
>
{announcement}
</div>
{/* Mobile overlay - only show on mobile/tablet */}
{isOpen && (
<div
className="fixed inset-0 bg-black/50 backdrop-blur-sm transition-opacity duration-300 md:hidden"
style={{ zIndex: designTokens.zIndex.overlay }}
onClick={onClose}
aria-hidden="true"
/>
)}
{/* Mobile Sidebar - hidden on desktop (md+) */}
<aside
ref={sidebarRef}
className={`
md:hidden
fixed top-0 right-0 h-full w-80 max-w-[85vw] bg-white shadow-2xl
transform transition-transform duration-300 ease-out
${isOpen ? 'translate-x-0' : 'translate-x-full'}
`} dir="rtl">
{/* Mobile Header */}
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200">
<div className="flex items-center">
<div className="h-8 w-8 bg-blue-600 rounded-full flex items-center justify-center">
<svg className="h-5 w-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<h1 className="ml-3 text-lg font-semibold text-gray-900">نظام الصيانة</h1>
</div>
<button
onClick={onClose}
className="p-2 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100"
>
<svg className="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
`}
style={{ zIndex: designTokens.zIndex.sidebar }}
dir="rtl"
role="navigation"
aria-label="القائمة الرئيسية"
aria-hidden={!isOpen}
>
{/* Mobile Header */}
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200 bg-white">
<div className="flex items-center gap-3">
<div className="h-10 w-10 bg-blue-600 rounded-lg flex items-center justify-center flex-shrink-0">
<svg className="h-6 w-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</button>
</div>
<h1 className="text-lg font-bold text-gray-900">نظام الصيانة</h1>
</div>
<button
onClick={onClose}
className="p-2 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors"
aria-label="إغلاق القائمة"
>
<svg className="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
{/* Mobile Navigation */}
<nav className="mt-5 px-2 flex-1 overflow-y-auto">
<div className="space-y-1">
{filteredNavItems.map((item) => {
const isActive = location.pathname === item.href;
return (
{/* Mobile Navigation */}
<nav className="flex-1 overflow-y-auto px-3 py-4" aria-label="القائمة الرئيسية">
<ul className="space-y-1" role="list">
{filteredNavItems.map((item) => {
const isActive = location.pathname === item.href;
return (
<li key={item.name}>
<Link
key={item.name}
to={item.href}
className={`
group flex items-center px-3 py-2 text-sm font-medium rounded-md transition-colors duration-150 relative
${isActive ? 'bg-blue-100 text-blue-900' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}
group flex items-center gap-3 px-3 py-3 text-sm font-medium rounded-lg transition-all duration-150 relative
${isActive
? 'bg-blue-50 text-blue-900 shadow-sm'
: 'text-gray-700 hover:bg-gray-50 hover:text-gray-900'
}
`}
aria-current={isActive ? 'page' : undefined}
>
{isActive && <div className="absolute right-0 top-0 bottom-0 w-1 bg-blue-600 rounded-l-md"></div>}
<div className={`flex-shrink-0 ${isActive ? 'text-blue-600' : 'text-gray-400 group-hover:text-gray-500'}`}>
{isActive && (
<div className="absolute right-0 top-0 bottom-0 w-1 bg-blue-600 rounded-l-md" aria-hidden="true"></div>
)}
<div className={`flex-shrink-0 ${isActive ? 'text-blue-600' : 'text-gray-400 group-hover:text-gray-600'}`}>
{item.icon}
</div>
<span className="ml-3">{item.name}</span>
<span className="flex-1">{item.name}</span>
</Link>
);
})}
</div>
</nav>
</div>
</>
);
}
</li>
);
})}
</ul>
</nav>
// Desktop Sidebar
return (
<div className={`
fixed top-0 right-0 h-full bg-white shadow-lg z-40 transition-all duration-300 ease-in-out
${isCollapsed ? 'w-16' : 'w-64'}
`} dir="rtl">
{/* Mobile Footer */}
<div className="border-t border-gray-200 p-4 bg-gray-50">
<p className="text-xs text-gray-500 text-center">
نظام إدارة صيانة السيارات
</p>
</div>
</aside>
{/* Desktop Sidebar - hidden on mobile/tablet (< md) */}
<aside
className={`
hidden md:block
fixed top-0 right-0 h-full bg-white shadow-lg
transition-all duration-300 ease-out
${isCollapsed ? 'w-16' : 'w-64'}
`}
style={{ zIndex: designTokens.zIndex.sidebar }}
dir="rtl"
role="navigation"
aria-label="القائمة الرئيسية"
>
{/* Desktop Header */}
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200">
<div className="flex items-center flex-1">
<div className="h-8 w-8 bg-blue-600 rounded-full flex items-center justify-center">
<svg className="h-5 w-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200 bg-white">
<div className="flex items-center flex-1 min-w-0">
<div className="h-10 w-10 bg-blue-600 rounded-lg flex items-center justify-center flex-shrink-0">
<svg className="h-6 w-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
{!isCollapsed && (
<h1 className="ml-3 text-lg font-semibold text-gray-900">نظام الصيانة</h1>
<h1 className="mr-3 text-lg font-bold text-gray-900 truncate">نظام الصيانة</h1>
)}
</div>
<button
onClick={onToggle}
className="p-1 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
onClick={() => {
onToggle();
setAnnouncement(isCollapsed ? 'القائمة موسعة' : 'القائمة مطوية');
}}
className="p-2 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors flex-shrink-0"
aria-label={isCollapsed ? 'توسيع القائمة' : 'طي القائمة'}
aria-expanded={!isCollapsed}
>
<svg
className={`h-4 w-4 transform transition-transform duration-200 ${isCollapsed ? 'rotate-180' : ''}`}
className={`h-5 w-5 transform transition-transform duration-200 ${isCollapsed ? 'rotate-180' : ''}`}
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
aria-hidden="true"
>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
</svg>
@@ -216,42 +298,51 @@ export function Sidebar({ isCollapsed, onToggle, isMobile, isOpen, onClose, user
</div>
{/* Desktop Navigation */}
<nav className="mt-5 px-2 flex-1 overflow-y-auto">
<div className="space-y-1">
<nav className="flex-1 overflow-y-auto px-2 py-4" aria-label="القائمة الرئيسية">
<ul className="space-y-1" role="list">
{filteredNavItems.map((item) => {
const isActive = location.pathname === item.href;
return (
<Link
key={item.name}
to={item.href}
className={`
group flex items-center px-3 py-2 text-sm font-medium rounded-md transition-colors duration-150 relative
${isActive ? 'bg-blue-100 text-blue-900' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}
${isCollapsed ? 'justify-center' : ''}
`}
title={isCollapsed ? item.name : undefined}
>
{isActive && <div className="absolute right-0 top-0 bottom-0 w-1 bg-blue-600 rounded-l-md"></div>}
<div className={`flex-shrink-0 ${isActive ? 'text-blue-600' : 'text-gray-400 group-hover:text-gray-500'}`}>
{item.icon}
</div>
{!isCollapsed && (
<span className="ml-3 truncate">{item.name}</span>
)}
</Link>
<li key={item.name}>
<Link
to={item.href}
className={`
group flex items-center gap-3 px-3 py-3 text-sm font-medium rounded-lg transition-all duration-150 relative
${isActive
? 'bg-blue-50 text-blue-900 shadow-sm'
: 'text-gray-700 hover:bg-gray-50 hover:text-gray-900'
}
${isCollapsed ? 'justify-center' : ''}
`}
title={isCollapsed ? item.name : undefined}
aria-label={isCollapsed ? item.name : undefined}
aria-current={isActive ? 'page' : undefined}
>
{isActive && !isCollapsed && (
<div className="absolute right-0 top-0 bottom-0 w-1 bg-blue-600 rounded-l-md" aria-hidden="true"></div>
)}
<div className={`flex-shrink-0 ${isActive ? 'text-blue-600' : 'text-gray-400 group-hover:text-gray-600'}`}>
{item.icon}
</div>
{!isCollapsed && (
<span className="flex-1 truncate">{item.name}</span>
)}
</Link>
</li>
);
})}
</div>
</ul>
</nav>
{/* Desktop Footer */}
{!isCollapsed && (
<div className="absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200">
<div className="text-xs text-gray-500 text-center">
<div className="border-t border-gray-200 p-4 bg-gray-50">
<p className="text-xs text-gray-500 text-center">
نظام إدارة صيانة السيارات
</div>
</p>
</div>
)}
</div>
</aside>
</>
);
}

View File

@@ -214,11 +214,130 @@ export function MaintenanceVisitList({
</p>
</div>
) : (
<DataTable
data={visits}
columns={columns}
emptyMessage="لم يتم العثور على أي زيارات صيانة"
/>
<>
{/* Desktop Table View */}
<div className="hidden lg:block">
<DataTable
data={visits}
columns={columns}
emptyMessage="لم يتم العثور على أي زيارات صيانة"
/>
</div>
{/* Mobile Card View */}
<div className="lg:hidden divide-y divide-gray-200">
{visits.map((visit) => {
let jobs;
try {
jobs = JSON.parse(visit.maintenanceJobs);
} catch {
jobs = [];
}
return (
<div key={visit.id} className="p-4 hover:bg-gray-50">
<div className="space-y-3">
<div className="flex justify-between items-start">
<div className="flex-1">
<Text weight="medium" className="text-gray-900">
{formatDate(visit.visitDate)}
</Text>
<Text size="sm" color="secondary">
{formatDateTime(visit.visitDate).split(' ')[1]}
</Text>
</div>
<span className={`inline-flex px-2 py-1 text-xs font-medium rounded-full ${getPaymentStatusColor(visit.paymentStatus)}`}>
{PAYMENT_STATUS_NAMES[visit.paymentStatus as keyof typeof PAYMENT_STATUS_NAMES]}
</span>
</div>
<div className="space-y-2">
<div>
<Text size="sm" color="secondary">المركبة</Text>
<Text weight="medium">{visit.vehicle.plateNumber}</Text>
<Text size="sm" color="secondary">
{visit.vehicle.manufacturer} {visit.vehicle.model} ({visit.vehicle.year})
</Text>
</div>
<div>
<Text size="sm" color="secondary">العميل</Text>
<Text weight="medium">{visit.customer.name}</Text>
{visit.customer.phone && (
<Text size="sm" color="secondary">{visit.customer.phone}</Text>
)}
</div>
<div>
<Text size="sm" color="secondary">أعمال الصيانة</Text>
<Text weight="medium">
{jobs.length > 1 ? `${jobs.length} أعمال صيانة` : jobs[0]?.job || 'غير محدد'}
</Text>
{visit.description && (
<Text size="sm" color="secondary" className="line-clamp-2">
{visit.description}
</Text>
)}
</div>
<div className="grid grid-cols-2 gap-2">
<div>
<Text size="sm" color="secondary">التكلفة</Text>
<Text weight="medium" className="font-mono">
{formatCurrency(visit.cost)}
</Text>
</div>
<div>
<Text size="sm" color="secondary">الكيلومترات</Text>
<Text className="font-mono">
{formatNumber(visit.kilometers)} كم
</Text>
</div>
</div>
</div>
<div className="flex gap-2 pt-2">
{onView ? (
<Button
size="sm"
variant="outline"
onClick={() => onView(visit)}
className="flex-1"
>
عرض
</Button>
) : (
<Link to={`/maintenance-visits/${visit.id}`} className="flex-1">
<Button size="sm" variant="outline" className="w-full">
عرض
</Button>
</Link>
)}
{onEdit && (
<Button
size="sm"
variant="outline"
onClick={() => onEdit(visit)}
className="flex-1"
>
تعديل
</Button>
)}
<Button
size="sm"
variant="outline"
className="text-red-600 border-red-300 hover:bg-red-50 flex-1"
onClick={() => handleDelete(visit.id)}
>
حذف
</Button>
</div>
</div>
</div>
);
})}
</div>
</>
)}
</div>

View File

@@ -184,12 +184,95 @@ export const UserList = memo(function UserList({
return (
<>
<DataTable
data={users}
columns={columns}
loading={loading}
emptyMessage="لا توجد مستخدمين"
/>
{/* Desktop Table View */}
<div className="hidden md:block">
<DataTable
data={users}
columns={columns}
loading={loading}
emptyMessage="لا توجد مستخدمين"
/>
</div>
{/* Mobile Card View */}
<div className="md:hidden divide-y divide-gray-200">
{users.map((user) => {
const levelName = getAuthLevelName(user.authLevel);
const statusName = getStatusName(user.status);
const levelColorClass = user.authLevel === AUTH_LEVELS.SUPERADMIN
? 'text-purple-600 bg-purple-100'
: user.authLevel === AUTH_LEVELS.ADMIN
? 'text-blue-600 bg-blue-100'
: 'text-gray-600 bg-gray-100';
const statusColorClass = user.status === 'active'
? 'text-green-600 bg-green-100'
: 'text-red-600 bg-red-100';
return (
<div key={user.id} className="p-4 hover:bg-gray-50">
<div className="space-y-3">
<div className="flex justify-between items-start">
<div className="flex-1 min-w-0">
<Text weight="medium" className="truncate">{user.name}</Text>
<Text size="sm" color="secondary" className="truncate">@{user.username}</Text>
{user.email && (
<Text size="sm" color="secondary" className="truncate mt-1">{user.email}</Text>
)}
</div>
</div>
<div className="flex gap-2">
<span className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${levelColorClass}`}>
{levelName}
</span>
<span className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${statusColorClass}`}>
{statusName}
</span>
</div>
<Text size="sm" color="secondary">
{formatDate(user.createdDate)}
</Text>
<div className="flex flex-wrap gap-2 pt-2">
{canEditUser(user) && (
<Button
size="sm"
variant="outline"
onClick={() => onEdit(user)}
className="flex-1 min-w-[80px]"
>
تعديل
</Button>
)}
{canEditUser(user) && (
<Button
size="sm"
variant="outline"
onClick={() => handleStatusClick(user)}
className="flex-1 min-w-[100px]"
>
{user.status === 'active' ? 'إلغاء تفعيل' : 'تفعيل'}
</Button>
)}
{canDeleteUser(user) && (
<Button
size="sm"
variant="danger"
onClick={() => handleDeleteClick(user)}
className="flex-1 min-w-[80px]"
>
حذف
</Button>
)}
</div>
</div>
</div>
);
})}
</div>
{totalPages > 1 && (
<div className="mt-6">

View File

@@ -249,12 +249,140 @@ export function VehicleList({
</p>
</div>
) : (
<DataTable
data={vehicles}
columns={columns}
loading={isLoading}
emptyMessage="لم يتم العثور على أي مركبات"
/>
<>
{/* Desktop Table View */}
<div className="hidden lg:block">
<DataTable
data={vehicles}
columns={columns}
loading={isLoading}
emptyMessage="لم يتم العثور على أي مركبات"
/>
</div>
{/* Mobile Card View */}
<div className="lg:hidden divide-y divide-gray-200">
{vehicles.map((vehicle) => (
<div key={vehicle.id} className="p-4 hover:bg-gray-50">
<div className="space-y-3">
<div className="flex justify-between items-start">
<div className="flex-1">
<Link
to={`/vehicles/${vehicle.id}`}
className="font-mono text-lg font-medium text-blue-600 hover:text-blue-800"
>
{vehicle.plateNumber}
</Link>
<div className="text-sm font-medium text-gray-900 mt-1">
{vehicle.manufacturer} {vehicle.model} ({vehicle.year})
</div>
{vehicle.trim && (
<div className="text-sm text-gray-500">
فئة: {vehicle.trim}
</div>
)}
</div>
</div>
<div className="grid grid-cols-2 gap-2 text-sm">
<div>
<span className="text-gray-600">النوع: </span>
<span className="text-gray-900">{getBodyTypeLabel(vehicle.bodyType)}</span>
</div>
<div>
<span className="text-gray-600">الوقود: </span>
<span className="text-gray-900">{getFuelLabel(vehicle.fuel)}</span>
</div>
<div>
<span className="text-gray-600">ناقل الحركة: </span>
<span className="text-gray-900">{getTransmissionLabel(vehicle.transmission)}</span>
</div>
<div>
<span className="text-gray-600">الاستخدام: </span>
<span className="text-gray-900">{getUseTypeLabel(vehicle.useType)}</span>
</div>
</div>
<div className="text-sm">
<Link
to={`/customers/${vehicle.owner.id}`}
className="font-medium text-blue-600 hover:text-blue-800"
>
المالك: {vehicle.owner.name}
</Link>
{vehicle.owner.phone && (
<div className="text-gray-500 mt-1" dir="ltr">
{vehicle.owner.phone}
</div>
)}
</div>
{vehicle.lastVisitDate && (
<div className="text-sm text-gray-600">
آخر زيارة: {formatDate(vehicle.lastVisitDate)}
</div>
)}
<Flex className="flex-wrap gap-2 pt-2">
{onViewVehicle ? (
<Button
size="sm"
variant="outline"
onClick={() => onViewVehicle(vehicle)}
disabled={isLoading}
className="flex-1 min-w-[80px]"
>
عرض
</Button>
) : (
<Link to={`/vehicles/${vehicle.id}`} className="flex-1 min-w-[80px]">
<Button
size="sm"
variant="outline"
disabled={isLoading}
className="w-full"
>
عرض
</Button>
</Link>
)}
<Button
size="sm"
variant="outline"
onClick={() => onEditVehicle(vehicle)}
disabled={isLoading}
className="flex-1 min-w-[80px]"
>
تعديل
</Button>
<Form method="post" className="flex-1 min-w-[80px]">
<input type="hidden" name="_action" value="delete" />
<input type="hidden" name="id" value={vehicle.id} />
<Button
type="submit"
size="sm"
variant="outline"
className="text-red-600 border-red-300 hover:bg-red-50 w-full"
disabled={isLoading || deletingVehicleId === vehicle.id}
onClick={(e) => {
e.preventDefault();
if (window.confirm("هل أنت متأكد من حذف هذه المركبة؟")) {
setDeletingVehicleId(vehicle.id);
(e.target as HTMLButtonElement).form?.submit();
}
}}
>
{deletingVehicleId === vehicle.id ? "جاري الحذف..." : "حذف"}
</Button>
</Form>
</Flex>
</div>
</div>
))}
</div>
</>
)}
</div>

63
app/hooks/useFocusTrap.ts Normal file
View File

@@ -0,0 +1,63 @@
import { useEffect, RefObject } from 'react';
/**
* Hook to trap focus within a container element
* Useful for modals, drawers, and overlays
*
* @param containerRef - Reference to the container element
* @param isActive - Whether the focus trap is active
*/
export function useFocusTrap(
containerRef: RefObject<HTMLElement>,
isActive: boolean
) {
useEffect(() => {
if (!isActive || !containerRef.current) return;
const container = containerRef.current;
// Get all focusable elements
const focusableElements = container.querySelectorAll<HTMLElement>(
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
);
if (focusableElements.length === 0) return;
const firstElement = focusableElements[0];
const lastElement = focusableElements[focusableElements.length - 1];
// Store the element that had focus before the trap
const previouslyFocusedElement = document.activeElement as HTMLElement;
// Focus the first element
firstElement.focus();
const handleTabKey = (e: KeyboardEvent) => {
if (e.key !== 'Tab') return;
if (e.shiftKey) {
// Shift + Tab
if (document.activeElement === firstElement) {
e.preventDefault();
lastElement.focus();
}
} else {
// Tab
if (document.activeElement === lastElement) {
e.preventDefault();
firstElement.focus();
}
}
};
container.addEventListener('keydown', handleTabKey);
// Cleanup: restore focus to previously focused element
return () => {
container.removeEventListener('keydown', handleTabKey);
if (previouslyFocusedElement) {
previouslyFocusedElement.focus();
}
};
}, [containerRef, isActive]);
}

View File

@@ -0,0 +1,76 @@
import { useState, useEffect } from 'react';
/**
* Hook to detect media query matches
* @param query - CSS media query string
* @returns boolean indicating if the query matches
*/
export function useMediaQuery(query: string): boolean {
const [matches, setMatches] = useState(false);
useEffect(() => {
const mediaQuery = window.matchMedia(query);
// Set initial value
setMatches(mediaQuery.matches);
// Create event listener
const handler = (event: MediaQueryListEvent) => {
setMatches(event.matches);
};
// Add listener
mediaQuery.addEventListener('change', handler);
// Cleanup
return () => mediaQuery.removeEventListener('change', handler);
}, [query]);
return matches;
}
/**
* Hook to detect current breakpoint
* @returns current breakpoint name
*/
export function useBreakpoint() {
const isXs = useMediaQuery('(max-width: 639px)');
const isSm = useMediaQuery('(min-width: 640px) and (max-width: 767px)');
const isMd = useMediaQuery('(min-width: 768px) and (max-width: 1023px)');
const isLg = useMediaQuery('(min-width: 1024px) and (max-width: 1279px)');
const isXl = useMediaQuery('(min-width: 1280px) and (max-width: 1535px)');
const is2Xl = useMediaQuery('(min-width: 1536px)');
if (isXs) return 'xs';
if (isSm) return 'sm';
if (isMd) return 'md';
if (isLg) return 'lg';
if (isXl) return 'xl';
if (is2Xl) return '2xl';
return 'lg'; // default
}
/**
* Hook to detect if viewport is mobile size
* @returns boolean indicating if viewport is mobile
*/
export function useIsMobile(): boolean {
return useMediaQuery('(max-width: 767px)');
}
/**
* Hook to detect if viewport is tablet size
* @returns boolean indicating if viewport is tablet
*/
export function useIsTablet(): boolean {
return useMediaQuery('(min-width: 768px) and (max-width: 1023px)');
}
/**
* Hook to detect if viewport is desktop size
* @returns boolean indicating if viewport is desktop
*/
export function useIsDesktop(): boolean {
return useMediaQuery('(min-width: 1024px)');
}

67
app/lib/design-tokens.ts Normal file
View File

@@ -0,0 +1,67 @@
/**
* Design Tokens
* Centralized design system constants for consistent UI/UX
*/
export const designTokens = {
// Breakpoints (in pixels)
breakpoints: {
xs: 320,
sm: 640,
md: 768,
lg: 1024,
xl: 1280,
'2xl': 1536,
'3xl': 1920,
},
// Sidebar dimensions
sidebar: {
collapsed: 64,
expanded: 256,
mobile: 320,
},
// Z-index scale
zIndex: {
base: 0,
dropdown: 10,
sticky: 20,
overlay: 40, // Overlay below sidebar
sidebar: 50, // Sidebar above overlay
header: 60, // Header above sidebar
modal: 70, // Modal above everything
toast: 80, // Toast at the top
},
// Animation durations (in milliseconds)
animation: {
fast: 150,
normal: 300,
slow: 500,
},
// Spacing scale (in pixels)
spacing: {
mobile: 16,
tablet: 24,
desktop: 32,
wide: 40,
},
// Touch target minimum size
touchTarget: {
min: 44,
},
// Container max widths
container: {
sm: 640,
md: 768,
lg: 1024,
xl: 1280,
'2xl': 1536,
},
} as const;
export type DesignTokens = typeof designTokens;

View File

@@ -443,26 +443,137 @@ export default function ExpensesPage() {
</div>
{/* Action Messages */}
{actionData?.success && actionData.message && (
{actionData?.success && 'message' in actionData && actionData.message && (
<div className="bg-green-50 border border-green-200 text-green-800 px-4 py-3 rounded-lg">
{actionData.message}
</div>
)}
{actionData?.error && (
{actionData && !actionData.success && 'error' in actionData && actionData.error && (
<div className="bg-red-50 border border-red-200 text-red-800 px-4 py-3 rounded-lg">
{actionData.error}
</div>
)}
{/* Expenses Table */}
<DataTable
data={expenses}
columns={columns}
currentPage={currentPage}
totalPages={totalPages}
onPageChange={handlePageChange}
/>
<div className="bg-white rounded-lg shadow-sm border">
{expenses.length === 0 ? (
<div className="text-center py-12">
<div className="text-gray-400 text-lg mb-2">💰</div>
<h3 className="text-lg font-medium text-gray-900 mb-2">
لا توجد مصروفات
</h3>
<p className="text-gray-500">
لم يتم العثور على أي مصروفات.
</p>
</div>
) : (
<>
{/* Desktop Table View */}
<div className="hidden md:block">
<DataTable
data={expenses as any}
columns={columns}
emptyMessage="لم يتم العثور على أي مصروفات"
/>
</div>
{/* Mobile Card View */}
<div className="md:hidden divide-y divide-gray-200">
{expenses.map((expense: any) => {
const categoryLabel = EXPENSE_CATEGORIES.find(c => c.value === expense.category)?.label;
return (
<div key={expense.id} className="p-4 hover:bg-gray-50">
<div className="space-y-3">
<div className="flex justify-between items-start">
<div className="flex-1">
<div className="font-medium text-gray-900">{expense.description}</div>
<div className="text-sm text-gray-500 mt-1">{categoryLabel || expense.category}</div>
</div>
<div className="text-lg font-semibold text-gray-900">
{formatCurrency(expense.amount)}
</div>
</div>
<div className="grid grid-cols-2 gap-2 text-sm">
<div>
<span className="text-gray-600">تاريخ المصروف: </span>
<span className="text-gray-900">{formatDate(expense.expenseDate)}</span>
</div>
<div>
<span className="text-gray-600">تاريخ الإضافة: </span>
<span className="text-gray-900">{formatDate(expense.createdDate)}</span>
</div>
</div>
<div className="pt-2">
<Button
variant="outline"
size="sm"
onClick={() => handleEditExpense(expense)}
disabled={isLoading}
className="w-full"
>
تعديل
</Button>
</div>
</div>
</div>
);
})}
</div>
</>
)}
{/* Pagination */}
{totalPages > 1 && (
<div className="px-4 py-3 border-t border-gray-200 bg-gray-50">
<div className="flex items-center justify-between">
<div className="flex items-center space-x-2 space-x-reverse">
<button
onClick={() => handlePageChange(currentPage - 1)}
disabled={currentPage === 1 || isLoading}
className="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
>
السابق
</button>
<div className="flex items-center space-x-1 space-x-reverse">
{Array.from({ length: Math.min(5, totalPages) }, (_, i) => {
const page = i + 1;
return (
<button
key={page}
onClick={() => handlePageChange(page)}
disabled={isLoading}
className={`px-3 py-2 text-sm font-medium rounded-md ${
currentPage === page
? 'bg-blue-600 text-white'
: 'text-gray-500 bg-white border border-gray-300 hover:bg-gray-50'
} disabled:opacity-50 disabled:cursor-not-allowed`}
>
{page}
</button>
);
})}
</div>
<button
onClick={() => handlePageChange(currentPage + 1)}
disabled={currentPage === totalPages || isLoading}
className="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
>
التالي
</button>
</div>
<p className="text-sm text-gray-500">
صفحة {currentPage} من {totalPages}
</p>
</div>
</div>
)}
</div>
{/* Create Expense Modal */}
<Modal
@@ -472,7 +583,7 @@ export default function ExpensesPage() {
>
<ExpenseForm
onCancel={() => setShowCreateModal(false)}
errors={actionData?.action === "create" ? actionData.errors : undefined}
errors={actionData && 'errors' in actionData ? actionData.errors : undefined}
isLoading={isLoading}
/>
</Modal>
@@ -487,7 +598,7 @@ export default function ExpensesPage() {
<ExpenseForm
expense={selectedExpense}
onCancel={() => setShowEditModal(false)}
errors={actionData?.action === "update" ? actionData.errors : undefined}
errors={actionData && 'errors' in actionData ? actionData.errors : undefined}
isLoading={isLoading}
/>
)}

View File

@@ -258,17 +258,17 @@ export default function FinancialReportsPage() {
{/* Charts and Breakdowns */}
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
{/* Income by Maintenance Type */}
<div className="bg-white p-6 rounded-lg shadow">
<h2 className="text-lg font-semibold text-gray-900 mb-4">الإيرادات حسب نوع الصيانة</h2>
<div className="bg-white p-4 sm:p-6 rounded-lg shadow">
<h2 className="text-base sm:text-lg font-semibold text-gray-900 mb-4">الإيرادات حسب نوع الصيانة</h2>
<div className="space-y-3">
{incomeByType.map((item, index) => (
<div key={index} className="flex items-center justify-between">
<div className="flex-1">
<div className="flex justify-between items-center mb-1">
<span className="text-sm font-medium text-gray-700">
<span className="text-xs sm:text-sm font-medium text-gray-700">
{item.category}
</span>
<span className="text-sm text-gray-500">
<span className="text-xs sm:text-sm text-gray-500">
{item.percentage.toFixed(1)}%
</span>
</div>
@@ -279,7 +279,7 @@ export default function FinancialReportsPage() {
></div>
</div>
<div className="flex justify-between items-center mt-1">
<span className="text-sm font-semibold text-gray-900">
<span className="text-xs sm:text-sm font-semibold text-gray-900">
{formatCurrency(item.amount)}
</span>
<span className="text-xs text-gray-500">
@@ -293,17 +293,17 @@ export default function FinancialReportsPage() {
</div>
{/* Expense Breakdown */}
<div className="bg-white p-6 rounded-lg shadow">
<h2 className="text-lg font-semibold text-gray-900 mb-4">تفصيل المصروفات</h2>
<div className="bg-white p-4 sm:p-6 rounded-lg shadow">
<h2 className="text-base sm:text-lg font-semibold text-gray-900 mb-4">تفصيل المصروفات</h2>
<div className="space-y-3">
{expenseBreakdown.map((item, index) => (
<div key={index} className="flex items-center justify-between">
<div className="flex-1">
<div className="flex justify-between items-center mb-1">
<span className="text-sm font-medium text-gray-700">
<span className="text-xs sm:text-sm font-medium text-gray-700">
{item.category}
</span>
<span className="text-sm text-gray-500">
<span className="text-xs sm:text-sm text-gray-500">
{item.percentage.toFixed(1)}%
</span>
</div>
@@ -314,7 +314,7 @@ export default function FinancialReportsPage() {
></div>
</div>
<div className="flex justify-between items-center mt-1">
<span className="text-sm font-semibold text-gray-900">
<span className="text-xs sm:text-sm font-semibold text-gray-900">
{formatCurrency(item.amount)}
</span>
<span className="text-xs text-gray-500">
@@ -331,24 +331,24 @@ export default function FinancialReportsPage() {
{/* Top Customers and Monthly Data */}
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
{/* Top Customers */}
<div className="bg-white p-6 rounded-lg shadow">
<h2 className="text-lg font-semibold text-gray-900 mb-4">أفضل العملاء</h2>
<div className="bg-white p-4 sm:p-6 rounded-lg shadow">
<h2 className="text-base sm:text-lg font-semibold text-gray-900 mb-4">أفضل العملاء</h2>
<div className="space-y-3">
{topCustomers.map((customer, index) => (
<div key={customer.customerId} className="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
<div className="flex items-center space-x-3 space-x-reverse">
<div className="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center">
<div className="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center flex-shrink-0">
<span className="text-sm font-semibold text-blue-600">
{index + 1}
</span>
</div>
<div>
<p className="font-medium text-gray-900">{customer.customerName}</p>
<p className="text-sm text-gray-500">{customer.visitCount} زيارة</p>
<div className="min-w-0 flex-1">
<p className="font-medium text-gray-900 truncate">{customer.customerName}</p>
<p className="text-xs sm:text-sm text-gray-500">{customer.visitCount} زيارة</p>
</div>
</div>
<div className="text-left">
<p className="font-semibold text-gray-900">
<div className="text-left flex-shrink-0 mr-2">
<p className="text-sm sm:text-base font-semibold text-gray-900">
{formatCurrency(customer.totalRevenue)}
</p>
</div>
@@ -358,20 +358,20 @@ export default function FinancialReportsPage() {
</div>
{/* Monthly Performance */}
<div className="bg-white p-6 rounded-lg shadow">
<h2 className="text-lg font-semibold text-gray-900 mb-4">الأداء الشهري</h2>
<div className="bg-white p-4 sm:p-6 rounded-lg shadow">
<h2 className="text-base sm:text-lg font-semibold text-gray-900 mb-4">الأداء الشهري</h2>
<div className="space-y-3 max-h-96 overflow-y-auto">
{monthlyData.slice(-6).reverse().map((month, index) => (
<div key={`${month.year}-${month.month}`} className="p-3 bg-gray-50 rounded-lg">
<div className="flex justify-between items-center mb-2">
<span className="font-medium text-gray-900">
<span className="text-sm sm:text-base font-medium text-gray-900">
{getArabicMonthName(month.month)} {month.year}
</span>
<span className={`font-semibold ${month.profit >= 0 ? 'text-green-600' : 'text-red-600'}`}>
<span className={`text-sm sm:text-base font-semibold ${month.profit >= 0 ? 'text-green-600' : 'text-red-600'}`}>
{formatCurrency(month.profit)}
</span>
</div>
<div className="grid grid-cols-2 gap-4 text-sm">
<div className="grid grid-cols-2 gap-2 sm:gap-4 text-xs sm:text-sm">
<div>
<span className="text-gray-600">الإيرادات: </span>
<span className="font-medium text-green-600">