import { ReactNode, Component } from 'react'; import axios from 'axios'; import { Button, Vierkant, CheckBox, Input } from './ui'; import { DialogBox } from './dialogBox'; import { ruleset, userPreferences } from '../api/api'; import BuildOutlinedIcon from '@material-ui/icons/BuildOutlined'; type CurrentGameSettingsStateType = { editGameRulesDialogVisible: boolean; ruleset: ruleset; } export class CurrentGameSettings extends Component { state: CurrentGameSettingsStateType = { editGameRulesDialogVisible: false, ruleset: { timelimit: { enabled: false, shared: false }, ranked: false } } constructor(props: {}) { super(props); if (typeof window === "undefined") return; // return if run on server axios.request({ method: "get", url: `/api/user/preferences`, headers: {"content-type": "application/json"} }) //FIXME: this assumes the request ruleset has all properties of a ruleset .then(request => this.setState({ ruleset: request.data.ruleset || this.state.ruleset })) .catch(() => {}); } showEditGameRules = () => this.setState({ editGameRulesDialogVisible: true }); hideEditGameRules = () => this.setState({ editGameRulesDialogVisible: false }); setGameRules = (newRules: ruleset) => this.setState({ ruleset: newRules }); render() { var timelimit_str = this.state.ruleset.timelimit.enabled ? `${this.state.ruleset.timelimit.minutes}m${this.state.ruleset.timelimit.seconds}s plus ${this.state.ruleset.timelimit.addmove}` : "Geen tijdslimiet" var ranked_str = this.state.ruleset.ranked ? "Gerangschikt" : "Niet gerangschikt" return

{timelimit_str}
{ranked_str}

; } } function GameSettingsSection(props: { children?: ReactNode; title: string; state: boolean; noMarginBottom?: boolean; id: string; }) { return {props.title}
{props.children}
} /* function GameRule(props: { */ /* title: string; */ /* description: string; */ /* style?: CSSProperties; */ /* }) { */ /* return
*/ /*

{props.title}

*/ /*

{props.description}

*/ /*
; */ /* } */ /*
*/ type editGameSettingsProps = { parentState: CurrentGameSettingsStateType; hideEditGameRules: () => void; setGameRules: (newRules: ruleset) => void; }; export class EditGameSettings extends Component { render () { return
Timer gebruiken voor bijde spelers
; } }