diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 320e49cf8..02375e70e 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -19,6 +19,9 @@ const roboto = Roboto({ fallback: ["Helvetica", "Arial", "sans-serif"], }); +// Cache all fetch requests by default +export const fetchCache = "default-cache"; + export default function RootLayout({ children }: PropsWithChildren) { return ( diff --git a/apps/web/app/opinionsundersokningar/components/block-builder.tsx b/apps/web/app/opinionsundersokningar/graphs/block-builder.tsx similarity index 100% rename from apps/web/app/opinionsundersokningar/components/block-builder.tsx rename to apps/web/app/opinionsundersokningar/graphs/block-builder.tsx diff --git a/apps/web/app/opinionsundersokningar/components/block-statistics.tsx b/apps/web/app/opinionsundersokningar/graphs/block-statistics.tsx similarity index 100% rename from apps/web/app/opinionsundersokningar/components/block-statistics.tsx rename to apps/web/app/opinionsundersokningar/graphs/block-statistics.tsx diff --git a/apps/web/app/opinionsundersokningar/components/historic-polls.tsx b/apps/web/app/opinionsundersokningar/graphs/historic-polls.tsx similarity index 100% rename from apps/web/app/opinionsundersokningar/components/historic-polls.tsx rename to apps/web/app/opinionsundersokningar/graphs/historic-polls.tsx diff --git a/apps/web/app/opinionsundersokningar/graphs/index.tsx b/apps/web/app/opinionsundersokningar/graphs/index.tsx new file mode 100644 index 000000000..f366fd8b9 --- /dev/null +++ b/apps/web/app/opinionsundersokningar/graphs/index.tsx @@ -0,0 +1,117 @@ +"use client"; + +import dynamic from "next/dynamic"; +import { twMerge } from "tailwind-merge"; + +import { ResponsiveAd } from "@components/ads"; +import { Card } from "@components/common/card"; +import type { + AveragePoll, + BlocksAverage, + MonthlyAverage, +} from "@lib/api/polls/types"; + +interface Props { + currentMonthAverage: AveragePoll; + historicPolls: MonthlyAverage; + blockAverage: BlocksAverage; +} + +export default function Graphs({ + currentMonthAverage, + historicPolls, + blockAverage, +}: Props) { + return ( + <> + +

+ Senaste mätningar +

+ +
+ + +

+ Historiskt genomsnitt (senaste 4 åren) +

+ +
+ +

+ Bygg din egna regering +

+ +
+ +

+ Blockskillnad (senaste mätningar) +

+ +
+ + + + ); +} + +const LOADING_BARS = [ + "h-80", + "h-64", + "h-60", + "h-72", + "h-48", + "h-96", + "h-32", + "h-56", +]; + +const BlockStatistics = dynamic(() => import("./block-statistics"), { + ssr: false, + loading: () => ( +
+ ), +}); + +const BlockBuilder = dynamic(() => import("./block-builder"), { + ssr: false, + loading: () => ( +
+ ), +}); + +const HistoricPolls = dynamic(() => import("./historic-polls"), { + ssr: false, + loading: () => ( +
+ ), +}); + +const MonthPoll = dynamic(() => import("./month-poll"), { + loading: () => ( +
+ {LOADING_BARS.map((height) => ( +
+ ))} +
+ ), + ssr: false, +}); diff --git a/apps/web/app/opinionsundersokningar/components/month-poll.tsx b/apps/web/app/opinionsundersokningar/graphs/month-poll.tsx similarity index 100% rename from apps/web/app/opinionsundersokningar/components/month-poll.tsx rename to apps/web/app/opinionsundersokningar/graphs/month-poll.tsx diff --git a/apps/web/app/opinionsundersokningar/page.tsx b/apps/web/app/opinionsundersokningar/page.tsx index 25734bca1..162260e98 100644 --- a/apps/web/app/opinionsundersokningar/page.tsx +++ b/apps/web/app/opinionsundersokningar/page.tsx @@ -1,67 +1,10 @@ import { ChartBarIcon } from "@heroicons/react/24/solid"; -import dynamic from "next/dynamic"; -import { twMerge } from "tailwind-merge"; -import { ResponsiveAd } from "@components/ads"; -import { Card } from "@components/common/card"; import Container from "@components/common/container"; import PageTitle from "@components/common/page-title"; import getPolls from "@lib/api/polls/get-polls"; -const LOADING_BARS = [ - "h-80", - "h-64", - "h-60", - "h-72", - "h-48", - "h-96", - "h-32", - "h-56", -]; - -const BlockStatistics = dynamic(() => import("./components/block-statistics"), { - ssr: false, - loading: () => ( -
- ), -}); -const BlockBuilder = dynamic(() => import("./components//block-builder"), { - ssr: false, - loading: () => ( -
- ), -}); -const HistoricPolls = dynamic(() => import("./components//historic-polls"), { - ssr: false, - loading: () => ( -
- ), -}); -const MonthPoll = dynamic(() => import("./components//month-poll"), { - loading: () => ( -
- {LOADING_BARS.map((height) => ( -
- ))} -
- ), - ssr: false, -}); +import Graphs from "./graphs"; export const metadata = { title: "Opinionsundersökningar | Partiguiden", @@ -80,36 +23,11 @@ export default async function PollPage() { Opinionsundersökningar - -

- Senaste mätningar -

- -
- - -

- Historiskt genomsnitt (senaste 4 åren) -

- -
- -

- Bygg din egna regering -

- -
- -

- Blockskillnad (senaste mätningar) -

- -
- - +
); diff --git a/apps/web/components/ads/index.ts b/apps/web/components/ads/index.ts index 8045a955f..9d0eb1137 100644 --- a/apps/web/components/ads/index.ts +++ b/apps/web/components/ads/index.ts @@ -1,3 +1,5 @@ +"use client"; + import dynamic from "next/dynamic"; import LoadingFlowAd from "@components/loading/flow-ad"; diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 32c7b3473..95bfa7a71 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -25,9 +25,6 @@ let nextConfig = withBundleAnalyzer({ }, ], }, - experimental: { - instrumentationHook: true, - }, }); export default withSentryConfig(nextConfig, {