fix: caching
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { batchRequest } from "@/lib/graphql/batchRequest"
|
||||
import {
|
||||
GetDaDeEnUrls,
|
||||
GetFiNoSvUrls,
|
||||
GetDaDeEnUrlsCurrentBlocksPage,
|
||||
GetFiNoSvUrlsCurrentBlocksPage,
|
||||
} from "@/lib/graphql/Query/LanguageSwitcherCurrent.graphql"
|
||||
|
||||
import Desktop from "@/components/Current/Header/LanguageSwitcher/Desktop"
|
||||
@@ -26,11 +26,11 @@ export default async function LanguageSwitcher({
|
||||
|
||||
const { data: urls } = await batchRequest<LanguageSwitcherData>([
|
||||
{
|
||||
document: GetDaDeEnUrls,
|
||||
document: GetDaDeEnUrlsCurrentBlocksPage,
|
||||
variables,
|
||||
},
|
||||
{
|
||||
document: GetFiNoSvUrls,
|
||||
document: GetFiNoSvUrlsCurrentBlocksPage,
|
||||
variables,
|
||||
},
|
||||
])
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
Helvetica Neue,
|
||||
Helvetica,
|
||||
Arial,
|
||||
sans-serif;
|
||||
sans-serif !important;
|
||||
font-weight: 700;
|
||||
background-color: transparent !important;
|
||||
text-decoration: none;
|
||||
@@ -234,7 +234,7 @@
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1367px) {
|
||||
@media screen and (min-width: 950px) {
|
||||
.mainMenu {
|
||||
box-shadow: none;
|
||||
background-color: hsla(0, 0%, 100%, 0.95);
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1367px) {
|
||||
@media screen and (min-width: 950px) {
|
||||
.topMenu {
|
||||
background-color: #3d3835;
|
||||
display: block;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
display: grid;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
@media screen and (max-width: 950px) {
|
||||
.header {
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ query GetAccountPageRefs($locale: String!, $uid: String!) {
|
||||
}
|
||||
}
|
||||
|
||||
query GetDaDeEnUrls($uid: String!) {
|
||||
query GetDaDeEnUrlsAccountPage($uid: String!) {
|
||||
de: all_account_page(where: { uid: $uid }, locale: "de") {
|
||||
items {
|
||||
url
|
||||
@@ -81,7 +81,7 @@ query GetDaDeEnUrls($uid: String!) {
|
||||
}
|
||||
}
|
||||
|
||||
query GetFiNoSvUrls($uid: String!) {
|
||||
query GetFiNoSvUrlsAccountPage($uid: String!) {
|
||||
fi: all_account_page(where: { uid: $uid }, locale: "fi") {
|
||||
items {
|
||||
url
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#import "../Fragments/Image.graphql"
|
||||
#import "../Fragments/Refs/System.graphql"
|
||||
|
||||
query GetCurrentHeader($locale: String!) {
|
||||
all_current_header(limit: 1, locale: $locale) {
|
||||
@@ -30,3 +31,13 @@ query GetCurrentHeader($locale: String!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetCurrentHeaderRef($locale: String!) {
|
||||
all_current_header(limit: 1, locale: $locale) {
|
||||
items {
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
query GetDaDeEnUrls($uid: String!) {
|
||||
query GetDaDeEnUrlsCurrentBlocksPage($uid: String!) {
|
||||
de: current_blocks_page(uid: $uid, locale: "de") {
|
||||
url: original_url
|
||||
}
|
||||
@@ -10,7 +10,7 @@ query GetDaDeEnUrls($uid: String!) {
|
||||
}
|
||||
}
|
||||
|
||||
query GetFiNoSvUrls($uid: String!) {
|
||||
query GetFiNoSvUrlsCurrentBlocksPage($uid: String!) {
|
||||
fi: current_blocks_page(uid: $uid, locale: "fi") {
|
||||
url: original_url
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ query GetLoyaltyPageRefs($locale: String!, $uid: String!) {
|
||||
}
|
||||
}
|
||||
|
||||
query GetDaDeEnUrls($uid: String!) {
|
||||
query GetDaDeEnUrlsLoyaltyPage($uid: String!) {
|
||||
de: all_loyalty_page(where: { uid: $uid }, locale: "de") {
|
||||
items {
|
||||
web {
|
||||
@@ -273,7 +273,7 @@ query GetDaDeEnUrls($uid: String!) {
|
||||
}
|
||||
}
|
||||
|
||||
query GetFiNoSvUrls($uid: String!) {
|
||||
query GetFiNoSvUrlsLoyaltyPage($uid: String!) {
|
||||
sv: all_loyalty_page(where: { uid: $uid }, locale: "sv") {
|
||||
items {
|
||||
web {
|
||||
|
||||
@@ -3,8 +3,8 @@ import { batchRequest } from "@/lib/graphql/batchRequest"
|
||||
import {
|
||||
GetAccountPage,
|
||||
GetAccountPageRefs,
|
||||
GetDaDeEnUrls,
|
||||
GetFiNoSvUrls,
|
||||
GetDaDeEnUrlsAccountPage,
|
||||
GetFiNoSvUrlsAccountPage,
|
||||
} from "@/lib/graphql/Query/AccountPage.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { internalServerError, notFound } from "@/server/errors/trpc"
|
||||
@@ -147,11 +147,11 @@ export const accountPageQueryRouter = router({
|
||||
|
||||
const res = await batchRequest<LanguageSwitcherQueryDataRaw>([
|
||||
{
|
||||
document: GetDaDeEnUrls,
|
||||
document: GetDaDeEnUrlsAccountPage,
|
||||
variables,
|
||||
},
|
||||
{
|
||||
document: GetFiNoSvUrls,
|
||||
document: GetFiNoSvUrlsAccountPage,
|
||||
variables,
|
||||
},
|
||||
])
|
||||
|
||||
@@ -118,3 +118,18 @@ export type HeaderData = Omit<
|
||||
> & {
|
||||
logo: Image
|
||||
}
|
||||
|
||||
const validateHeaderRefConfigSchema = z.object({
|
||||
all_current_header: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
system: z.object({
|
||||
content_type_uid: z.string(),
|
||||
uid: z.string(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
|
||||
export type HeaderRefDataRaw = z.infer<typeof validateHeaderRefConfigSchema>
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import { GetContactConfig } from "@/lib/graphql/Query/ContactConfig.graphql"
|
||||
import { GetCurrentHeader } from "@/lib/graphql/Query/CurrentHeader.graphql"
|
||||
import {
|
||||
GetCurrentHeader,
|
||||
GetCurrentHeaderRef,
|
||||
} from "@/lib/graphql/Query/CurrentHeader.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { internalServerError, notFound } from "@/server/errors/trpc"
|
||||
import { contentstackProcedure, publicProcedure, router } from "@/server/trpc"
|
||||
|
||||
import { generateTag } from "@/utils/generateTag"
|
||||
|
||||
import {
|
||||
type ContactConfigData,
|
||||
HeaderData,
|
||||
HeaderDataRaw,
|
||||
HeaderRefDataRaw,
|
||||
validateContactConfigSchema,
|
||||
validateHeaderConfigSchema,
|
||||
} from "./output"
|
||||
@@ -35,10 +41,23 @@ export const configQueryRouter = router({
|
||||
return validatedContactConfigConfig.data.all_contact_config.items[0]
|
||||
}),
|
||||
header: publicProcedure.query(async ({ ctx }) => {
|
||||
const responseRef = await request<HeaderRefDataRaw>(GetCurrentHeaderRef, {
|
||||
locale: ctx.lang,
|
||||
})
|
||||
|
||||
const response = await request<HeaderDataRaw>(
|
||||
GetCurrentHeader,
|
||||
{ locale: ctx.lang },
|
||||
{ next: { tags: [`header-${ctx.lang}`] } }
|
||||
{
|
||||
next: {
|
||||
tags: [
|
||||
generateTag(
|
||||
ctx.lang,
|
||||
responseRef.data.all_current_header.items[0].system.uid
|
||||
),
|
||||
],
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { batchRequest } from "@/lib/graphql/batchRequest"
|
||||
import {
|
||||
GetDaDeEnUrls,
|
||||
GetFiNoSvUrls,
|
||||
GetDaDeEnUrlsLoyaltyPage,
|
||||
GetFiNoSvUrlsLoyaltyPage,
|
||||
GetLoyaltyPage,
|
||||
GetLoyaltyPageRefs,
|
||||
} from "@/lib/graphql/Query/LoyaltyPage.graphql"
|
||||
@@ -188,11 +188,11 @@ export const loyaltyPageQueryRouter = router({
|
||||
|
||||
const res = await batchRequest<LanguageSwitcherQueryDataRaw>([
|
||||
{
|
||||
document: GetDaDeEnUrls,
|
||||
document: GetDaDeEnUrlsLoyaltyPage,
|
||||
variables,
|
||||
},
|
||||
{
|
||||
document: GetFiNoSvUrls,
|
||||
document: GetFiNoSvUrlsLoyaltyPage,
|
||||
variables,
|
||||
},
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user