'use client' import { Fragment, useState } from 'react' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { useMessage } from '@/hooks/useMessage' import { logout } from '@/lib/authActions' import QSelectBox from '@/components/common/select/QSelectBox' export const ToggleonMouse = (e, act, target) => { const listWrap = e.target.closest(target) const ListItem = Array.from(listWrap.childNodes) ListItem.forEach((el) => { if (act === 'add') { el.classList.add('mouse') } else { el.classList.remove('mouse') } }) if (act === 'add') { e.target.parentElement.classList.remove('mouse') } } export default function Header(props) { const { loginedUserNm } = props const { getMessage } = useMessage() const pathName = usePathname() // if (pathName.includes('login') || pathName.includes('join')) { // return null // } const [selected, setSelected] = useState('') const SelectOptions = [ { id: 0, name: 'オンライン保証シ', link: '' }, { id: 1, name: 'ステム', link: '' }, { id: 2, name: 'TEST1', link: 'https://www.weather.go.kr/w/index.do' }, { id: 3, name: 'TEST2', link: 'https://www.google.com' }, ] const menus = [ { id: 0, name: 'header.menus.home', url: '/', children: [] }, { id: 1, name: 'header.menus.management', url: '', children: [ { id: 3, name: 'header.menus.management.stuff', url: '/management/stuff', children: [] }, { id: 4, name: 'header.menus.management.plan', url: '/floor-plan', children: [] }, ], }, { id: 2, name: 'header.menus.community', url: '', children: [ { id: 5, name: 'header.menus.community.notice', url: '/community/notice', children: [] }, { id: 6, name: 'header.menus.community.faq', url: '/community/faq', children: [] }, { id: 7, name: 'header.menus.community.archive', url: '/community/archive', children: [] }, ], }, ] const onChangeSelect = (option) => { setSelected(option) } const navPage = () => { if (selected.link) { location.href = selected.link } } const getMenuTemplate = (menus) => { return menus.map((menu) => { return (
  • ToggleonMouse(e, 'add', 'nav > ul')} onMouseLeave={(e) => ToggleonMouse(e, 'remove', 'nav > ul')} > {menu.children.length === 0 ? ( {getMessage(menu.name)} ) : ( )}
  • ) }) } return ( !(pathName.includes('login') || pathName.includes('join')) && (

    ) ) }