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