From 156197612a664de77d592c40a404387c8d0bc6c9 Mon Sep 17 00:00:00 2001 From: moebiusl Date: Fri, 11 Oct 2024 20:51:21 +0200 Subject: [PATCH] addPage for gmpl --- src/app/context/LanguageContext.tsx | 21 +++++++++ src/app/glp/page.tsx | 69 +++++++++++++++++++++++++++++ src/app/layout.tsx | 6 +++ src/app/page.tsx | 22 ++++++++- 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/app/context/LanguageContext.tsx create mode 100644 src/app/glp/page.tsx diff --git a/src/app/context/LanguageContext.tsx b/src/app/context/LanguageContext.tsx new file mode 100644 index 0000000..96e9a7c --- /dev/null +++ b/src/app/context/LanguageContext.tsx @@ -0,0 +1,21 @@ +'use client'; + +import React, { createContext, useState, ReactNode } from 'react'; + +export const LanguageContext = createContext<{ + language: string; + setLanguage: (lang: string) => void; +}>({ + language: 'eng', + setLanguage: () => {}, +}); + +export const LanguageProvider = ({ children }: { children: ReactNode }) => { + const [language, setLanguage] = useState('eng'); + + return ( + + {children} + + ); +}; \ No newline at end of file diff --git a/src/app/glp/page.tsx b/src/app/glp/page.tsx new file mode 100644 index 0000000..f965cf5 --- /dev/null +++ b/src/app/glp/page.tsx @@ -0,0 +1,69 @@ +'use client'; + +import { useRouter } from 'next/navigation'; +import React, { useState, useContext } from 'react'; +import text from "../lang"; +import { LanguageContext } from '../context/LanguageContext'; + + +const GlpPage = () => { + const router = useRouter(); + + const { language, setLanguage } = useContext(LanguageContext); + const [model, setModel] = useState('gen'); + + const tr_hTitle = text(language, 'header_title'); + const tr_hSubtitle = text(language, 'header_subtitle'); + const tr_boxObjTitle = text(language, 'boxObjTitle'); + const tr_boxObjDesc = text(language, "boxObjDesc"); + const tr_boxSubjTitle = text(language, 'boxSubjTitle'); + const tr_boxSubjDesc = text(language, "boxSubjDesc"); + const tr_boxBoundsTitle = text(language, 'boxBoundsTitle'); + const tr_boxBoundsDesc = text(language, "boxBoundsDesc"); + const tr_boxVarsTitle = text(language, 'boxVarsTitle'); + const tr_boxVarsDesc = text(language, "boxVarsDesc"); + const tr_boxOut = text(language, "boxOut"); + const tr_boxExportLP = text(language, "boxExportLP"); + const tr_calc_max = text(language, "maximize"); + const tr_calc_min = text(language, "minimize"); + const tr_calcButton = text(language, "buttonCalc"); + const tr_boxExportMPS = text(language, "boxExportMPS"); + + const handleLanguageChange = (event: React.ChangeEvent) => { + setLanguage(event.target.value); + }; + + const changeModel = (event: React.ChangeEvent) => { + const selectedModel = event.target.value; + setModel(selectedModel); + + if (selectedModel === 'spec') { + router.push('/'); + } + }; + + return ( +
+
+
+ {tr_hTitle} +
+ + {tr_hSubtitle} + +
+ + +
+
+
+ ); +}; + +export default GlpPage; \ No newline at end of file diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 6f3f03b..0542883 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,6 +1,7 @@ import type { Metadata } from "next"; import Image from "next/image"; import localFont from "next/font/local"; +import { LanguageProvider } from './context/LanguageContext'; // Importiere den Provider import "./globals.css"; const geistSans = localFont({ @@ -19,16 +20,21 @@ export const metadata: Metadata = { description: "OR-Tool by Spaceholder Programming", }; + export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { return ( + + + {children} {} + {children}