21 Commits

Author SHA1 Message Date
theis.gaedigk d2b22fc71f Merge branch 'dev' into prod 2026-05-04 22:04:26 +02:00
theis.gaedigk 4df6d243f3 feat: implement dynamic API base URL and add language toggle in MainForm
Co-authored-by: Copilot <copilot@github.com>
2026-05-04 22:03:21 +02:00
theis.gaedigk 471c0c7a49 Merge branch 'dev' into prod 2026-01-21 16:33:03 +01:00
theis.gaedigk 75ff65e76b Merge branch 'dev' into prod 2026-01-21 16:28:23 +01:00
theis.gaedigk 7cf1245ef6 Merge branch 'dev' into prod 2026-01-21 14:27:37 +01:00
theis.gaedigk 2adbfa75a5 Merge branch 'dev' into prod 2026-01-21 14:07:26 +01:00
theis.gaedigk 216a1cb1d4 Merge branch 'dev' into prod 2026-01-20 20:43:59 +01:00
theis.gaedigk 7fc98d6c9f Merge branch 'dev' into prod 2026-01-20 20:34:52 +01:00
theis.gaedigk e346cf9445 e 2026-01-20 20:33:41 +01:00
theis.gaedigk c030b6dbe6 Merge branch 'dev' into prod 2026-01-20 20:33:31 +01:00
theis.gaedigk 6f26b9bbc3 e 2026-01-20 20:22:59 +01:00
theis.gaedigk a34a70572f edited 2026-01-20 20:19:12 +01:00
theis.gaedigk 4b3c8a2424 edited compose file 2026-01-20 20:17:53 +01:00
theis.gaedigk 568b3bf495 edited 2026-01-20 20:08:14 +01:00
theis.gaedigk 5653d32857 fix: update WireGuard PASSWORD_HASH to a static value 2026-01-20 20:06:44 +01:00
theis.gaedigk 7cf5b8df48 Merge branch 'dev' into prod 2026-01-20 20:03:51 +01:00
theis.gaedigk 65c5fc0f8f Merge branch 'dev' into prod 2026-01-20 19:59:27 +01:00
theis.gaedigk b626a67907 Merge branch 'dev' into prod 2026-01-20 19:46:56 +01:00
theis.gaedigk 6643a176a6 Merge branch 'dev' into prod 2026-01-20 19:43:53 +01:00
theis.gaedigk 89803754a7 Merge branch 'dev' into prod 2026-01-20 19:38:27 +01:00
theis.gaedigk 5052b3e83a changed fetch urls 2026-01-20 19:23:53 +01:00
4 changed files with 46 additions and 9 deletions
+8 -5
View File
@@ -40,7 +40,7 @@ export const confirmUser = async (username) => {
console.log(tableName);
const [createTable] = await pool.query(
`CREATE TABLE IF NOT EXISTS ${tableName} (
`CREATE TABLE IF NOT EXISTS ? (
id INT AUTO_INCREMENT PRIMARY KEY,
Vorname VARCHAR(100) NOT NULL,
Nachname Varchar(100) NOT NULL,
@@ -56,14 +56,16 @@ export const confirmUser = async (username) => {
Plz_Ort Varchar(100),
Zahlungsmethode Varchar(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)`
)`,
[tableName],
);
if (createTable) {
let nextID;
const getNextID = async () => {
const [rows] = await pool.query(
`SELECT id FROM ${tableName} ORDER BY id DESC LIMIT 1`
`SELECT id FROM ? ORDER BY id DESC LIMIT 1`,
[tableName],
);
nextID = rows.length > 0 ? rows[0].id + 1 : 1;
};
@@ -87,8 +89,9 @@ export const newEntry = async (formData, username) => {
const tableName = confirmation.tableName;
const [result] = await pool.query(
`INSERT INTO ${tableName} (Vorname, Nachname, EMail, Telefonnummer, Lose, Firmenname, Vorname_Geschaeftlich, Nachname_Geschaeftlich, EMail_Geschaeftlich, Telefonnummer_Geschaeftlich, Strasse_Hausnr, Plz_Ort, Zahlungsmethode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
`INSERT INTO ? (Vorname, Nachname, EMail, Telefonnummer, Lose, Firmenname, Vorname_Geschaeftlich, Nachname_Geschaeftlich, EMail_Geschaeftlich, Telefonnummer_Geschaeftlich, Strasse_Hausnr, Plz_Ort, Zahlungsmethode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
tableName,
formData.firstName,
formData.lastName,
formData.email,
@@ -102,7 +105,7 @@ export const newEntry = async (formData, username) => {
formData.street,
formData.postalCode,
formData.paymentMethod,
]
],
);
return { success: true, insertId: result.insertId };
+4
View File
@@ -0,0 +1,4 @@
export const API_BASE =
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8004";
+31 -3
View File
@@ -10,12 +10,15 @@ import {
Box,
Paper,
Typography,
IconButton,
} from "@mui/material";
import { useTranslation } from "react-i18next";
import { useState, useEffect } from "react";
import { submitFormData } from "../utils/sender";
import Cookies from "js-cookie";
import * as React from "react";
import TranslateIcon from "@mui/icons-material/Translate";
import { API_BASE } from "../config/api.config";
interface Message {
type: "error" | "info" | "success" | "warning";
@@ -24,7 +27,7 @@ interface Message {
}
export const MainForm = () => {
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const [invoice, setInvoice] = useState(false);
const [msg, setMsg] = useState<Message | null>(null);
const [isLoading, setIsLoading] = useState(false);
@@ -47,11 +50,27 @@ export const MainForm = () => {
const [users, setUsers] = useState<string[]>([]);
const [selectedUser, setSelectedUser] = useState<string | null>(null);
const changeTranslation = () => {
const clientLng = i18n.language;
if (clientLng === "en") {
i18n.changeLanguage("de");
} else if (clientLng === "de") {
i18n.changeLanguage("en");
} else {
setMsg({
type: "error",
headline: "Error",
text: "Cannot change langugage.",
});
}
};
useEffect(() => {
// Fetch user data or any other data needed for the form
try {
const fetchUsers = async () => {
const response = await fetch("http://localhost:8004/default/users");
const response = await fetch(`${API_BASE}/default/users`);
const data = await response.json();
setUsers(data.users);
};
@@ -80,7 +99,7 @@ export const MainForm = () => {
const confirmUser = async (selectedUser: string) => {
try {
const response = await fetch(
`http://localhost:8004/default/confirm-user?username=${selectedUser}`,
`${API_BASE}/default/confirm-user?username=${selectedUser}`,
);
const data = await response.json();
setNextID(data.nextID);
@@ -129,6 +148,7 @@ export const MainForm = () => {
elevation={6}
className="w-full rounded-2xl"
sx={{
position: "relative",
backgroundColor: "#fff",
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
width: "100%",
@@ -143,6 +163,14 @@ export const MainForm = () => {
},
}}
>
<Box sx={{ position: "absolute", top: 12, right: 12 }}>
<IconButton
onClick={() => changeTranslation()}
aria-label="translate"
>
<TranslateIcon />
</IconButton>
</Box>
<form
onSubmit={(e) => {
e.preventDefault();
+3 -1
View File
@@ -1,3 +1,5 @@
import { API_BASE } from "../config/api.config";
interface FormData {
firstName: string;
lastName: string;
@@ -18,7 +20,7 @@ export const submitFormData = async (data: FormData, username: string) => {
console.log(data);
try {
const response = await fetch(
`http://localhost:8004/default/new-entry?username=${username}`,
`${API_BASE}/default/new-entry?username=${username}`,
{
method: "POST",
headers: {