diff --git a/src/pages/notification/Notification.tsx b/src/pages/notification/Notification.tsx index 1cfac9c..bfb519d 100644 --- a/src/pages/notification/Notification.tsx +++ b/src/pages/notification/Notification.tsx @@ -14,6 +14,7 @@ import Button from '../../components/Button'; import { toast } from '../../components/Toast'; // import { useNavigate } from 'react-router-dom'; import { ErrorType } from '../../helpers/types'; +import { useSharedStore } from '@/shared/store/sharedStore'; const Notifications: FC = () => { // const navigate = useNavigate() const { t } = useTranslation(); @@ -22,6 +23,7 @@ const Notifications: FC = () => { const [showModal, setShowModal] = useState(false); const { data, fetchNextPage, hasNextPage, refetch } = useGetNotification(activeTab); const readAll = useReadAll() + const { emailWidth } = useSharedStore() const posts = data?.pages.flatMap((page) => page.data?.notifications) || []; const handleAllRead = () => { @@ -89,7 +91,14 @@ const Notifications: FC = () => { {showModal && ( -
+
0 ? 'xl:left-auto' : 'w-full' + )} + style={emailWidth > 0 && window.innerWidth > 1280 ? { left: `${emailWidth - 50}px` } : {}} + >
{t('notif.natification')}
diff --git a/src/shared/Header.tsx b/src/shared/Header.tsx index 61e2284..22adf82 100644 --- a/src/shared/Header.tsx +++ b/src/shared/Header.tsx @@ -31,8 +31,9 @@ const Header: FC = () => { }) const { t } = useTranslation('global') - const { setOpenSidebar, openSidebar, setOpenReportBug } = useSharedStore() - + const { setOpenSidebar, openSidebar, setOpenReportBug, setEmailWidth } = useSharedStore() + const [popoverButtonRef, setPopoverButtonRef] = useState(null) + const [popoverButtonWidth, setPopoverButtonWidth] = useState(0) const handleSearchChange = (value: string) => { setSearch(value) if (value) { @@ -124,6 +125,19 @@ const Header: FC = () => { setPopoverKey((prevKey) => prevKey + 1) }, [pathname]) + useEffect(() => { + if (popoverButtonRef) { + const rect = popoverButtonRef.getBoundingClientRect(); + setPopoverButtonWidth(rect.width); + console.log('popoverButtonRef width:', rect.width); + console.log('popoverButtonRef height:', rect.height); + console.log('popoverButtonRef dimensions:', { width: rect.width, height: rect.height }); + console.log('Stored width in state:', popoverButtonWidth); + setEmailWidth(rect.width); + } + }, [popoverButtonRef]) + + return (
{/* Desktop Search */} @@ -299,19 +313,21 @@ const Header: FC = () => { { data && ( - -
-
- -
-
-
- {data?.data?.user?.emailAddress} +
+ +
+
+ +
+
+
+ {data?.data?.user?.emailAddress} +
+
-
-
- + +
@@ -354,7 +370,7 @@ const Header: FC = () => { } title={t('sidebar.logout')} - isActive={false} + isActive link={'#'} isWithoutLine isLogout diff --git a/src/shared/store/sharedStore.ts b/src/shared/store/sharedStore.ts index 0cc928e..00ecb49 100644 --- a/src/shared/store/sharedStore.ts +++ b/src/shared/store/sharedStore.ts @@ -12,4 +12,6 @@ export const useSharedStore = create((set) => ({ setDraftData: (draft) => set({ draftData: draft }), editingDraftId: null, setEditingDraftId: (id) => set({ editingDraftId: id }), + emailWidth: 0, + setEmailWidth: (width) => set({ emailWidth: width }), })); diff --git a/src/shared/types/SharedTypes.ts b/src/shared/types/SharedTypes.ts index 2f359da..eb67ff4 100644 --- a/src/shared/types/SharedTypes.ts +++ b/src/shared/types/SharedTypes.ts @@ -11,6 +11,8 @@ export type SharedStoreType = { setDraftData: (draft: DraftMessage | null) => void; editingDraftId: number | null; setEditingDraftId: (id: number | null) => void; + emailWidth: number; + setEmailWidth: (width: number) => void; }; export type MailboxCount = {