improved choosing payment method

This commit is contained in:
2026-01-21 15:51:38 +01:00
parent 697e84b5ea
commit 308b21ae6c
3 changed files with 64 additions and 10 deletions

View File

@@ -9,11 +9,14 @@ import {
Chip, Chip,
Box, Box,
Paper, Paper,
Menu,
MenuItem,
} from "@mui/material"; } from "@mui/material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { submitFormData } from "../utils/sender"; import { submitFormData } from "../utils/sender";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import * as React from "react";
interface Message { interface Message {
type: "error" | "info" | "success" | "warning"; type: "error" | "info" | "success" | "warning";
@@ -45,6 +48,16 @@ export const MainForm = () => {
const [users, setUsers] = useState<string[]>([]); const [users, setUsers] = useState<string[]>([]);
const [selectedUser, setSelectedUser] = useState<string | null>(null); const [selectedUser, setSelectedUser] = useState<string | null>(null);
// Payment Methods Menu States
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
useEffect(() => { useEffect(() => {
// Fetch user data or any other data needed for the form // Fetch user data or any other data needed for the form
try { try {
@@ -317,13 +330,52 @@ export const MainForm = () => {
/> />
</Box> </Box>
)} )}
{/* Payment Methods */} {/* Payment Methods */}
<Box className="flex justify-center gap-4 pt-2"> <Button
<FormControlLabel control={<Checkbox />} label={t("cash")} /> id="basic-button"
<FormControlLabel control={<Checkbox />} label={t("paypal")} /> aria-controls={open ? "basic-menu" : undefined}
<FormControlLabel control={<Checkbox />} label={t("transfer")} /> aria-haspopup="true"
</Box> aria-expanded={open ? "true" : undefined}
onClick={handleClick}
>
{formData.paymentMethod || t("select-payment-method")}
</Button>
<Menu
id="basic-menu"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
slotProps={{
list: {
"aria-labelledby": "basic-button",
},
}}
>
<MenuItem
onClick={() => {
setFormData({ ...formData, paymentMethod: "bar" });
handleClose();
}}
>
{t("cash")}
</MenuItem>
<MenuItem
onClick={() => {
setFormData({ ...formData, paymentMethod: "paypal" });
handleClose();
}}
>
{t("paypal")}
</MenuItem>
<MenuItem
onClick={() => {
setFormData({ ...formData, paymentMethod: "andere" });
handleClose();
}}
>
{t("transfer")}
</MenuItem>
</Menu>
{/* Submit Button */} {/* Submit Button */}
<Button <Button

View File

@@ -18,8 +18,9 @@
"error": "Fehler", "error": "Fehler",
"cash": "Bar", "cash": "Bar",
"paypal": "PayPal", "paypal": "PayPal",
"transfer": "Überweisung", "transfer": "Andere (notieren)",
"ticket-payment": "Sie haben erflogreich {count} {count, plural, one {Los} other {Lose}} gekauft.", "ticket-payment": "Sie haben erflogreich {count} {count, plural, one {Los} other {Lose}} gekauft.",
"entry-id": "Eintrags-ID", "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." "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"
} }

View File

@@ -17,11 +17,12 @@
"error": "Error", "error": "Error",
"cash": "Cash", "cash": "Cash",
"paypal": "PayPal", "paypal": "PayPal",
"transfer": "Bank Transfer", "transfer": "Other (note down)",
"ticket-payment_one": "You have successfully purchased {{count}} ticket.", "ticket-payment_one": "You have successfully purchased {{count}} ticket.",
"ticket-payment_other": "You have successfully purchased {{count}} tickets.", "ticket-payment_other": "You have successfully purchased {{count}} tickets.",
"ticket": "ticket", "ticket": "ticket",
"tickets": "tickets", "tickets": "tickets",
"entry-id": "Entry ID", "entry-id": "Entry ID",
"thank-you": "Thank you for supporting the Claudius Akademie! We wish you the best of luck with your ticket." "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"
} }