import React from 'react';
import { Mutation } from 'react-apollo';
import { DateTime } from 'luxon';
import {
Paper,
Typography,
AppBar,
Tabs,
Tab,
} from '@material-ui/core';
import {
Face as BasicIcon,
Alarm as TechnicalIcon,
Group as TeamAndServerIcon,
PresentToAll as PresentationIcon,
} from '@material-ui/icons';
import { withStyles } from '@material-ui/core/styles';
import styles from './styles';
import BannerTopBar from '../../BannerTopBar';
import {
Basic,
PresentationPage,
TeamsServer,
Technical,
} from './Tabs';
import { hostedEventsCalls } from '../../../GraphQL/Calls';
function TabContainer(props) {
return (
{props.children}
);
}
class Create extends React.Component {
constructor(props) {
super(props);
this.state = {
value: 0,
title: '',
subtitle: '',
description: '',
startDatetime: DateTime.local().plus({ days: 1 }).startOf('day'),
endDatetime: DateTime.local().plus({ days: 8 }).startOf('day'),
formulaId: '',
plotterId: '',
prizes: [],
rules: [],
};
}
handleTabChange = (event, value) => {
this.setState({ value });
}
handleEventChange = (newType, newVal) => {
this.setState({ [newType]: newVal });
}
remapPrizes = (prizes) => {
const remappedPrizes = [];
prizes.forEach((prize) => {
remappedPrizes.push({
condition: {
from: parseInt(prize.from, 10),
to: parseInt(prize.to, 10),
additional: prize.additional,
},
pool: {
amount: parseInt(prize.amount, 10),
asset: prize.asset,
},
});
});
return remappedPrizes;
}
render() {
const {
title,
subtitle,
description,
startDatetime,
endDatetime,
value,
formulaId,
plotterId,
prizes,
rules,
} = this.state;
const { classes } = this.props;
return (
{
this.props.history.push(`/events/edit/${data.events_CreateEvent.id}`);
}
}
>
{hostEvent => (
}
/>
}
/>
}
disabled
/>
}
disabled
/>
Create a new event
{value === 0 &&
this.handleEventChange(newType, newVal)}
create={() => hostEvent({
variables: {
event: {
title,
subtitle,
description,
startDatetime: startDatetime.valueOf() / 1000,
endDatetime: endDatetime.valueOf() / 1000,
formulaId,
plotterId,
prizes: this.remapPrizes(prizes),
rules,
},
},
})}
/>
}
{value === 1 &&
this.handleEventChange(newType, newVal)}
create={() => hostEvent({
variables: {
event: {
title,
subtitle,
description,
startDatetime: startDatetime.valueOf() / 1000,
endDatetime: endDatetime.valueOf() / 1000,
formulaId,
plotterId,
prizes: this.remapPrizes(prizes),
rules,
},
},
})}
/>
}
{value === 2 && }
{value === 3 && }
)}
);
}
}
export default withStyles(styles)(Create);