Skip to content

Commit 3134cac

Browse files
committed
changes
1 parent 0838c6d commit 3134cac

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

frontend/src/components/page-handler/page-static-props.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@ import {
1010
queryPagePreview,
1111
} from "~/types";
1212

13-
export const getProps = async ({
14-
preview,
15-
previewData,
16-
locale,
17-
params,
18-
revalidate,
19-
}: {
20-
preview: boolean;
21-
previewData: {
22-
contentType: string;
23-
token: string;
24-
};
25-
locale: string;
26-
params: {
27-
slug?: string;
28-
};
29-
revalidate: number | null;
30-
}) => {
31-
const client = getApolloClient();
13+
export const getProps = async (
14+
{
15+
preview,
16+
previewData,
17+
locale,
18+
params,
19+
}: {
20+
preview: boolean;
21+
previewData: {
22+
contentType: string;
23+
token: string;
24+
};
25+
locale: string;
26+
params: {
27+
slug?: string;
28+
};
29+
},
30+
clientParam = null,
31+
revalidate = null,
32+
) => {
33+
const client = clientParam || getApolloClient();
3234
const slug = params?.slug as string;
3335

3436
const [_, pageDataQuery] = await Promise.all([

frontend/src/pages/hotels/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { GetServerSideProps } from "next";
22
import { useRouter } from "next/router";
3+
import { getApolloClient } from "~/apollo/client";
34
import { PageHandler } from "~/components/page-handler";
45
import { getProps } from "~/components/page-handler/page-static-props";
56

@@ -16,13 +17,18 @@ export const HotelsPage = ({ blocksProps, isPreview, previewData }) => {
1617
};
1718

1819
export const getServerSideProps: GetServerSideProps = async (context: any) => {
19-
return getProps({
20-
...context,
21-
params: {
22-
slug: "hotels",
20+
const { req } = context;
21+
const client = getApolloClient(null, req.cookies);
22+
return getProps(
23+
{
24+
...context,
25+
params: {
26+
slug: "hotels",
27+
},
2328
},
24-
revalidate: null,
25-
});
29+
client,
30+
null,
31+
);
2632
};
2733

2834
export default HotelsPage;

0 commit comments

Comments
 (0)