diff --git a/frontend/src/pages/Inventory/DailyControlPage.tsx b/frontend/src/pages/Inventory/DailyControlPage.tsx index 73fb60c..da57d90 100644 --- a/frontend/src/pages/Inventory/DailyControlPage.tsx +++ b/frontend/src/pages/Inventory/DailyControlPage.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from "react"; +import { useMemo, useRef, useState } from "react"; import { useNavigate } from "react-router-dom"; import { Header, PageLayout } from "../../components/layout/Header"; import { useAuthStore } from "../../store/auth"; @@ -90,11 +90,40 @@ export function DailyControlPage() { nm = 1; ny += 1; } - const [gy, gm] = jalaliToGregorian(ny, nm, 1); - setAnchor(new Date(gy, gm - 1, 1)); + // روزِ برگشتی را نگه می‌داریم (ماه شمسی از میانه‌ی ماه میلادی شروع می‌شود: + // مثلاً مهر ۱ = ۲۳ سپتامبر). اگر به‌جای آن روز «۱» استفاده شود، لنگر در + // اولِ ماهِ میلادی می‌نشیند و هنوز در همان ماه شمسی است — دکمه «ماه بعد» + // ظاهراً هیچ کاری نمی‌کند. + const [gy, gm, gd] = jalaliToGregorian(ny, nm, 1); + setAnchor(new Date(gy, gm - 1, gd)); }; const dayTx = txByDay.get(sel) || []; + + // فعال‌سازی ناوبری ماه از چند مسیر (pointerup / click / کیبورد) با حذف + // اجرای تکراری — اگر مرورگر رویداد click را بخورد، pointerup جواب می‌دهد. + const navLast = useRef<{ key: string; at: number }>({ key: "", at: 0 }); + const navFire = (key: string, action: () => void) => { + const now = Date.now(); + if (navLast.current.key === key && now - navLast.current.at < 350) return; + navLast.current = { key, at: now }; + action(); + }; + const navBtnProps = (key: string, action: () => void) => ({ + type: "button" as const, + onPointerUp: (e: React.PointerEvent) => { + e.preventDefault(); + navFire(key, action); + }, + onClick: () => navFire(key, action), + onKeyDown: (e: React.KeyboardEvent) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + navFire(key, action); + } + }, + }); + const withdrawals = dayTx.filter((t) => t.transaction_type === "WITHDRAWAL"); const wGroups = useMemo(() => { const gmap = new Map(); @@ -149,9 +178,9 @@ export function DailyControlPage() {
📅 {monthTitle}
- - - + + +