fix: typings for contactConfig
This commit is contained in:
@@ -22,15 +22,28 @@ query GetLoyaltyPage($locale: String!, $url: String!) {
|
||||
edges {
|
||||
node {
|
||||
... on LoyaltyPage {
|
||||
system {
|
||||
locale
|
||||
uid
|
||||
}
|
||||
url
|
||||
title
|
||||
}
|
||||
... on ContentPage {
|
||||
web {
|
||||
url
|
||||
system {
|
||||
locale
|
||||
uid
|
||||
}
|
||||
url
|
||||
title
|
||||
}
|
||||
... on AccountPage {
|
||||
system {
|
||||
locale
|
||||
uid
|
||||
}
|
||||
url
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export const middleware: NextMiddleware = async (request) => {
|
||||
const { nextUrl } = request
|
||||
const lang = findLang(nextUrl.pathname)
|
||||
|
||||
const contentType = "currentContentPage"
|
||||
const contentType = "loyaltyPage"
|
||||
const pathNameWithoutLang = nextUrl.pathname.replace(`/${lang}`, "")
|
||||
const searchParams = new URLSearchParams(request.nextUrl.searchParams)
|
||||
|
||||
@@ -23,12 +23,16 @@ export const middleware: NextMiddleware = async (request) => {
|
||||
|
||||
searchParams.set("uri", pathNameWithoutLang)
|
||||
switch (contentType) {
|
||||
case "currentContentPage":
|
||||
// case "currentContentPage":
|
||||
// return NextResponse.rewrite(
|
||||
// new URL(
|
||||
// `/${lang}/current-content-page?${searchParams.toString()}`,
|
||||
// nextUrl
|
||||
// )
|
||||
// )
|
||||
case "loyaltyPage":
|
||||
return NextResponse.rewrite(
|
||||
new URL(
|
||||
`/${lang}/current-content-page?${searchParams.toString()}`,
|
||||
nextUrl
|
||||
)
|
||||
new URL(`/${lang}/loyalty-page?${searchParams.toString()}`, nextUrl)
|
||||
)
|
||||
default:
|
||||
return NextResponse.next()
|
||||
|
||||
48
types/requests/contactConfig.ts
Normal file
48
types/requests/contactConfig.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { AllRequestResponse } from "./utils/all"
|
||||
|
||||
export type ContactConfig = {
|
||||
items: [
|
||||
{
|
||||
email: {
|
||||
name: string
|
||||
address: string
|
||||
}
|
||||
email_loyalty: {
|
||||
name: string
|
||||
address: string
|
||||
}
|
||||
mailing_address: {
|
||||
zip: string
|
||||
street: string
|
||||
name: string
|
||||
city: string
|
||||
country: string
|
||||
}
|
||||
phone: {
|
||||
number: string
|
||||
naem: string
|
||||
}
|
||||
phone_loyalty: {
|
||||
number: string
|
||||
name: string
|
||||
}
|
||||
visiting_address: {
|
||||
zip: string
|
||||
country: string
|
||||
city: string
|
||||
street: string
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
type FlattenKeys<T> = T extends object
|
||||
? {
|
||||
[K in keyof T]-?: `${K & string}.${FlattenKeys<T[K]>}`
|
||||
}[keyof T]
|
||||
: ""
|
||||
|
||||
export type ContactField = FlattenKeys<ContactConfig["items"][0]>
|
||||
|
||||
export type GetContactConfigData = {
|
||||
all_contact_config: AllRequestResponse<ContactConfig>
|
||||
}
|
||||
@@ -1,19 +1,48 @@
|
||||
import { PageLink } from "./myPages/navigation"
|
||||
import type { AllRequestResponse } from "./utils/all"
|
||||
import type { Typename } from "./utils/typename"
|
||||
import { Edges } from "./utils/edges"
|
||||
import type { RTEDocument } from "../rte/node"
|
||||
import type { Embeds } from "./embeds"
|
||||
import type { ContactField } from "./contactConfig"
|
||||
|
||||
enum SidebarTypenameEnum {
|
||||
LoyaltyPageSidebarLoyaltyJoinContact = "LoyaltyPageSidebarLoyaltyJoinContact",
|
||||
LoyaltyPageSidebarContent = "LoyaltyPageSidebarContent",
|
||||
}
|
||||
|
||||
type SidebarContent = {}
|
||||
type SidebarContent = {
|
||||
content: {
|
||||
embedded_itemsConnection: Edges<Embeds>
|
||||
json: RTEDocument
|
||||
}
|
||||
}
|
||||
|
||||
type JoinContact = {}
|
||||
type Contact = {
|
||||
contact: {
|
||||
contact_fields: ContactField[]
|
||||
}
|
||||
}
|
||||
|
||||
type LoyaltyJoinContact = {
|
||||
loyalty_join_contact: {
|
||||
title: string
|
||||
contact: Typename<
|
||||
Contact,
|
||||
"LoyaltyPageSidebarLoyaltyJoinContactBlockContactContact"
|
||||
>
|
||||
login_button_text: string
|
||||
body: {
|
||||
embedded_itemsConnection: Edges<Embeds>
|
||||
json: RTEDocument
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type Sidebar =
|
||||
| Typename<SidebarContent, SidebarTypenameEnum.LoyaltyPageSidebarContent>
|
||||
| Typename<
|
||||
JoinContact,
|
||||
LoyaltyJoinContact,
|
||||
SidebarTypenameEnum.LoyaltyPageSidebarLoyaltyJoinContact
|
||||
>
|
||||
|
||||
@@ -22,38 +51,12 @@ enum ContentBlocks {
|
||||
LoyaltyPageContentCardGrid = "LoyaltyPageContentCardGrid",
|
||||
}
|
||||
|
||||
enum LinkedPageConnection {
|
||||
LoyaltyPage = "LoyaltyPage",
|
||||
ContentPage = "ContentPage",
|
||||
AccountPage = "AccountPage",
|
||||
}
|
||||
|
||||
type ContentPageLink = {
|
||||
web: { url: string }
|
||||
}
|
||||
type LoyaltyPageLink = {
|
||||
url: string
|
||||
}
|
||||
|
||||
type AccountPageLink = {
|
||||
url: string
|
||||
}
|
||||
|
||||
type LinkedPage =
|
||||
| Typename<ContentPageLink, LinkedPageConnection.ContentPage>
|
||||
| Typename<LoyaltyPageLink, ContentBlocks.LoyaltyPageContentLoyaltyLevels>
|
||||
| Typename<AccountPageLink, ContentBlocks.LoyaltyPageContentLoyaltyLevels>
|
||||
|
||||
type CardGrid = {
|
||||
card_grid: {
|
||||
heading: string
|
||||
subheading: string
|
||||
cards: {
|
||||
referenceConnection: {
|
||||
edges: {
|
||||
node: LinkedPage
|
||||
}
|
||||
}
|
||||
referenceConnection: Edges<PageLink>
|
||||
heading: string
|
||||
subheading: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user