Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move ConfigProvider to layout.tsx, as all pages need it #3

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/app/language/[language]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@ import React from "react";
import { getNileConfig } from "@/static/NileConfig";
import { LanguageProvider } from "@/providers/LanguageProvider";
import { LayoutCommon } from "@/components/LayoutCommon";
import { ConfigProvider } from "@/providers/ConfigProvider";
import { Listing } from "./Listing";

export default async function Home({ params }: { params: { language: string } }) {
const { language } = params;
const nileConfig = await getNileConfig();

return (
<main>
<ConfigProvider config={nileConfig}>
<LanguageProvider initialLanguage={language}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</LanguageProvider>
</ConfigProvider>
<LanguageProvider initialLanguage={language}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</LanguageProvider>
</main>
);
}
Expand Down
12 changes: 3 additions & 9 deletions src/app/languages/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React from "react";
import { getNileConfig } from "@/static/NileConfig";
import { LayoutCommon } from "@/components/LayoutCommon";
import { ConfigProvider } from "@/providers/ConfigProvider";
import { Listing } from "./Listing";

export default async function Home() {
const nileConfig = await getNileConfig();

return (
<main>
<ConfigProvider config={nileConfig}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</ConfigProvider>
<LayoutCommon>
<Listing />
</LayoutCommon>
</main>
);
}
10 changes: 8 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@ import type { Metadata } from "next";
import "./globals.css";
import '@mantine/core/styles.css';
import { ColorSchemeScript, MantineProvider } from '@mantine/core';
import { getNileConfig } from "@/static/NileConfig";
import { ConfigProvider } from "@/providers/ConfigProvider";

export const metadata: Metadata = {
title: "OpenTTD Web Translator",
description: "Translate OpenTTD into your language",
};

export default function RootLayout({
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const nileConfig = await getNileConfig();

return (
<html lang="en">
<head>
<ColorSchemeScript defaultColorScheme="auto" />
</head>
<body>
<MantineProvider defaultColorScheme="auto">
{children}
<ConfigProvider config={nileConfig}>
{children}
</ConfigProvider>
</MantineProvider>
</body>
</html>
Expand Down
14 changes: 5 additions & 9 deletions src/app/project/[project]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import React from "react";
import { getNileConfig } from "@/static/NileConfig";
import { ConfigProvider } from "@/providers/ConfigProvider";
import { ProjectProvider } from "@/providers/ProjectProvider";
import { LayoutCommon } from "@/components/LayoutCommon";
import { Listing } from "./Listing";

export default async function Home({ params }: { params: { project: string } }) {
const { project } = params;
const nileConfig = await getNileConfig();

return (
<main>
<ConfigProvider config={nileConfig}>
<ProjectProvider initialProject={project}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</ProjectProvider>
</ConfigProvider>
<ProjectProvider initialProject={project}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</ProjectProvider>
</main>
);
}
Expand Down
12 changes: 3 additions & 9 deletions src/app/projects/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React from "react";
import { getNileConfig } from "@/static/NileConfig";
import { LayoutCommon } from "@/components/LayoutCommon";
import { ConfigProvider } from "@/providers/ConfigProvider";
import { Listing } from "./Listing";

export default async function Home() {
const nileConfig = await getNileConfig();

return (
<main>
<ConfigProvider config={nileConfig}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</ConfigProvider>
<LayoutCommon>
<Listing />
</LayoutCommon>
</main>
);
}
18 changes: 7 additions & 11 deletions src/app/string/[project]/[language]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@ import React from "react";
import { getNileConfig } from "@/static/NileConfig";
import { LanguageProvider } from "@/providers/LanguageProvider";
import { ValidatorProvider } from "@/providers/ValidatorProvider";
import { ConfigProvider } from "@/providers/ConfigProvider";
import { ProjectProvider } from "@/providers/ProjectProvider";
import { Listing } from "./Listing";
import { LayoutCommon } from "@/components/LayoutCommon";

export default async function Home({ params }: { params: { project: string, language: string } }) {
const { project, language } = params;
const nileConfig = await getNileConfig();

return (
<main>
<ValidatorProvider>
<ConfigProvider config={nileConfig}>
<ProjectProvider initialProject={project}>
<LanguageProvider initialLanguage={language}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</LanguageProvider>
</ProjectProvider>
</ConfigProvider>
<ProjectProvider initialProject={project}>
<LanguageProvider initialLanguage={language}>
<LayoutCommon>
<Listing />
</LayoutCommon>
</LanguageProvider>
</ProjectProvider>
</ValidatorProvider>
</main>
);
Expand Down
14 changes: 5 additions & 9 deletions src/app/translation/[project]/[language]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@ import React from "react";
import { getNileConfig } from "@/static/NileConfig";
import { LanguageProvider } from "@/providers/LanguageProvider";
import { ValidatorProvider } from "@/providers/ValidatorProvider";
import { ConfigProvider } from "@/providers/ConfigProvider";
import { ProjectProvider } from "@/providers/ProjectProvider";
import { Listing } from "./Listing";

export default async function Home({ params }: { params: { project: string, language: string } }) {
const { project, language } = params;
const nileConfig = await getNileConfig();

return (
<main>
<ValidatorProvider>
<ConfigProvider config={nileConfig}>
<ProjectProvider initialProject={project}>
<LanguageProvider initialLanguage={language}>
<Listing />
</LanguageProvider>
</ProjectProvider>
</ConfigProvider>
<ProjectProvider initialProject={project}>
<LanguageProvider initialLanguage={language}>
<Listing />
</LanguageProvider>
</ProjectProvider>
</ValidatorProvider>
</main>
);
Expand Down
Loading