diff --git a/.env b/.env index 3c55071..0274da7 100644 --- a/.env +++ b/.env @@ -11,3 +11,4 @@ VITE_CONSOLE_URL = 'https://console.danakcorp.com' VITE_WORKSPACE_ID = 'workspace_id' VITE_SERVICE_ID = 'e51afdc3-ea0b-49cf-8f49-2a6f131b024e' +VITE_HELP_URL = 'https://help.danakcorp.com' diff --git a/src/components/RowActionsDropdown.tsx b/src/components/RowActionsDropdown.tsx index 2485924..06aa578 100644 --- a/src/components/RowActionsDropdown.tsx +++ b/src/components/RowActionsDropdown.tsx @@ -13,11 +13,23 @@ interface RowActionsDropdownProps { actions: RowActionItem[]; className?: string; trigger?: React.ReactNode; + topOffset?: number; + leftOffset?: number; + topOffsetMobile?: number; + leftOffsetMobile?: number; } -const RowActionsDropdown: React.FC = ({ actions, className = '', trigger }) => { +const RowActionsDropdown: React.FC = ({ + actions, + className = '', + trigger, + topOffset = 0, + leftOffset = 0, + topOffsetMobile = 0, + leftOffsetMobile = 0 +}) => { const [isOpen, setIsOpen] = useState(false) - const [position, setPosition] = useState({ top: 0, left: 0 }) + const [dropdownPosition, setDropdownPosition] = useState({ top: 0, left: 0 }) const dropdownRef = useRef(null) const buttonRef = useRef(null) @@ -34,31 +46,46 @@ const RowActionsDropdown: React.FC = ({ actions, classN } }, []) + const calculatePosition = (rect: DOMRect) => { + const isMobile = window.innerWidth < 768 + const dropdownWidth = isMobile ? 140 : 150 + const dropdownHeight = actions.length * (isMobile ? 36 : 40) + + // انتخاب offset بر اساس سایز صفحه + const currentTopOffset = isMobile ? topOffsetMobile : topOffset + const currentLeftOffset = isMobile ? leftOffsetMobile : leftOffset + + let left = rect.left + window.scrollX - dropdownWidth + rect.width + currentLeftOffset + let top = rect.bottom + window.scrollY + currentTopOffset + + if (left + dropdownWidth > window.innerWidth) { + left = rect.left + window.scrollX - dropdownWidth + currentLeftOffset + } + + if (left < 0) { + left = isMobile ? 20 : 40 + } + + if (top + dropdownHeight > window.innerHeight + window.scrollY) { + top = rect.top + window.scrollY - dropdownHeight + currentTopOffset + } + + // اطمینان از اینکه dropdown از صفحه خارج نشود + if (left < 0) left = 20 + if (left + dropdownWidth > window.innerWidth) left = window.innerWidth - dropdownWidth - 20 + if (top < 0) top = 20 + if (top + dropdownHeight > window.innerHeight) top = window.innerHeight - dropdownHeight - 20 + + return { top, left } + } + const handleToggle = (e: React.MouseEvent) => { e.stopPropagation() if (!isOpen && buttonRef.current) { const rect = buttonRef.current.getBoundingClientRect() - const isMobile = window.innerWidth < 768 - const dropdownWidth = isMobile ? 140 : 150 - const dropdownHeight = actions.length * (isMobile ? 36 : 40) - - let left = rect.left + window.scrollX - dropdownWidth + rect.width - let top = rect.bottom + window.scrollY - - if (left + dropdownWidth > window.innerWidth) { - left = rect.left + window.scrollX - dropdownWidth - } - - if (left < 0) { - left = isMobile ? 20 : 40 - } - - if (top + dropdownHeight > window.innerHeight + window.scrollY) { - top = rect.top + window.scrollY - dropdownHeight - } - - setPosition({ top, left }) + const calculatedPosition = calculatePosition(rect) + setDropdownPosition(calculatedPosition) } setIsOpen(!isOpen) @@ -75,10 +102,10 @@ const RowActionsDropdown: React.FC = ({ actions, classN return createPortal(
{actions.map((action, index) => ( @@ -106,7 +133,7 @@ const RowActionsDropdown: React.FC = ({ actions, classN aria-expanded={isOpen} > {trigger ? trigger : ( - + )} diff --git a/src/pages/guide/ReportBug.tsx b/src/pages/guide/ReportBug.tsx index 1695d4f..4c4e27c 100644 --- a/src/pages/guide/ReportBug.tsx +++ b/src/pages/guide/ReportBug.tsx @@ -48,7 +48,8 @@ const ReportBug: React.FC = () => { content: description, rating: getRatingFromFeeling(feeling), serviceId: import.meta.env.VITE_SERVICE_ID, - email: data?.data?.user?.emailAddress, + email: data?.data?.user?.email, + phone: data?.data?.user?.phone, }, { onSuccess: () => { toast('گزارش با موفقیت ارسال شد', 'success') diff --git a/src/shared/Header.tsx b/src/shared/Header.tsx index 5417b94..b0544a2 100644 --- a/src/shared/Header.tsx +++ b/src/shared/Header.tsx @@ -71,6 +71,10 @@ const Header: FC = () => { }, ]} trigger={} + topOffset={23} + leftOffset={70} + topOffsetMobile={15} + leftOffsetMobile={70} /> diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index 8e25b7d..93007bd 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -53,7 +53,7 @@ const SideBar: FC = () => {
} + icon={} title={t('setting.dashboard')} isActive={isActive(Paths.home)} link={Paths.home}