diff --git a/client/src/pages/Join/states/Input/Input.jsx b/client/src/pages/Join/states/Input/Input.jsx index 218069f..9b8b287 100644 --- a/client/src/pages/Join/states/Input/Input.jsx +++ b/client/src/pages/Join/states/Input/Input.jsx @@ -4,7 +4,7 @@ import {useEffect, useState} from "react"; import {socket} from "@/common/utils/socket.js"; import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; -export const Input = ({setState, capital, setCost, setWin}) => { +export const Input = ({setState, capital, setCost, setWin, settings}) => { const [price, setPrice] = useState(1000); const [amount, setAmount] = useState(10); @@ -12,7 +12,7 @@ export const Input = ({setState, capital, setCost, setWin}) => { const [error, setError] = useState(""); const submit = () => { - if ((1000 * amount + 4000) > capital) { + if ((settings.costPerCake * amount + settings.costPerRound) > capital) { setError("Zu wenig Kapital"); return; } @@ -36,10 +36,12 @@ export const Input = ({setState, capital, setCost, setWin}) => { }, [error]); useEffect(() => { - setCost(1000 * amount + 4000); - setWin((price * amount) - (1000 * amount + 4000)); + setCost(settings.costPerCake * amount + settings.costPerRound); + setWin((price * amount) - (settings.costPerCake * amount + settings.costPerRound)); }, [price, amount]); + if (!settings || Object.keys(settings).length === 0) return null; + return ( <> {error &&
@@ -48,13 +50,13 @@ export const Input = ({setState, capital, setCost, setWin}) => {
}

Preis

- e.target.value <= 10000 && setPrice(e.target.value)} value={price}/> + e.target.value <= settings.maxPrice && setPrice(e.target.value)} value={price}/>

Absatzmenge

- e.target.value <= 20 && setAmount(e.target.value)} value={amount}/> + e.target.value <= settings.maxProduction && setAmount(e.target.value)} value={amount}/>