added new frontend and renamed old frontend
This commit is contained in:
+184
-1
@@ -1 +1,184 @@
|
||||
@import "tailwindcss";
|
||||
.counter {
|
||||
font-size: 16px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
color: var(--accent);
|
||||
background: var(--accent-bg);
|
||||
border: 2px solid transparent;
|
||||
transition: border-color 0.3s;
|
||||
margin-bottom: 24px;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.hero {
|
||||
position: relative;
|
||||
|
||||
.base,
|
||||
.framework,
|
||||
.vite {
|
||||
inset-inline: 0;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.base {
|
||||
width: 170px;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.framework,
|
||||
.vite {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.framework {
|
||||
z-index: 1;
|
||||
top: 34px;
|
||||
height: 28px;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
|
||||
scale(1.4);
|
||||
}
|
||||
|
||||
.vite {
|
||||
z-index: 0;
|
||||
top: 107px;
|
||||
height: 26px;
|
||||
width: auto;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
|
||||
scale(0.8);
|
||||
}
|
||||
}
|
||||
|
||||
#center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
place-content: center;
|
||||
place-items: center;
|
||||
flex-grow: 1;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
padding: 32px 20px 24px;
|
||||
gap: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps {
|
||||
display: flex;
|
||||
border-top: 1px solid var(--border);
|
||||
text-align: left;
|
||||
|
||||
& > div {
|
||||
flex: 1 1 0;
|
||||
padding: 32px;
|
||||
@media (max-width: 1024px) {
|
||||
padding: 24px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-bottom: 16px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
#docs {
|
||||
border-right: 1px solid var(--border);
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin: 32px 0 0;
|
||||
|
||||
.logo {
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--text-h);
|
||||
font-size: 16px;
|
||||
border-radius: 6px;
|
||||
background: var(--social-bg);
|
||||
display: flex;
|
||||
padding: 6px 12px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
transition: box-shadow 0.3s;
|
||||
|
||||
&:hover {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.button-icon {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
margin-top: 20px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
|
||||
li {
|
||||
flex: 1 1 calc(50% - 8px);
|
||||
}
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#spacer {
|
||||
height: 88px;
|
||||
border-top: 1px solid var(--border);
|
||||
@media (max-width: 1024px) {
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
.ticks {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -4.5px;
|
||||
border: 5px solid transparent;
|
||||
}
|
||||
|
||||
&::before {
|
||||
left: 0;
|
||||
border-left-color: var(--border);
|
||||
}
|
||||
&::after {
|
||||
right: 0;
|
||||
border-right-color: var(--border);
|
||||
}
|
||||
}
|
||||
|
||||
+117
-12
@@ -1,17 +1,122 @@
|
||||
import "./App.css";
|
||||
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
||||
import { MainForm } from "./pages/MainForm";
|
||||
import { SuccessPage } from "./pages/SuccessPage";
|
||||
import { useState } from 'react'
|
||||
import reactLogo from './assets/react.svg'
|
||||
import viteLogo from './assets/vite.svg'
|
||||
import heroImg from './assets/hero.png'
|
||||
import './App.css'
|
||||
|
||||
function App() {
|
||||
const [count, setCount] = useState(0)
|
||||
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<MainForm />} />
|
||||
<Route path="/success" element={<SuccessPage />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
);
|
||||
<>
|
||||
<section id="center">
|
||||
<div className="hero">
|
||||
<img src={heroImg} className="base" width="170" height="179" alt="" />
|
||||
<img src={reactLogo} className="framework" alt="React logo" />
|
||||
<img src={viteLogo} className="vite" alt="Vite logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h1>Get started</h1>
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to test <code>HMR</code>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="counter"
|
||||
onClick={() => setCount((count) => count + 1)}
|
||||
>
|
||||
Count is {count}
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<div className="ticks"></div>
|
||||
|
||||
<section id="next-steps">
|
||||
<div id="docs">
|
||||
<svg className="icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#documentation-icon"></use>
|
||||
</svg>
|
||||
<h2>Documentation</h2>
|
||||
<p>Your questions, answered</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://vite.dev/" target="_blank">
|
||||
<img className="logo" src={viteLogo} alt="" />
|
||||
Explore Vite
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://react.dev/" target="_blank">
|
||||
<img className="button-icon" src={reactLogo} alt="" />
|
||||
Learn more
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="social">
|
||||
<svg className="icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#social-icon"></use>
|
||||
</svg>
|
||||
<h2>Connect with us</h2>
|
||||
<p>Join the Vite community</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://github.com/vitejs/vite" target="_blank">
|
||||
<svg
|
||||
className="button-icon"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<use href="/icons.svg#github-icon"></use>
|
||||
</svg>
|
||||
GitHub
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://chat.vite.dev/" target="_blank">
|
||||
<svg
|
||||
className="button-icon"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<use href="/icons.svg#discord-icon"></use>
|
||||
</svg>
|
||||
Discord
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://x.com/vite_js" target="_blank">
|
||||
<svg
|
||||
className="button-icon"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<use href="/icons.svg#x-icon"></use>
|
||||
</svg>
|
||||
X.com
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://bsky.app/profile/vite.dev" target="_blank">
|
||||
<svg
|
||||
className="button-icon"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<use href="/icons.svg#bluesky-icon"></use>
|
||||
</svg>
|
||||
Bluesky
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="ticks"></div>
|
||||
<section id="spacer"></section>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
@@ -1,4 +0,0 @@
|
||||
export const API_BASE =
|
||||
(import.meta as any).env?.VITE_BACKEND_URL ||
|
||||
import.meta.env.VITE_BACKEND_URL ||
|
||||
"http://localhost:8004";
|
||||
+111
-1
@@ -1 +1,111 @@
|
||||
@import "tailwindcss";
|
||||
:root {
|
||||
--text: #6b6375;
|
||||
--text-h: #08060d;
|
||||
--bg: #fff;
|
||||
--border: #e5e4e7;
|
||||
--code-bg: #f4f3ec;
|
||||
--accent: #aa3bff;
|
||||
--accent-bg: rgba(170, 59, 255, 0.1);
|
||||
--accent-border: rgba(170, 59, 255, 0.5);
|
||||
--social-bg: rgba(244, 243, 236, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
|
||||
|
||||
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
--heading: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
--mono: ui-monospace, Consolas, monospace;
|
||||
|
||||
font: 18px/145% var(--sans);
|
||||
letter-spacing: 0.18px;
|
||||
color-scheme: light dark;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--text: #9ca3af;
|
||||
--text-h: #f3f4f6;
|
||||
--bg: #16171d;
|
||||
--border: #2e303a;
|
||||
--code-bg: #1f2028;
|
||||
--accent: #c084fc;
|
||||
--accent-bg: rgba(192, 132, 252, 0.15);
|
||||
--accent-border: rgba(192, 132, 252, 0.5);
|
||||
--social-bg: rgba(47, 48, 58, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
|
||||
}
|
||||
|
||||
#social .button-icon {
|
||||
filter: invert(1) brightness(2);
|
||||
}
|
||||
}
|
||||
|
||||
#root {
|
||||
width: 1126px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
border-inline: 1px solid var(--border);
|
||||
min-height: 100svh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
font-family: var(--heading);
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 56px;
|
||||
letter-spacing: -1.68px;
|
||||
margin: 32px 0;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 36px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
}
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
line-height: 118%;
|
||||
letter-spacing: -0.24px;
|
||||
margin: 0 0 8px;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code,
|
||||
.counter {
|
||||
font-family: var(--mono);
|
||||
display: inline-flex;
|
||||
border-radius: 4px;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 15px;
|
||||
line-height: 135%;
|
||||
padding: 4px 8px;
|
||||
background: var(--code-bg);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import "./index.css";
|
||||
import "./utils/i18n";
|
||||
import App from "./App.tsx";
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>
|
||||
);
|
||||
</StrictMode>,
|
||||
)
|
||||
|
||||
@@ -1,514 +0,0 @@
|
||||
import {
|
||||
TextField,
|
||||
FormControlLabel,
|
||||
Checkbox,
|
||||
Button,
|
||||
Alert,
|
||||
CircularProgress,
|
||||
Autocomplete,
|
||||
Chip,
|
||||
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";
|
||||
headline: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export const MainForm = () => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [invoice, setInvoice] = useState(false);
|
||||
const [msg, setMsg] = useState<Message | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [nextID, setNextID] = useState<number | null>(null);
|
||||
const [formData, setFormData] = useState({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
phoneNumber: "",
|
||||
tickets: 1,
|
||||
companyName: "",
|
||||
cmpFirstName: "",
|
||||
cpmLastName: "",
|
||||
cpmEmail: "",
|
||||
cpmPhoneNumber: "",
|
||||
street: "",
|
||||
postalCode: "",
|
||||
paymentMethod: "",
|
||||
});
|
||||
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(`${API_BASE}/default/users`);
|
||||
const data = await response.json();
|
||||
setUsers(data.users);
|
||||
};
|
||||
fetchUsers();
|
||||
console.log(users);
|
||||
} catch (error) {
|
||||
setMsg({
|
||||
type: "error",
|
||||
headline: t("error"),
|
||||
text: t("failed-to-load-users"),
|
||||
});
|
||||
console.error("Error fetching users:", error);
|
||||
}
|
||||
|
||||
if (Cookies.get("selectedUser")) {
|
||||
const cookieUser = Cookies.get("selectedUser")!;
|
||||
setSelectedUser(cookieUser);
|
||||
confirmUser(cookieUser);
|
||||
}
|
||||
}, [isLoading]);
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setFormData({ ...formData, [e.target.name]: e.target.value });
|
||||
};
|
||||
|
||||
const confirmUser = async (selectedUser: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${API_BASE}/default/confirm-user?username=${selectedUser}`,
|
||||
);
|
||||
const data = await response.json();
|
||||
setNextID(data.nextID);
|
||||
} catch (error) {
|
||||
console.error("Error confirming user:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUserSelection = (selectedUser: string | null) => {
|
||||
if (!selectedUser) return;
|
||||
setSelectedUser(selectedUser);
|
||||
confirmUser(selectedUser);
|
||||
Cookies.set("selectedUser", selectedUser);
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const result = await submitFormData(formData, selectedUser || "");
|
||||
if (result.success) {
|
||||
document.location.href = `/success?id=${nextID}&tickets=${formData.tickets}`;
|
||||
} else {
|
||||
setMsg({
|
||||
type: "error",
|
||||
headline: t("error"),
|
||||
text: result.error || t("form-submission-failed"),
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box
|
||||
className="bg-gray-100 py-10 px-4"
|
||||
sx={{
|
||||
minHeight: "100vh",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Paper
|
||||
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%",
|
||||
maxWidth: {
|
||||
xs: 360, // kompakte Handy-Ansicht
|
||||
sm: 420, // kleine Tablets / große Phones
|
||||
md: 480, // Desktop, bleibt angenehm schmal
|
||||
},
|
||||
padding: {
|
||||
xs: "1.5rem",
|
||||
sm: "2rem",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Box sx={{ position: "absolute", top: 12, right: 12 }}>
|
||||
<IconButton
|
||||
onClick={() => changeTranslation()}
|
||||
aria-label="translate"
|
||||
>
|
||||
<TranslateIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleSubmit();
|
||||
}}
|
||||
className="flex flex-col gap-4"
|
||||
>
|
||||
{/* User Selection */}
|
||||
<Autocomplete
|
||||
disablePortal
|
||||
options={users}
|
||||
value={selectedUser}
|
||||
fullWidth
|
||||
renderInput={(params) => (
|
||||
<TextField {...params} label={t("user")} variant="filled" />
|
||||
)}
|
||||
onChange={(_event, value) => handleUserSelection(value)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.defaultMuiPrevented = true;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Next ID Chip */}
|
||||
<Chip
|
||||
label={`#${nextID ?? "N/A"}`}
|
||||
color="primary"
|
||||
sx={{
|
||||
alignSelf: "flex-start",
|
||||
fontWeight: 500,
|
||||
fontSize: "0.9rem",
|
||||
mt: 0.5,
|
||||
mb: 0.5,
|
||||
py: 0.5,
|
||||
px: 1.25,
|
||||
borderRadius: "999px",
|
||||
background: "linear-gradient(135deg, #1976d2 0%, #1565c0 100%)",
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Name Fields - Two Columns */}
|
||||
<Box className="grid grid-cols-2 gap-3">
|
||||
<TextField
|
||||
required
|
||||
id="first-name"
|
||||
label={t("first-name")}
|
||||
variant="filled"
|
||||
value={formData.firstName}
|
||||
onChange={handleChange}
|
||||
name="firstName"
|
||||
fullWidth
|
||||
/>
|
||||
<TextField
|
||||
required
|
||||
id="last-name"
|
||||
label={t("last-name")}
|
||||
variant="filled"
|
||||
value={formData.lastName}
|
||||
onChange={handleChange}
|
||||
name="lastName"
|
||||
fullWidth
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Email */}
|
||||
<TextField
|
||||
required
|
||||
id="email"
|
||||
label={t("email")}
|
||||
variant="filled"
|
||||
type="email"
|
||||
value={formData.email}
|
||||
onChange={handleChange}
|
||||
name="email"
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
{/* Phone Number */}
|
||||
<TextField
|
||||
required
|
||||
id="phone-number"
|
||||
label={t("phone-number")}
|
||||
variant="filled"
|
||||
type="tel"
|
||||
value={formData.phoneNumber}
|
||||
onChange={handleChange}
|
||||
name="phoneNumber"
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
{/* Tickets and Invoice Checkbox */}
|
||||
<Box className="grid grid-cols-2 gap-3 items-center">
|
||||
<TextField
|
||||
required
|
||||
id="tickets"
|
||||
type="number"
|
||||
label={t("tickets")}
|
||||
variant="filled"
|
||||
value={formData.tickets}
|
||||
onChange={handleChange}
|
||||
name="tickets"
|
||||
fullWidth
|
||||
inputProps={{ min: 1 }}
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={invoice}
|
||||
onChange={(e) => setInvoice(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={t("invoice")}
|
||||
className="justify-end"
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Invoice Fields */}
|
||||
{invoice && (
|
||||
<Box
|
||||
className="flex flex-col gap-2 pt-3 mt-2"
|
||||
sx={{
|
||||
borderTop: "2px solid",
|
||||
borderColor: "primary.light",
|
||||
borderRadius: "0",
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
required
|
||||
id="company-name"
|
||||
label={t("company-name")}
|
||||
variant="filled"
|
||||
value={formData.companyName}
|
||||
onChange={handleChange}
|
||||
name="companyName"
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
{/* Invoice Name Fields - Two Columns */}
|
||||
<Box className="grid grid-cols-2 gap-3">
|
||||
<TextField
|
||||
required
|
||||
id="first-name_invoice"
|
||||
label={t("first-name")}
|
||||
variant="filled"
|
||||
value={formData.cmpFirstName}
|
||||
onChange={handleChange}
|
||||
name="cmpFirstName"
|
||||
fullWidth
|
||||
/>
|
||||
<TextField
|
||||
required
|
||||
id="last-name_invoice"
|
||||
label={t("last-name")}
|
||||
variant="filled"
|
||||
value={formData.cpmLastName}
|
||||
onChange={handleChange}
|
||||
name="cpmLastName"
|
||||
fullWidth
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<TextField
|
||||
required
|
||||
id="street"
|
||||
label={t("street")}
|
||||
variant="filled"
|
||||
value={formData.street}
|
||||
onChange={handleChange}
|
||||
name="street"
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
<TextField
|
||||
required
|
||||
id="postal-code"
|
||||
label={t("postal-code")}
|
||||
variant="filled"
|
||||
value={formData.postalCode}
|
||||
onChange={handleChange}
|
||||
name="postalCode"
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
<TextField
|
||||
required
|
||||
id="phone-number_invoice"
|
||||
label={t("phone-number")}
|
||||
variant="filled"
|
||||
type="tel"
|
||||
value={formData.cpmPhoneNumber}
|
||||
onChange={handleChange}
|
||||
name="cpmPhoneNumber"
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
<TextField
|
||||
required
|
||||
id="email_invoice"
|
||||
label={t("email")}
|
||||
variant="filled"
|
||||
type="email"
|
||||
value={formData.cpmEmail}
|
||||
onChange={handleChange}
|
||||
name="cpmEmail"
|
||||
fullWidth
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
{/* Payment Methods */}
|
||||
<Box className="flex flex-col gap-2 mt-2">
|
||||
<Typography
|
||||
component="label"
|
||||
sx={{
|
||||
fontSize: "0.875rem",
|
||||
fontWeight: 500,
|
||||
color: "text.secondary",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: 0.5,
|
||||
}}
|
||||
>
|
||||
{t("select-payment-method")} *
|
||||
</Typography>
|
||||
<Box className="flex gap-2 flex-wrap">
|
||||
<Button
|
||||
variant={
|
||||
formData.paymentMethod === "bar" ? "contained" : "outlined"
|
||||
}
|
||||
onClick={() =>
|
||||
setFormData({ ...formData, paymentMethod: "bar" })
|
||||
}
|
||||
sx={{
|
||||
flex: 1,
|
||||
minWidth: "100px",
|
||||
py: 1.5,
|
||||
borderRadius: "12px",
|
||||
textTransform: "none",
|
||||
fontWeight: formData.paymentMethod === "bar" ? 600 : 400,
|
||||
}}
|
||||
>
|
||||
{t("cash")}
|
||||
</Button>
|
||||
<Button
|
||||
variant={
|
||||
formData.paymentMethod === "paypal" ? "contained" : "outlined"
|
||||
}
|
||||
onClick={() =>
|
||||
setFormData({ ...formData, paymentMethod: "paypal" })
|
||||
}
|
||||
sx={{
|
||||
flex: 1,
|
||||
minWidth: "100px",
|
||||
py: 1.5,
|
||||
borderRadius: "12px",
|
||||
textTransform: "none",
|
||||
fontWeight: formData.paymentMethod === "paypal" ? 600 : 400,
|
||||
}}
|
||||
>
|
||||
{t("paypal")}
|
||||
</Button>
|
||||
<Button
|
||||
variant={
|
||||
formData.paymentMethod === "andere" ? "contained" : "outlined"
|
||||
}
|
||||
onClick={() =>
|
||||
setFormData({ ...formData, paymentMethod: "andere" })
|
||||
}
|
||||
sx={{
|
||||
flex: 1,
|
||||
minWidth: "100px",
|
||||
py: 1.5,
|
||||
borderRadius: "12px",
|
||||
textTransform: "none",
|
||||
fontWeight: formData.paymentMethod === "andere" ? 600 : 400,
|
||||
}}
|
||||
>
|
||||
{t("transfer")}
|
||||
</Button>
|
||||
</Box>
|
||||
{!formData.paymentMethod && (
|
||||
<input
|
||||
tabIndex={-1}
|
||||
autoComplete="off"
|
||||
style={{
|
||||
opacity: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
position: "absolute",
|
||||
}}
|
||||
required
|
||||
value={formData.paymentMethod}
|
||||
onChange={() => {}}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* Submit Button */}
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
disabled={isLoading || !formData.paymentMethod}
|
||||
fullWidth
|
||||
size="large"
|
||||
sx={{
|
||||
mt: 3,
|
||||
py: 2,
|
||||
textTransform: "uppercase",
|
||||
fontWeight: "bold",
|
||||
borderRadius: "12px",
|
||||
fontSize: "1rem",
|
||||
background: "linear-gradient(135deg, #1976d2 0%, #1565c0 100%)",
|
||||
boxShadow: "0 4px 14px 0 rgba(25, 118, 210, 0.39)",
|
||||
"&:hover": {
|
||||
background: "linear-gradient(135deg, #1565c0 0%, #0d47a1 100%)",
|
||||
boxShadow: "0 6px 20px 0 rgba(25, 118, 210, 0.5)",
|
||||
},
|
||||
"&:disabled": {
|
||||
background: "#e0e0e0",
|
||||
boxShadow: "none",
|
||||
},
|
||||
}}
|
||||
>
|
||||
{isLoading ? (
|
||||
<CircularProgress size={24} color="inherit" />
|
||||
) : (
|
||||
t("submit")
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{/* Alert Message */}
|
||||
{msg && (
|
||||
<Alert severity={msg.type} sx={{ mt: 2 }}>
|
||||
{msg.headline}: {msg.text}
|
||||
</Alert>
|
||||
)}
|
||||
</form>
|
||||
</Paper>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -1,210 +0,0 @@
|
||||
import { Box, Paper, Typography, Chip, Button } from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
import { CircleCheck } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export const SuccessPage = () => {
|
||||
const [orderId, setOrderId] = useState<string | null>(null);
|
||||
const [tickets, setNumberOfTickets] = useState<number>(0);
|
||||
const [animate, setAnimate] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const [seconds, setSeconds] = useState(30);
|
||||
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const id = params.get("id");
|
||||
const numberOfTickets = params.get("tickets");
|
||||
|
||||
setOrderId(id);
|
||||
setNumberOfTickets(numberOfTickets ? parseInt(numberOfTickets, 10) : 0);
|
||||
|
||||
setTimeout(() => setAnimate(true), 100);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (seconds === 0) {
|
||||
window.location.href = "/";
|
||||
return;
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => setSeconds(seconds - 1), 1000);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [seconds]);
|
||||
|
||||
return (
|
||||
<Box className="min-h-screen bg-gray-800 flex items-center justify-center p-4">
|
||||
<Paper
|
||||
elevation={3}
|
||||
className="w-full max-w-md p-8 rounded-lg"
|
||||
sx={{
|
||||
backgroundColor: "#fff",
|
||||
textAlign: "center",
|
||||
position: "relative",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
{/* Animated Success Icon */}
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
mb: 3,
|
||||
transition: "all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)",
|
||||
transform: animate ? "scale(1)" : "scale(0)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<CircleCheck size={80} className="text-green-500" strokeWidth={2.5} />
|
||||
</Box>
|
||||
|
||||
{/* Success Message */}
|
||||
<Typography
|
||||
variant="h4"
|
||||
component="h1"
|
||||
gutterBottom
|
||||
sx={{
|
||||
fontWeight: "bold",
|
||||
color: "#2e7d32",
|
||||
mb: 2,
|
||||
transition: "all 0.5s ease-in-out 0.2s",
|
||||
transform: animate ? "translateY(0)" : "translateY(20px)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
{t("form-submitted-successfully")}
|
||||
</Typography>
|
||||
|
||||
<Typography
|
||||
variant="body1"
|
||||
sx={{
|
||||
color: "#666",
|
||||
mb: 3,
|
||||
transition: "all 0.5s ease-in-out 0.3s",
|
||||
transform: animate ? "translateY(0)" : "translateY(20px)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
{t("ticket-payment", { count: tickets })}
|
||||
</Typography>
|
||||
|
||||
{/* Tickets Display */}
|
||||
{tickets > 0 && (
|
||||
<Box
|
||||
sx={{
|
||||
mb: 2,
|
||||
transition: "all 0.5s ease-in-out 0.35s",
|
||||
transform: animate ? "translateY(0)" : "translateY(20px)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<Chip
|
||||
label={`${tickets} ${tickets === 1 ? t("ticket") : t("tickets")}`}
|
||||
color="secondary"
|
||||
sx={{
|
||||
fontWeight: "bold",
|
||||
fontSize: "1rem",
|
||||
py: 2.5,
|
||||
px: 2,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Order ID Display */}
|
||||
{orderId && (
|
||||
<Box
|
||||
sx={{
|
||||
mb: 3,
|
||||
transition: "all 0.5s ease-in-out 0.4s",
|
||||
transform: animate ? "translateY(0)" : "translateY(20px)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
color: "#888",
|
||||
mb: 1,
|
||||
fontSize: "0.875rem",
|
||||
}}
|
||||
>
|
||||
{t("entry-id")}
|
||||
</Typography>
|
||||
<Chip
|
||||
label={`#${orderId}`}
|
||||
color="primary"
|
||||
sx={{
|
||||
fontWeight: "bold",
|
||||
fontSize: "1.25rem",
|
||||
py: 3,
|
||||
px: 2,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Return button */}
|
||||
<Box
|
||||
sx={{
|
||||
mb: 3,
|
||||
transition: "all 0.5s ease-in-out 0.4s",
|
||||
transform: animate ? "translateY(0)" : "translateY(20px)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
href="/"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
sx={{
|
||||
fontWeight: "bold",
|
||||
fontSize: "1.25rem",
|
||||
py: 3,
|
||||
px: 2,
|
||||
}}
|
||||
>
|
||||
{seconds + " " + t("return-to-homepage")}
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{/* Additional Info */}
|
||||
<Box
|
||||
sx={{
|
||||
mt: 4,
|
||||
pt: 3,
|
||||
borderTop: "1px solid #e0e0e0",
|
||||
transition: "all 0.5s ease-in-out 0.5s",
|
||||
transform: animate ? "translateY(0)" : "translateY(20px)",
|
||||
opacity: animate ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
color: "#666",
|
||||
lineHeight: 1.6,
|
||||
}}
|
||||
>
|
||||
{t("thank-you")}
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
{/* Decorative Elements */}
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: "4px",
|
||||
background: "linear-gradient(90deg, #4caf50 0%, #81c784 100%)",
|
||||
transition: "all 0.8s ease-in-out 0.6s",
|
||||
transform: animate ? "scaleX(1)" : "scaleX(0)",
|
||||
transformOrigin: "left",
|
||||
}}
|
||||
/>
|
||||
</Paper>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
import enLang from "./locales/en/en.json";
|
||||
import deLang from "./locales/de/de.json";
|
||||
|
||||
// the translations
|
||||
// (tip move them in a JSON file and import them,
|
||||
// or even better, manage them separated from your code: https://react.i18next.com/guides/multiple-translation-files)
|
||||
const resources = {
|
||||
en: {
|
||||
translation: enLang,
|
||||
},
|
||||
de: {
|
||||
translation: deLang,
|
||||
},
|
||||
};
|
||||
|
||||
i18n
|
||||
.use(initReactI18next) // passes i18n down to react-i18next
|
||||
.init({
|
||||
resources,
|
||||
fallbackLng: "en", // use en if detected lng is not available
|
||||
lng: Cookies.get("language") || navigator.language.split("-")[0] || "en", // Check cookie first, then browser language
|
||||
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
|
||||
// if you're using a language detector, do not define the lng option
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false, // react already safes from xss
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"first-name": "Vorname",
|
||||
"last-name": "Nachname",
|
||||
"phone-number": "Telefonnummer",
|
||||
"tickets": "Lose",
|
||||
"invoice": "Rechnung",
|
||||
"company-name": "Firmenname",
|
||||
"street": "Straße + Haus Nr.",
|
||||
"postal-code": "Plz + Stadt",
|
||||
"email": "E-Mail",
|
||||
"submit": "Abschicken",
|
||||
"failed-to-load-users": "Das Laden der Benutzer ist fehlgeschlagen.",
|
||||
"user": "Benutzer",
|
||||
"next-id": "Nächste Eintragsnummer: ",
|
||||
"form-submitted-successfully": "Formular erfolgreich übermittelt!",
|
||||
"orm-submission-failed": "Formularübermittlung fehlgeschlagen.",
|
||||
"success": "Erfolg",
|
||||
"error": "Fehler",
|
||||
"cash": "Bar",
|
||||
"paypal": "PayPal",
|
||||
"transfer": "Andere (notieren)",
|
||||
"ticket-payment_one": "Sie haben erfolgreich {{count}} Los gekauft.",
|
||||
"ticket-payment_other": "Sie haben erfolgreich {{count}} Lose gekauft.",
|
||||
"entry-id": "Eintrags-ID",
|
||||
"thank-you": "Vielen Dank für Ihre Unterstützung der Claudius Akademie! Wir wünschen Ihnen viel Glück mit dem Los.",
|
||||
"select-payment-method": "Zahlungsmethode auswählen",
|
||||
"return-to-homepage": "Zurück"
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"first-name": "First Name",
|
||||
"last-name": "Last Name",
|
||||
"phone-number": "Phone Number",
|
||||
"invoice": "Invoice",
|
||||
"company-name": "Company Name",
|
||||
"street": "Street + House No.",
|
||||
"postal-code": "Postal Code + City",
|
||||
"email": "Email",
|
||||
"submit": "Submit Form",
|
||||
"failed-to-load-users": "Failed to load users.",
|
||||
"user": "User",
|
||||
"next-id": "Next Entry Number: ",
|
||||
"form-submitted-successfully": "Form submitted successfully!",
|
||||
"orm-submission-failed": "Form submission failed.",
|
||||
"success": "Success",
|
||||
"error": "Error",
|
||||
"cash": "Cash",
|
||||
"paypal": "PayPal",
|
||||
"transfer": "Other (note down)",
|
||||
"ticket-payment_one": "You have successfully purchased {{count}} ticket.",
|
||||
"ticket-payment_other": "You have successfully purchased {{count}} tickets.",
|
||||
"ticket": "Ticket",
|
||||
"tickets": "Tickets",
|
||||
"entry-id": "Entry ID",
|
||||
"thank-you": "Thank you for supporting the Claudius Akademie! We wish you the best of luck with your ticket.",
|
||||
"select-payment-method": "Select Payment Method",
|
||||
"return-to-homepage": "Return"
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import { API_BASE } from "../config/api.config";
|
||||
|
||||
interface FormData {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
phoneNumber: string;
|
||||
tickets: number;
|
||||
companyName: string;
|
||||
cmpFirstName: string;
|
||||
cpmLastName: string;
|
||||
cpmEmail: string;
|
||||
cpmPhoneNumber: string;
|
||||
street: string;
|
||||
postalCode: string;
|
||||
paymentMethod: string;
|
||||
}
|
||||
|
||||
export const submitFormData = async (data: FormData, username: string) => {
|
||||
console.log(data);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${API_BASE}/default/new-entry?username=${username}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
return { success: false, error: `Server error: ${errorText}` };
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
return { success: false, error: (error as Error).message };
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user