1
1
'use client' ;
2
2
3
3
import { useMutation , useQuery , useQueryClient } from '@tanstack/react-query' ;
4
- import { usePathname } from 'next/navigation' ;
4
+ import { usePathname , useRouter } from 'next/navigation' ;
5
5
import { useEffect , useRef , useState } from 'react' ;
6
6
import Image from 'next/image' ;
7
7
import { revalidate } from '@/utils/revalidateUtil' ;
@@ -33,7 +33,8 @@ export const Header = () => {
33
33
const { open : ModalOpen } = useModal ( ) ;
34
34
const menu = useRef < HTMLDivElement | null > ( null ) ;
35
35
const path = usePathname ( ) ;
36
- const { replace } = useCustomNavigation ( ) ;
36
+ const { replace, start } = useCustomNavigation ( ) ;
37
+ const { replace : replaceWithoutLoading } = useRouter ( ) ;
37
38
const width = useResponsive ( ) ;
38
39
const barWidth = width < SCREENS . MBI ? 65 : 180 ;
39
40
const client = useQueryClient ( ) ;
@@ -57,10 +58,7 @@ export const Header = () => {
57
58
58
59
useEffect ( ( ) => {
59
60
const handleClickOutside = ( e : MouseEvent ) =>
60
- open &&
61
- menu . current &&
62
- ! menu . current . contains ( e . target as HTMLElement ) &&
63
- setOpen ( false ) ;
61
+ open && menu . current && ! menu . current . contains ( e . target as HTMLElement ) && setOpen ( false ) ;
64
62
65
63
document . addEventListener ( 'mousedown' , handleClickOutside ) ;
66
64
return ( ) => document . removeEventListener ( 'mousedown' , handleClickOutside ) ;
@@ -69,20 +67,9 @@ export const Header = () => {
69
67
return (
70
68
< nav className = "w-full max-MBI:flex max-MBI:justify-center" >
71
69
< div className = "flex w-fit" >
72
- < Section
73
- clickType = "function"
74
- action = { ( ) => replace ( `/main${ PARAMS . MAIN } ` ) }
75
- >
76
- < Image
77
- width = { 35 }
78
- height = { 35 }
79
- src = { '/favicon.png' }
80
- className = "transition-all"
81
- alt = ""
82
- />
83
- < span className = "text-TEXT-MAIN text-T4 max-TBL:hidden" >
84
- Velog Dashboard
85
- </ span >
70
+ < Section clickType = "function" action = { ( ) => replaceWithoutLoading ( `/main${ PARAMS . MAIN } ` ) } >
71
+ < Image width = { 35 } height = { 35 } src = { '/favicon.png' } className = "transition-all" alt = "" />
72
+ < span className = "text-TEXT-MAIN text-T4 max-TBL:hidden" > Velog Dashboard</ span >
86
73
</ Section >
87
74
< div className = "flex w-fit relative" >
88
75
< div
@@ -92,12 +79,7 @@ export const Header = () => {
92
79
className = { `${ defaultStyle } h-[2px_!important] bg-TEXT-MAIN absolute bottom-0 left-0` }
93
80
/>
94
81
{ layouts . map ( ( i ) => (
95
- < Section
96
- key = { i . title }
97
- clickType = "link"
98
- icon = { i . icon }
99
- action = { i . path }
100
- >
82
+ < Section key = { i . title } clickType = "link" icon = { i . icon } action = { i . path } >
101
83
{ i . title }
102
84
</ Section >
103
85
) ) }
@@ -122,7 +104,10 @@ export const Header = () => {
122
104
< div className = "cursor-pointer h-fit flex-col rounded-[4px] bg-BG-SUB shadow-BORDER-MAIN shadow-md" >
123
105
< button
124
106
className = "text-DESTRUCTIVE-SUB text-I3 p-5 max-MBI:p-4 flex whitespace-nowrap w-auto hover:bg-BG-ALT"
125
- onClick = { ( ) => out ( ) }
107
+ onClick = { ( ) => {
108
+ start ( ) ;
109
+ out ( ) ;
110
+ } }
126
111
>
127
112
로그아웃
128
113
</ button >
0 commit comments