import { cookies } from 'next/headers'
async function getUser() {
const sessionCookie = cookies().get('app_session')?.value
if (sessionCookie === undefined) return null
const res = await fetch(`http://localhost:8000/api/user/me`, {
next: { revalidate: 10 },
headers: {
cookie: `app_session=${sessionCookie}`
}
})
const user = (await res.json()) as User | null
<b>console.log(sessionCookie)</b>
return user
}
s:IdsrVAzpQXf3eOsd6dDMAZMt2WlBRwvT.LWJ+GOVVY0skk2N7/G7nsONlCdUtPssC/6A6IsUFzZo
def ajax(view):
@wraps(view)
def wrapped(request, *args, **kwargs):
if request.is_ajax():
return JsonResponse(request, *args, **kwargs)
else:
return render(request, *args, **kwargs)
return wrapped
const router = useRouter()
const [links, setLinks] = useState(initialState)
const [currentLink, setCurrentLink] = useState('/')
const [dropdown, setDropdown] = useState(false)
const handler = () => setDropdown(dropdown => !dropdown)
useEffect(() => {
const linkValue = links.some(el => el.pathname === router.pathname)
? router.pathname
: '/'
setCurrentLink({currentLink: linkValue})
}, [])
const changeCurrentLink = pathname => {
const newCurrentLink = links.find(el => el.pathname === pathname).pathname
setCurrentLink({currentLink: newCurrentLink})
}
const dropdownLinks =
router.pathname !== '/' &&
router.pathname !== '/new'
? links.filter(el => el.pathname !== currentLink)
: links.filter(el => el.pathname !== '/')
const currentLinkLabel =
router.pathname !== '/' &&
router.pathname !== '/new'
? links.find(el => el.pathname === currentLink).label
: 'Книги'
const currentLinkPathname =
router.pathname !== '/' &&
router.pathname !== '/new'
? links.find(el => el.pathname === currentLink).pathname
: '/'
const btnClass = this.state.isHovered ? " highlighted" : ""
<div className={"РОДИТЕЛЬ" + (btnClass)}></div>
<div className='ДОЧЕРНИЙ' onMouseEnter={this.handleHover} onMouseLeave={this.handleHover}></div>