fix: redirect users to /refresh on unauth and mod webview links
This commit is contained in:
66
components/Loyalty/Blocks/WebView/index.tsx
Normal file
66
components/Loyalty/Blocks/WebView/index.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
import DynamicContentBlock from "@/components/Loyalty/Blocks/DynamicContent"
|
||||
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
||||
import { modWebviewLink } from "@/utils/webviews"
|
||||
|
||||
import CardGrid from "../CardGrid"
|
||||
|
||||
import type { BlocksProps } from "@/types/components/loyalty/blocks"
|
||||
import { LoyaltyBlocksTypenameEnum } from "@/types/components/loyalty/enums"
|
||||
import { LangParams } from "@/types/params"
|
||||
|
||||
export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
||||
return blocks.map((block) => {
|
||||
switch (block.__typename) {
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardGrid:
|
||||
const cardGrid = {
|
||||
...block.card_grid,
|
||||
cards: block.card_grid.cards.map((card) => {
|
||||
return {
|
||||
...card,
|
||||
link: card.link
|
||||
? { ...card.link, href: modWebviewLink(card.link.href, lang) }
|
||||
: undefined,
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
||||
return <CardGrid card_grid={cardGrid} />
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
|
||||
return (
|
||||
<section>
|
||||
<JsonToHtml
|
||||
nodes={block.content.content.json.children}
|
||||
embeds={block.content.content.embedded_itemsConnection.edges}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksDynamicContent:
|
||||
const dynamicContent = {
|
||||
...block.dynamic_content,
|
||||
linK: block.dynamic_content.link
|
||||
? {
|
||||
...block.dynamic_content.link,
|
||||
href: modWebviewLink(block.dynamic_content.link.href, lang),
|
||||
}
|
||||
: undefined,
|
||||
}
|
||||
|
||||
return <DynamicContentBlock dynamicContent={dynamicContent} />
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||
const shortcuts = block.shortcuts.shortcuts.map((shortcut) => ({
|
||||
...shortcut,
|
||||
url: modWebviewLink(shortcut.url, lang),
|
||||
}))
|
||||
return (
|
||||
<Shortcuts
|
||||
shortcuts={shortcuts}
|
||||
title={block.shortcuts.title}
|
||||
subtitle={block.shortcuts.preamble}
|
||||
/>
|
||||
)
|
||||
default:
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
import Overview from "@/components/MyPages/Blocks/Overview"
|
||||
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
||||
import { modWebviewLink } from "@/utils/webviews"
|
||||
|
||||
import {
|
||||
AccountPageContentProps,
|
||||
@@ -31,7 +32,7 @@ export default function Content({ lang, content }: ContentProps) {
|
||||
href:
|
||||
item.dynamic_content.link.linkConnection.edges[0].node
|
||||
.original_url ||
|
||||
`/${lang}${item.dynamic_content.link.linkConnection.edges[0].node.url}`,
|
||||
`/${lang}/webview${item.dynamic_content.link.linkConnection.edges[0].node.url}`,
|
||||
text: item.dynamic_content.link.link_text,
|
||||
}
|
||||
: null
|
||||
@@ -50,9 +51,15 @@ export default function Content({ lang, content }: ContentProps) {
|
||||
/>
|
||||
)
|
||||
case ContentEntries.AccountPageContentShortcuts:
|
||||
const shortcuts = item.shortcuts.shortcuts.map((shortcut) => {
|
||||
return {
|
||||
...shortcut,
|
||||
url: modWebviewLink(shortcut.url, lang),
|
||||
}
|
||||
})
|
||||
return (
|
||||
<Shortcuts
|
||||
shortcuts={item.shortcuts.shortcuts}
|
||||
shortcuts={shortcuts}
|
||||
subtitle={item.shortcuts.preamble}
|
||||
title={item.shortcuts.title}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { _ } from "@/lib/translation"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
@@ -6,8 +7,17 @@ import BreadcrumbsWithLink from "./BreadcrumbWithLink"
|
||||
|
||||
import styles from "./breadcrumbs.module.css"
|
||||
|
||||
export default async function Breadcrumbs() {
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get()
|
||||
export default async function Breadcrumbs({
|
||||
href,
|
||||
locale,
|
||||
}: {
|
||||
href: string
|
||||
locale: Lang
|
||||
}) {
|
||||
const breadcrumbs = await serverClient().contentstack.breadcrumbs.get({
|
||||
href,
|
||||
locale,
|
||||
})
|
||||
|
||||
return (
|
||||
<nav className={styles.breadcrumbs}>
|
||||
|
||||
16
components/MyPages/Header/Hamburger/hamburger.module.css
Normal file
16
components/MyPages/Header/Hamburger/hamburger.module.css
Normal file
@@ -0,0 +1,16 @@
|
||||
.hamburger {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.line {
|
||||
background-color: var(--some-black-color, #1c1b1f);
|
||||
border-radius: 0.8rem;
|
||||
height: 0.2rem;
|
||||
width: 2.5rem;
|
||||
}
|
||||
11
components/MyPages/Header/Hamburger/index.tsx
Normal file
11
components/MyPages/Header/Hamburger/index.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import styles from "./hamburger.module.css"
|
||||
|
||||
export default function Hamburger() {
|
||||
return (
|
||||
<button className={styles.hamburger} type="button">
|
||||
<div className={styles.line} />
|
||||
<div className={styles.line} />
|
||||
<div className={styles.line} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
17
components/MyPages/Header/LanguageSwitcher/index.tsx
Normal file
17
components/MyPages/Header/LanguageSwitcher/index.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import Image from "@/components/Image"
|
||||
|
||||
import styles from "./language.module.css"
|
||||
|
||||
export default function LanguageSwitcher() {
|
||||
return (
|
||||
<div className={styles.switcher}>
|
||||
<Image
|
||||
alt="Swedish flag"
|
||||
height={21}
|
||||
src="/_static/icons/sweden.svg"
|
||||
width={21}
|
||||
/>
|
||||
<span>SV / SEK</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
.switcher {
|
||||
align-items: center;
|
||||
display: none;
|
||||
font-family: var(--ff-fira-sans);
|
||||
font-size: 1.4rem;
|
||||
font-weight: 400;
|
||||
gap: 0.6rem;
|
||||
line-height: 1.6rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 950px) {
|
||||
.switcher {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
34
components/MyPages/Header/Logo/index.tsx
Normal file
34
components/MyPages/Header/Logo/index.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import Link from "next/link"
|
||||
|
||||
import { GetMyPagesLogo } from "@/lib/graphql/Query/Logo.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
|
||||
import Image from "@/components/Image"
|
||||
|
||||
import styles from "./logo.module.css"
|
||||
|
||||
import type { LangParams } from "@/types/params"
|
||||
import type { LogoQueryData } from "@/types/requests/myPages/logo"
|
||||
|
||||
export default async function Logo({ lang }: LangParams) {
|
||||
const { data } = await request<LogoQueryData>(GetMyPagesLogo, {
|
||||
locale: lang,
|
||||
})
|
||||
if (
|
||||
!data.all_header.items.length ||
|
||||
!data.all_header.items?.[0].logoConnection.totalCount
|
||||
) {
|
||||
return null
|
||||
}
|
||||
const logo = data.all_header.items[0].logoConnection.edges[0]
|
||||
return (
|
||||
<Link className={styles.link} href="#">
|
||||
<Image
|
||||
alt={logo.node.title}
|
||||
height={logo.node.dimension.height}
|
||||
src={logo.node.url}
|
||||
width={logo.node.dimension.width}
|
||||
/>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
4
components/MyPages/Header/Logo/logo.module.css
Normal file
4
components/MyPages/Header/Logo/logo.module.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.link {
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
25
components/MyPages/Header/header.module.css
Normal file
25
components/MyPages/Header/header.module.css
Normal file
@@ -0,0 +1,25 @@
|
||||
.header {
|
||||
align-items: center;
|
||||
background-color: var(--some-white-color, #fff);
|
||||
box-shadow: 0px 1.0006656646728516px 1.0006656646728516px 0px #0000000d;
|
||||
display: grid;
|
||||
gap: 3rem;
|
||||
grid-template-columns: 1fr auto auto;
|
||||
height: var(--header-height);
|
||||
|
||||
padding: 0 2rem;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 950px) {
|
||||
.header {
|
||||
background-color: var(--some-grey-color, #ececec);
|
||||
border-bottom: 0.1rem solid var(--some-grey-color, #ccc);
|
||||
box-shadow: none;
|
||||
gap: 3.2rem;
|
||||
grid-template-columns: 1fr 19rem auto auto;
|
||||
padding: 0 2.4rem;
|
||||
}
|
||||
}
|
||||
19
components/MyPages/Header/index.tsx
Normal file
19
components/MyPages/Header/index.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import Hamburger from "./Hamburger"
|
||||
import LanguageSwitcher from "./LanguageSwitcher"
|
||||
import Logo from "./Logo"
|
||||
import User from "./User"
|
||||
|
||||
import styles from "./header.module.css"
|
||||
|
||||
import type { LangParams } from "@/types/params"
|
||||
|
||||
export default function Header({ lang }: LangParams) {
|
||||
return (
|
||||
<header className={styles.header}>
|
||||
<Logo lang={lang} />
|
||||
<LanguageSwitcher />
|
||||
<User />
|
||||
<Hamburger />
|
||||
</header>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user