From 2e290d9540cf69d64e3c3b460587ca9a60a3f0b5 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 3 Feb 2021 09:12:26 +0100 Subject: edit game rules form submit --- components/gameSettings.tsx | 63 +++++++++++++++++++++++++++++++++++---------- components/globalState.tsx | 2 +- components/ui.tsx | 2 ++ 3 files changed, 53 insertions(+), 14 deletions(-) (limited to 'components') diff --git a/components/gameSettings.tsx b/components/gameSettings.tsx index b89f429..c41d55a 100644 --- a/components/gameSettings.tsx +++ b/components/gameSettings.tsx @@ -5,15 +5,37 @@ import { DialogBox } from './dialogBox'; import BuildRoundedIcon from '@material-ui/icons/BuildRounded'; +type ruleset = { + timelimit: { + enabled: boolean; + minutes?: number; + seconds?: number; + addmove?: number; + shared: boolean; + }, + ranked: boolean; +}; + +type CurrentGameSettingsStateType = { + editGameRulesDialogVisible: boolean; + ruleset: ruleset; +} + export class CurrentGameSettings extends Component { - state: { - editGameRulesDialogVisible: boolean; - } = { - editGameRulesDialogVisible: false + state: CurrentGameSettingsStateType = { + editGameRulesDialogVisible: false, + ruleset: { // default ruleset (should be replaced in this.constructor()) + timelimit: { + enabled: false, + shared: false + }, + ranked: false + } } showEditGameRules = () => this.setState({ editGameRulesDialogVisible: true }); hideEditGameRules = () => this.setState({ editGameRulesDialogVisible: false }); + setGameRules = (newRules: ruleset) => this.setState({ ruleset: newRules }); render() { return
Geen tijdslimiet
- Standaardregels
Gerangschikt

- +
; } } @@ -122,13 +143,15 @@ function GameSettingsSection(props: { */ type editGameSettingsProps = { - parentState: { editGameRulesDialogVisible: boolean; }; + parentState: CurrentGameSettingsStateType; hideEditGameRules: () => void; + setGameRules: (newRules: ruleset) => void; }; export class EditGameSettings extends Component { constructor(props: editGameSettingsProps) { super(props); + console.log(this.props.parentState) } render () { @@ -142,28 +165,42 @@ export class EditGameSettings extends Component { overflowY: "scroll", borderRadius: 8, }}> - +
- - - + + +
- + Timer gebruiken voor bijde spelers
- + ; } diff --git a/components/globalState.tsx b/components/globalState.tsx index bf6ee40..5b01947 100644 --- a/components/globalState.tsx +++ b/components/globalState.tsx @@ -4,7 +4,7 @@ type globalState = { gameSettings: { timeLimit: { on: boolean; - time: Number; + time: number; useForBoth: boolean; } rankedGame: boolean; diff --git a/components/ui.tsx b/components/ui.tsx index a0c34a4..8745c67 100644 --- a/components/ui.tsx +++ b/components/ui.tsx @@ -66,6 +66,7 @@ export function Input(props: { id?: string; min?: number; max?: number; + value?: string|number; }) { return