fix: add logout button in mobile dropdown and name in desktop
This commit is contained in:
@@ -106,7 +106,7 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 950px) {
|
@media (min-width: 1366px) {
|
||||||
.desktop {
|
.desktop {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,7 @@ export default function Mobile({
|
|||||||
const urlKeys = Object.keys(urls)
|
const urlKeys = Object.keys(urls)
|
||||||
|
|
||||||
if (urlKeys.length === 1 && urlKeys[0] === currentLanguage) {
|
if (urlKeys.length === 1 && urlKeys[0] === currentLanguage) {
|
||||||
return (
|
return <div className={styles.toggle}>{languages[currentLanguage]}</div>
|
||||||
<div className={styles.languageSwitcher}>
|
|
||||||
{languages[currentLanguage]}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -67,8 +67,8 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 950px) {
|
@media (min-width: 1366px) {
|
||||||
.mobile {
|
.mobile {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
components/Current/Header/LoginButton.tsx
Normal file
27
components/Current/Header/LoginButton.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { usePathname } from "next/navigation"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { login } from "@/constants/routes/handleAuth"
|
||||||
|
|
||||||
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
|
|
||||||
|
import { LangParams } from "@/types/params"
|
||||||
|
|
||||||
|
export default function LoginButton({
|
||||||
|
className,
|
||||||
|
lang,
|
||||||
|
}: LangParams & { className: string }) {
|
||||||
|
const { formatMessage } = useIntl()
|
||||||
|
const pathName = usePathname()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
href={`${login[lang]}?redirectTo=${encodeURIComponent(`/${lang}${pathName}`)}`}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
{formatMessage({ id: "Log in" })}
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useState } from "react"
|
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { login } from "@/constants/routes/handleAuth"
|
import { logout } from "@/constants/routes/handleAuth"
|
||||||
import { myPages } from "@/constants/routes/myPages"
|
import { myPages } from "@/constants/routes/myPages"
|
||||||
import useDropdownStore from "@/stores/main-menu"
|
import useDropdownStore from "@/stores/main-menu"
|
||||||
|
|
||||||
@@ -11,6 +10,7 @@ import Avatar from "@/components/MyPages/Avatar"
|
|||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
|
|
||||||
import BookingButton from "../BookingButton"
|
import BookingButton from "../BookingButton"
|
||||||
|
import LoginButton from "../LoginButton"
|
||||||
|
|
||||||
import styles from "./mainMenu.module.css"
|
import styles from "./mainMenu.module.css"
|
||||||
|
|
||||||
@@ -103,12 +103,10 @@ export function MainMenu({
|
|||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li className={styles.mobileLinkRow}>
|
<li className={styles.mobileLinkRow}>
|
||||||
<Link
|
<LoginButton
|
||||||
className={styles.mobileLinkButton}
|
className={styles.mobileLinkButton}
|
||||||
href={login[lang]}
|
lang={lang}
|
||||||
>
|
/>
|
||||||
{intl.formatMessage({ id: "Log in" })}
|
|
||||||
</Link>
|
|
||||||
</li>
|
</li>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -141,10 +139,16 @@ export function MainMenu({
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{languageSwitcher ? (
|
{languageSwitcher ? (
|
||||||
<li className={styles.mobileLi}>{languageSwitcher}</li>
|
<li className={styles.mobileLi}>{languageSwitcher}</li>
|
||||||
) : null}
|
) : null}
|
||||||
|
{!!user ? (
|
||||||
|
<li className={`${styles.mobileLi} ${styles.logout}`}>
|
||||||
|
<Link href={logout[lang]} className={styles.mobileLink}>
|
||||||
|
{intl.formatMessage({ id: "Log out" })}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
) : null}
|
||||||
</ul>
|
</ul>
|
||||||
<div className={styles.buttonContainer}>
|
<div className={styles.buttonContainer}>
|
||||||
<div className={styles.myPagesDesktopLink}>
|
<div className={styles.myPagesDesktopLink}>
|
||||||
|
|||||||
@@ -219,10 +219,14 @@
|
|||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mobileLi.logout {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.mobileLink {
|
.mobileLink {
|
||||||
color: #000;
|
color: #000;
|
||||||
display: block;
|
display: block;
|
||||||
font-family: Helvetica;
|
font-family: Helvetica !important;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
import { login, logout } from "@/constants/routes/handleAuth"
|
import { logout } from "@/constants/routes/handleAuth"
|
||||||
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
import { auth } from "@/auth"
|
import { auth } from "@/auth"
|
||||||
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
|
import { getIntl } from "@/i18n"
|
||||||
|
|
||||||
|
import LoginButton from "../LoginButton"
|
||||||
|
|
||||||
import styles from "./topMenu.module.css"
|
import styles from "./topMenu.module.css"
|
||||||
|
|
||||||
import type { TopMenuProps } from "@/types/components/current/header/topMenu"
|
import type { TopMenuProps } from "@/types/components/current/header/topMenu"
|
||||||
|
|
||||||
|
function capitalize(str: string) {
|
||||||
|
return str.charAt(0).toUpperCase().toUpperCase() + str.slice(1).toLowerCase()
|
||||||
|
}
|
||||||
|
|
||||||
export default async function TopMenu({
|
export default async function TopMenu({
|
||||||
frontpageLinkText,
|
frontpageLinkText,
|
||||||
homeHref,
|
homeHref,
|
||||||
@@ -13,7 +22,9 @@ export default async function TopMenu({
|
|||||||
languageSwitcher,
|
languageSwitcher,
|
||||||
lang,
|
lang,
|
||||||
}: TopMenuProps) {
|
}: TopMenuProps) {
|
||||||
|
const { formatMessage } = await getIntl()
|
||||||
const session = await auth()
|
const session = await auth()
|
||||||
|
const user = session ? await serverClient().user.get() : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.topMenu}>
|
<div className={styles.topMenu}>
|
||||||
@@ -34,15 +45,24 @@ export default async function TopMenu({
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li className={styles.loginContainer}>
|
<li className={styles.sessionContainer}>
|
||||||
{session ? (
|
{session ? (
|
||||||
<a href={logout[lang]} className={styles.loginLink}>
|
<>
|
||||||
Log out
|
{user ? (
|
||||||
</a>
|
<Link href={logout[lang]} className={styles.sessionLink}>
|
||||||
|
{capitalize(user.firstName)}
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
<div className={styles.loginSeparator} />
|
||||||
|
<Link href={logout[lang]} className={styles.sessionLink}>
|
||||||
|
{formatMessage({ id: "Log out" })}
|
||||||
|
</Link>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<a href={login[lang]} className={styles.loginLink}>
|
<LoginButton
|
||||||
Log in
|
lang={lang}
|
||||||
</a>
|
className={`${styles.sessionLink} ${styles.loginLink}`}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -78,9 +78,14 @@
|
|||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
padding-right: 30px;
|
padding-right: 30px;
|
||||||
color: #000;
|
color: #000;
|
||||||
|
font-family:
|
||||||
|
Helvetica Neue,
|
||||||
|
Helvetica,
|
||||||
|
Arial,
|
||||||
|
sans-serif !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loginContainer {
|
.sessionContainer {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
background-color: #f3f2f1;
|
background-color: #f3f2f1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -88,15 +93,19 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loginLink {
|
.loginSeparator {
|
||||||
padding-left: 30px;
|
height: 15px;
|
||||||
padding-right: 30px;
|
border-right: 1px solid #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sessionLink {
|
||||||
|
padding: 4px 15px;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-family:
|
font-family:
|
||||||
Helvetica Neue,
|
Helvetica Neue,
|
||||||
Helvetica,
|
Helvetica,
|
||||||
Arial,
|
Arial,
|
||||||
sans-serif;
|
sans-serif !important;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
@@ -106,4 +115,9 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sessionLink.loginLink {
|
||||||
|
padding-left: 30px;
|
||||||
|
padding-right: 30px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user