import React from 'react'; import { Query } from 'react-apollo'; import { Typography, FormControl, InputLabel, Input, Select, FormHelperText, MenuItem, Grid, Button, } from '@material-ui/core'; import { withStyles } from '@material-ui/core/styles'; import styles from '../../styles'; import { getOptionsCalls } from '../../../../../GraphQL/Calls/index'; import { List as RulesList, New as NewRule } from './Rules'; import { List as PrizesList, New as NewPrize } from './Prizes'; import { New as NewPlotter } from './Plotter'; import { New as NewFormula } from './Formula'; class Technical extends React.Component { constructor(props) { super(props); this.state = { isNewFormulaOpen: false, isNewPlotterOpen: false, isNewRuleOpen: false, isNewPrizeOpen: false, }; } addRule = (title, description) => { this.props.edit('rules', [...this.props.event.rules, { title, description, }]); this.closeDialogs(); } addPrize = (prize) => { this.props.edit('prizes', [...this.props.event.prizes, prize]); this.closeDialogs(); } closeDialogs = () => { this.setState({ isNewFormulaOpen: false, isNewPlotterOpen: false, isNewRuleOpen: false, isNewPrizeOpen: false, }); } render() { const { classes, event, edit, create, } = this.props; const { isNewPlotterOpen, isNewFormulaOpen, isNewRuleOpen, isNewPrizeOpen, } = this.state; return ( Select the formula and the plotter you want to use, you can also create your own with the corresponding button. Select the formula {({ loading, error, data }) => { if (loading) { return ( ); } if (error) return `Error! ${error.message}`; const selects = data.events_Formulas.map((formula, index) => ( {formula.name} )); return ( { isNewFormulaOpen ? this.closeDialogs()} /> : ''} ); }} { this.setState({ isNewFormulaOpen: true }); }}> To create a new formula, click here Select the Plotter {({ loading, error, data }) => { if (loading) { return ( ); } if (error) return `Error! ${error.message}`; const selects = data.events_Plotters.map((plotter, index) => ( {plotter.name} )); return ( { isNewPlotterOpen ? this.closeDialogs()} /> : ''} ); }} { this.setState({ isNewPlotterOpen: true }); }} > To create a new plotter, click here Define the rules of your event. edit('rules', newVal)} /> { isNewRuleOpen ? this.closeDialogs()} addRule={(title, description) => this.addRule(title, description)} /> : ''} { this.setState({ isNewRuleOpen: true }); }} > To add a new rule, click here Define the prizes of your event. edit('prizes', newVal)} /> { isNewPrizeOpen ? this.closeDialogs()} addPrize={prize => this.addPrize(prize)} /> : ''} { this.setState({ isNewPrizeOpen: true }); }} > To add a new prize, click here ); } } export default withStyles(styles)(Technical);