'use client'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import Link from 'next/link'; import { IRootState } from '@/store'; import { toggleTheme, toggleSidebar, toggleRTL } from '@/store/themeConfigSlice'; import Dropdown from '@/components/dropdown'; import IconMenu from '@/components/icon/icon-menu'; import IconCalendar from '@/components/icon/icon-calendar'; import IconEdit from '@/components/icon/icon-edit'; import IconChatNotification from '@/components/icon/icon-chat-notification'; import IconSearch from '@/components/icon/icon-search'; import IconXCircle from '@/components/icon/icon-x-circle'; import IconSun from '@/components/icon/icon-sun'; import IconMoon from '@/components/icon/icon-moon'; import IconLaptop from '@/components/icon/icon-laptop'; import IconMailDot from '@/components/icon/icon-mail-dot'; import IconArrowLeft from '@/components/icon/icon-arrow-left'; import IconInfoCircle from '@/components/icon/icon-info-circle'; import IconBellBing from '@/components/icon/icon-bell-bing'; import IconUser from '@/components/icon/icon-user'; import IconMail from '@/components/icon/icon-mail'; import IconLockDots from '@/components/icon/icon-lock-dots'; import IconLogout from '@/components/icon/icon-logout'; import IconMenuDashboard from '@/components/icon/menu/icon-menu-dashboard'; import IconCaretDown from '@/components/icon/icon-caret-down'; import IconMenuApps from '@/components/icon/menu/icon-menu-apps'; import IconMenuComponents from '@/components/icon/menu/icon-menu-components'; import IconMenuElements from '@/components/icon/menu/icon-menu-elements'; import IconMenuDatatables from '@/components/icon/menu/icon-menu-datatables'; import IconMenuForms from '@/components/icon/menu/icon-menu-forms'; import IconMenuPages from '@/components/icon/menu/icon-menu-pages'; import IconMenuMore from '@/components/icon/menu/icon-menu-more'; import { usePathname, useRouter } from 'next/navigation'; import { getTranslation } from '@/i18n'; const Header = () => { const pathname = usePathname(); const dispatch = useDispatch(); const router = useRouter(); const { t, i18n } = getTranslation(); useEffect(() => { const selector = document.querySelector('ul.horizontal-menu a[href="' + window.location.pathname + '"]'); if (selector) { const all: any = document.querySelectorAll('ul.horizontal-menu .nav-link.active'); for (let i = 0; i < all.length; i++) { all[0]?.classList.remove('active'); } let allLinks = document.querySelectorAll('ul.horizontal-menu a.active'); for (let i = 0; i < allLinks.length; i++) { const element = allLinks[i]; element?.classList.remove('active'); } selector?.classList.add('active'); const ul: any = selector.closest('ul.sub-menu'); if (ul) { let ele: any = ul.closest('li.menu').querySelectorAll('.nav-link'); if (ele) { ele = ele[0]; setTimeout(() => { ele?.classList.add('active'); }); } } } }, [pathname]); const isRtl = useSelector((state: IRootState) => state.themeConfig.rtlClass) === 'rtl'; const themeConfig = useSelector((state: IRootState) => state.themeConfig); const setLocale = (flag: string) => { if (flag.toLowerCase() === 'ae') { dispatch(toggleRTL('rtl')); } else { dispatch(toggleRTL('ltr')); } router.refresh(); }; function createMarkup(messages: any) { return { __html: messages }; } const [messages, setMessages] = useState([ { id: 1, image: '', title: 'Congratulations!', message: 'Your OS has been updated.', time: '1hr', }, { id: 2, image: '', title: 'Did you know?', message: 'You can switch between artboards.', time: '2hr', }, { id: 3, image: ' ', title: 'Something went wrong!', message: 'Send Reposrt', time: '2days', }, { id: 4, image: ' ', title: 'Warning', message: 'Your password strength is low.', time: '5days', }, ]); const removeMessage = (value: number) => { setMessages(messages.filter((user) => user.id !== value)); }; const [notifications, setNotifications] = useState([ { id: 1, profile: 'user-profile.jpeg', message: 'John Doeinvite you to Prototyping', time: '45 min ago', }, { id: 2, profile: 'profile-34.jpeg', message: 'Adam Nolanmentioned you to UX Basics', time: '9h Ago', }, { id: 3, profile: 'profile-16.jpeg', message: 'Anna MorganUpload a file', time: '9h Ago', }, ]); const removeNotification = (value: number) => { setNotifications(notifications.filter((user) => user.id !== value)); }; const [search, setSearch] = useState(false); return ( TCA dispatch(toggleSidebar())} > {/* */} } > John Doe Pro johndoe@gmail.com Profile Inbox Lock Screen Sign Out {/* horizontal menu */} {t('dashboard')} {t('sales')} {t('analytics')} {t('finance')} {t('crypto')} {t('apps')} {t('chat')} {t('mailbox')} {t('todo_list')} {t('notes')} {t('scrumboard')} {t('contacts')} {t('invoice')} {t('list')} {t('preview')} {t('add')} {t('edit')} {t('calendar')} {t('components')} {t('tabs')} {t('accordions')} {t('modals')} {t('cards')} {t('carousel')} {t('countdown')} {t('counter')} {t('sweet_alerts')} {t('timeline')} {t('notifications')} {t('media_object')} {t('list_group')} {t('pricing_tables')} {t('lightbox')} {t('elements')} {t('alerts')} {t('avatar')} {t('badges')} {t('breadcrumbs')} {t('buttons')} {t('button_groups')} {t('color_library')} {t('dropdown')} {t('infobox')} {t('jumbotron')} {t('loader')} {t('pagination')} {t('popovers')} {t('progress_bar')} {t('search')} {t('tooltips')} {t('treeview')} {t('typography')} {t('tables')} {t('tables')} {t('datatables')} {t('basic')} {t('advanced')} {t('skin')} {t('order_sorting')} {t('multi_column')} {t('multiple_tables')} {t('alt_pagination')} {t('checkbox')} {t('range_search')} {t('export')} {t('column_chooser')} {t('forms')} {t('basic')} {t('input_group')} {t('layouts')} {t('validation')} {t('input_mask')} {t('select2')} {t('touchspin')} {t('checkbox_and_radio')} {t('switches')} {t('wizards')} {t('file_upload')} {t('quill_editor')} {t('markdown_editor')} {t('date_and_range_picker')} {t('clipboard')} {t('pages')} {t('users')} {t('profile')} {t('account_settings')} {t('knowledge_base')} {t('contact_us_boxed')} {t('contact_us_cover')} {t('faq')} {t('coming_soon_boxed')} {t('coming_soon_cover')} {t('maintenence')} {t('error')} {t('404')} {t('500')} {t('503')} {t('login')} {t('login_cover')} {t('login_boxed')} {t('register')} {t('register_cover')} {t('register_boxed')} {t('password_recovery')} {t('recover_id_cover')} {t('recover_id_boxed')} {t('lockscreen')} {t('unlock_cover')} {t('unlock_boxed')} {t('more')} {t('drag_and_drop')} {t('charts')} {t('font_icons')} {t('widgets')} {t('documentation')} ); }; export default Header;