Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ackuq committed Oct 22, 2024
1 parent 338fef5 commit f19f539
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 91 deletions.
3 changes: 3 additions & 0 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<html lang="sv" suppressHydrationWarning>
Expand Down
117 changes: 117 additions & 0 deletions apps/web/app/opinionsundersokningar/graphs/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Card>
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Senaste mätningar
</h4>
<MonthPoll currentMonthAverage={currentMonthAverage} />
</Card>
<ResponsiveAd />
<Card>
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Historiskt genomsnitt (senaste 4 åren)
</h4>
<HistoricPolls historicPolls={historicPolls} />
</Card>
<Card>
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Bygg din egna regering
</h4>
<BlockBuilder currentMonthAverage={currentMonthAverage} />
</Card>
<Card className="overflow-visible">
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Blockskillnad (senaste mätningar)
</h4>
<BlockStatistics
currentMonthAverage={currentMonthAverage}
blockAverage={blockAverage}
/>
</Card>

<ResponsiveAd />
</>
);
}

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: () => (
<div
role="status"
className="h-52 w-full animate-pulse bg-slate-200 dark:bg-slate-900 sm:h-80"
/>
),
});

const BlockBuilder = dynamic(() => import("./block-builder"), {
ssr: false,
loading: () => (
<div
role="status"
className="h-[43rem] w-full animate-pulse bg-slate-200 dark:bg-slate-900"
/>
),
});

const HistoricPolls = dynamic(() => import("./historic-polls"), {
ssr: false,
loading: () => (
<div
role="status"
className="h-[30rem] w-full animate-pulse bg-slate-200 dark:bg-slate-900"
/>
),
});

const MonthPoll = dynamic(() => import("./month-poll"), {
loading: () => (
<div role="status" className="ml-[40px] flex h-96 items-end sm:h-[30rem]">
{LOADING_BARS.map((height) => (
<div
key={height}
className={twMerge(
"mx-2 flex-1 animate-pulse bg-slate-200 dark:bg-slate-900",
height,
)}
/>
))}
</div>
),
ssr: false,
});
94 changes: 6 additions & 88 deletions apps/web/app/opinionsundersokningar/page.tsx
Original file line number Diff line number Diff line change
@@ -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: () => (
<div
role="status"
className="h-52 w-full animate-pulse bg-slate-200 dark:bg-slate-900 sm:h-80"
/>
),
});
const BlockBuilder = dynamic(() => import("./components//block-builder"), {
ssr: false,
loading: () => (
<div
role="status"
className="h-[43rem] w-full animate-pulse bg-slate-200 dark:bg-slate-900"
/>
),
});
const HistoricPolls = dynamic(() => import("./components//historic-polls"), {
ssr: false,
loading: () => (
<div
role="status"
className="h-[30rem] w-full animate-pulse bg-slate-200 dark:bg-slate-900"
/>
),
});
const MonthPoll = dynamic(() => import("./components//month-poll"), {
loading: () => (
<div role="status" className="ml-[40px] flex h-96 items-end sm:h-[30rem]">
{LOADING_BARS.map((height) => (
<div
key={height}
className={twMerge(
"mx-2 flex-1 animate-pulse bg-slate-200 dark:bg-slate-900",
height,
)}
/>
))}
</div>
),
ssr: false,
});
import Graphs from "./graphs";

export const metadata = {
title: "Opinionsundersökningar | Partiguiden",
Expand All @@ -80,36 +23,11 @@ export default async function PollPage() {
<PageTitle Icon={ChartBarIcon}>Opinionsundersökningar</PageTitle>

<Container className="flex flex-col gap-4">
<Card>
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Senaste mätningar
</h4>
<MonthPoll currentMonthAverage={currentMonthAverage} />
</Card>
<ResponsiveAd />
<Card>
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Historiskt genomsnitt (senaste 4 åren)
</h4>
<HistoricPolls historicPolls={historicPolls} />
</Card>
<Card>
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Bygg din egna regering
</h4>
<BlockBuilder currentMonthAverage={currentMonthAverage} />
</Card>
<Card className="overflow-visible">
<h4 className="mb-3 text-center text-xl sm:text-2xl">
Blockskillnad (senaste mätningar)
</h4>
<BlockStatistics
currentMonthAverage={currentMonthAverage}
blockAverage={blockAverage}
/>
</Card>

<ResponsiveAd />
<Graphs
currentMonthAverage={currentMonthAverage}
historicPolls={historicPolls}
blockAverage={blockAverage}
/>
</Container>
</main>
);
Expand Down
2 changes: 2 additions & 0 deletions apps/web/components/ads/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import dynamic from "next/dynamic";

import LoadingFlowAd from "@components/loading/flow-ad";
Expand Down
3 changes: 0 additions & 3 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ let nextConfig = withBundleAnalyzer({
},
],
},
experimental: {
instrumentationHook: true,
},
});

export default withSentryConfig(nextConfig, {
Expand Down

0 comments on commit f19f539

Please sign in to comment.