feat: add Account Page query
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { _ } from "@/lib/translation"
|
import { _ } from "@/lib/translation"
|
||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
import { request } from "@/lib/graphql/request"
|
||||||
|
import { GetAccountPage } from "@/lib/graphql/Query/AccountPage.graphql"
|
||||||
|
|
||||||
import MaxWidth from "@/components/MaxWidth"
|
import MaxWidth from "@/components/MaxWidth"
|
||||||
import Overview from "@/components/MyPages/Blocks/Overview"
|
import Overview from "@/components/MyPages/Blocks/Overview"
|
||||||
@@ -8,10 +10,32 @@ import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
|||||||
|
|
||||||
import styles from "./page.module.css"
|
import styles from "./page.module.css"
|
||||||
|
|
||||||
|
import { GetAccountPageData } from "@/types/requests/myPages/accountpage"
|
||||||
import type { LangParams, PageArgs } from "@/types/params"
|
import type { LangParams, PageArgs } from "@/types/params"
|
||||||
|
|
||||||
export default async function MyPageOverview({ params }: PageArgs<LangParams>) {
|
export default async function MyPageOverview({ params }: PageArgs<LangParams>) {
|
||||||
const user = await serverClient().user.get()
|
const user = await serverClient().user.get()
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
const response = await request<GetAccountPageData>(
|
||||||
|
GetAccountPage,
|
||||||
|
{
|
||||||
|
locale: params.lang,
|
||||||
|
url: "/my-pages/overview",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tags: [`'/my-pages/overview',-en`],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!response.data?.all_account_page?.total) {
|
||||||
|
console.log("#### DATA ####")
|
||||||
|
console.log(response.data)
|
||||||
|
throw new Error("Not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
const pageData = response.data.all_account_page.items[0]
|
||||||
|
>>>>>>> 13b5550 (feat: add Account Page query)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MaxWidth className={styles.blocks} tag="main">
|
<MaxWidth className={styles.blocks} tag="main">
|
||||||
|
|||||||
4
lib/graphql/Fragments/MyPages/AccountPage.graphql
Normal file
4
lib/graphql/Fragments/MyPages/AccountPage.graphql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
fragment AccountPage on AccountPage {
|
||||||
|
title
|
||||||
|
url
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#import "./AccountPage.graphql"
|
||||||
|
#import "./LoyaltyPage.graphql"
|
||||||
|
|
||||||
|
fragment AccountPageContentDynamicContent on AccountPageContentDynamicContent {
|
||||||
|
dynamic_content {
|
||||||
|
component
|
||||||
|
title
|
||||||
|
link {
|
||||||
|
link_text
|
||||||
|
linkConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
...LoyaltyPage
|
||||||
|
...AccountPage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fragment AccountPageContentShortcuts on AccountPageContentShortcuts {
|
||||||
|
shortcuts {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
}
|
||||||
4
lib/graphql/Fragments/MyPages/LoyaltyPage.graphql
Normal file
4
lib/graphql/Fragments/MyPages/LoyaltyPage.graphql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
fragment LoyaltyPage on LoyaltyPage {
|
||||||
|
title
|
||||||
|
url
|
||||||
|
}
|
||||||
16
lib/graphql/Query/AccountPage.graphql
Normal file
16
lib/graphql/Query/AccountPage.graphql
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#import "../Fragments/MyPages/AccountPageContentDynamicContent.graphql"
|
||||||
|
#import "../Fragments/MyPages/AccountPageContentShortcuts.graphql"
|
||||||
|
|
||||||
|
query GetAccountPage($locale: String!, $url: String!) {
|
||||||
|
all_account_page(limit: 1, locale: $locale, where: { url: $url }) {
|
||||||
|
items {
|
||||||
|
url
|
||||||
|
title
|
||||||
|
content {
|
||||||
|
__typename
|
||||||
|
...AccountPageContentDynamicContent
|
||||||
|
...AccountPageContentShortcuts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
types/requests/myPages/accountpage.ts
Normal file
37
types/requests/myPages/accountpage.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { AllRequestResponse } from "../utils/all"
|
||||||
|
import type { TypenameInterface } from "../utils/typename"
|
||||||
|
import type { Edges } from "../utils/edges"
|
||||||
|
|
||||||
|
export type PageLink = {
|
||||||
|
url: string
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Shortcut = {
|
||||||
|
text: string
|
||||||
|
linkConnection: Edges<PageLink>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Shortcuts = {
|
||||||
|
title: string
|
||||||
|
preamble: string
|
||||||
|
shortcuts: Shortcut[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DynamicContent = {
|
||||||
|
component: string
|
||||||
|
title: string
|
||||||
|
link: { linkConnection: Edges<PageLink>; link_text: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AccountPageContentItem = {}
|
||||||
|
|
||||||
|
export type AccountPage = {
|
||||||
|
url: string
|
||||||
|
title: string
|
||||||
|
content: AccountPageContentItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GetAccountPageData = {
|
||||||
|
all_account_page: AllRequestResponse<AccountPage>
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user