Installing a clean linter for the frontend

This commit is contained in:
Nikola Bjelo committed 2018-11-06 02:38:16 +01:00
1 parent 6dd6fac7e6
commit b14828655f
33 files changed
+607 -401

No files matched your search

+17 -15
View File
@@ -1,27 +1,27 @@
import React from 'react'
import { Link } from 'react-router-dom'
import React from 'react';
import { Link } from 'react-router-dom';
import {
Grid, Paper,
Typography,
Button
} from '@material-ui/core'
import { withStyles } from '@material-ui/core/styles'
import styles from './styles'
Button,
} from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import styles from './styles';
import { toLocalTime } from '../../utils'
import { toLocalTime } from '../../utils';
class Event extends React.Component {
render () {
const classes = this.props.classes
render() {
const { classes } = this.props;
const {
name,
designator,
startDatetime,
finishDatetime,
host,
description
} = this.props.event
description,
} = this.props.event;
return (
<Paper className={classes.card}>
<Grid container spacing={16}>
@@ -31,7 +31,9 @@ class Event extends React.Component {
<Typography gutterBottom>To : {toLocalTime(finishDatetime)} </Typography>
</Grid>
<Grid item xs>
<Typography gutterBottom>Hosted by: {host.alias} ({host.lastName} {host.firstName}) </Typography>
<Typography gutterBottom>
Hosted by: {host.alias} ({host.lastName} {host.firstName})
</Typography>
<Typography gutterBottom>Formula: </Typography>
<Typography gutterBottom>First prize: </Typography>
</Grid>
@@ -48,7 +50,7 @@ class Event extends React.Component {
color='primary'
size='small'
component={Link}
to={'/show/' + designator}
to={`/show/${designator}`}
>
Show
</Button>
@@ -57,8 +59,8 @@ class Event extends React.Component {
</Grid>
</Grid>
</Paper>
)
);
}
}
export default withStyles(styles)(Event)
export default withStyles(styles)(Event);
+12 -14
View File
@@ -1,21 +1,19 @@
import React from 'react'
import { Typography } from '@material-ui/core'
import React from 'react';
import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles'
import styles from '../styles'
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
import Event from '../Event'
import Event from '../Event';
class Future extends React.Component {
render () {
const classes = this.props.classes
const { FutureEvents } = this.props
render() {
const { classes } = this.props;
const { FutureEvents } = this.props;
const futureEvents = FutureEvents.map((event, index) => {
return (
const futureEvents = FutureEvents.map((event, index) => (
<Event key={index} event={event} />
)
})
));
return (
<React.Fragment>
<Typography
@@ -29,8 +27,8 @@ class Future extends React.Component {
</Typography>
{futureEvents}
</React.Fragment>
)
);
}
}
export default withStyles(styles)(Future)
export default withStyles(styles)(Future);
+8 -8
View File
@@ -1,12 +1,12 @@
import React from 'react'
import { Typography } from '@material-ui/core'
import React from 'react';
import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles'
import styles from '../styles'
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
class History extends React.Component {
render () {
const classes = this.props.classes
render() {
const { classes } = this.props;
return (
<Typography
className={classes.title}
@@ -17,8 +17,8 @@ class History extends React.Component {
>
Your old events (maybe here, maybe not, who knows)
</Typography>
)
);
}
}
export default withStyles(styles)(History)
export default withStyles(styles)(History);
+14 -18
View File
@@ -1,26 +1,22 @@
import React from 'react'
import { Typography } from '@material-ui/core'
import React from 'react';
import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles'
import styles from '../styles'
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
import Event from '../Event'
import Event from '../Event';
class Incoming extends React.Component {
render () {
const classes = this.props.classes
const { IncomingEvents, OngoingEvents } = this.props
render() {
const { classes } = this.props;
const { IncomingEvents, OngoingEvents } = this.props;
const incomingEvents = IncomingEvents.map((event, index) => {
return (
const incomingEvents = IncomingEvents.map((event, index) => (
<Event key={index} event={event} />
)
})
const ongoingEvents = OngoingEvents.map((event, index) => {
return (
));
const ongoingEvents = OngoingEvents.map((event, index) => (
<Event key={index} event={event} />
)
})
));
return (
<React.Fragment>
<Typography
@@ -49,8 +45,8 @@ class Incoming extends React.Component {
</Typography>
{incomingEvents}
</React.Fragment>
)
);
}
}
export default withStyles(styles)(Incoming)
export default withStyles(styles)(Incoming);
+12 -14
View File
@@ -1,21 +1,19 @@
import React from 'react'
import { Typography } from '@material-ui/core'
import React from 'react';
import { Typography } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles'
import styles from '../styles'
import { withStyles } from '@material-ui/core/styles';
import styles from '../styles';
import Event from '../Event'
import Event from '../Event';
class Past extends React.Component {
render () {
const classes = this.props.classes
const { PastEvents } = this.props
render() {
const { classes } = this.props;
const { PastEvents } = this.props;
const pastEvents = PastEvents.map((event, index) => {
return (
const pastEvents = PastEvents.map((event, index) => (
<Event key={index} event={event} />
)
})
));
return (
<React.Fragment>
<Typography
@@ -29,8 +27,8 @@ class Past extends React.Component {
</Typography>
{pastEvents}
</React.Fragment>
)
);
}
}
export default withStyles(styles)(Past)
export default withStyles(styles)(Past);
+6 -6
View File
@@ -1,11 +1,11 @@
import Future from './Future'
import History from './History'
import Incoming from './Incoming'
import Past from './Past'
import Future from './Future';
import History from './History';
import Incoming from './Incoming';
import Past from './Past';
export {
Future,
History,
Incoming,
Past
}
Past,
};
+38 -34
View File
@@ -1,68 +1,70 @@
import React from 'react'
import { Query } from 'react-apollo'
import { DateTime } from 'luxon'
import React from 'react';
import { Query } from 'react-apollo';
import { DateTime } from 'luxon';
import {
Typography,
AppBar,
Tabs,
Tab
} from '@material-ui/core'
Tab,
} from '@material-ui/core';
import {
GetApp as IncomingIcon,
AlarmAdd as FutureIcon,
History as HistoryIcon
} from '@material-ui/icons'
History as HistoryIcon,
} from '@material-ui/icons';
import { withStyles } from '@material-ui/core/styles'
import styles from './styles'
import { withStyles } from '@material-ui/core/styles';
import styles from './styles';
import { listEventsCalls } from '../../GraphQL/Calls/index'
import { listEventsCalls } from '../../GraphQL/Calls/index';
import {
Future,
History,
Incoming,
Past
} from './Tabs'
Past,
} from './Tabs';
function TabContainer (props) {
function TabContainer(props) {
return (
<Typography component='div' style={{ padding: 8 * 3 }}>
{props.children}
</Typography>
)
);
}
class Search extends React.Component {
constructor (props) {
super(props)
constructor(props) {
super(props);
this.state = {
value: 0
}
value: 0,
};
}
handleChange = (event, value) => {
this.setState({ value })
this.setState({ value });
}
render () {
const classes = this.props.classes
const { value } = this.state
render() {
const { classes } = this.props;
const { value } = this.state;
return (
<Query
query={listEventsCalls.EVENTS_EVENTS}
>
{({ loading, error, data }) => {
if (loading) return 'Loading...'
if (error) return `Error! ${error.message}`
const now = ~~(DateTime.local().valueOf() / 1000)
const inTwoWeeks = ~~(DateTime.local().plus({ weeks: 2 }).valueOf() / 1000)
if (loading) return 'Loading...';
if (error) return `Error! ${error.message}`;
const now = Math.floor(DateTime.local().valueOf() / 1000);
const inTwoWeeks = Math.floor(DateTime.local().plus({ weeks: 2 }).valueOf() / 1000);
const IncomingEvents = data.events_Events.filter(event => event.startDatetime > now && event.startDatetime < inTwoWeeks)
const OngoingEvents = data.events_Events.filter(event => event.finishDatetime > now && event.startDatetime < now)
const FutureEvents = data.events_Events.filter(event => event.startDatetime > now)
const PastEvents = data.events_Events.filter(event => event.finishDatetime < now)
const IncomingEvents = data.events_Events.filter(event => event.startDatetime > now
&& event.startDatetime < inTwoWeeks);
const OngoingEvents = data.events_Events.filter(event => event.finishDatetime > now
&& event.startDatetime < now);
const FutureEvents = data.events_Events.filter(event => event.startDatetime > now);
const PastEvents = data.events_Events.filter(event => event.finishDatetime < now);
return (
<React.Fragment>
@@ -98,17 +100,19 @@ class Search extends React.Component {
/>
</Tabs>
</AppBar>
{value === 0 && <TabContainer><Incoming IncomingEvents={IncomingEvents} OngoingEvents={OngoingEvents} /></TabContainer>}
{value === 0 && <TabContainer>
<Incoming IncomingEvents={IncomingEvents} OngoingEvents={OngoingEvents} />
</TabContainer>}
{value === 1 && <TabContainer><Future FutureEvents={FutureEvents} /></TabContainer>}
{value === 2 && <TabContainer><History /></TabContainer>}
{value === 3 && <TabContainer><Past PastEvents={PastEvents} /></TabContainer>}
</div>
</React.Fragment>
)
);
}}
</Query>
)
);
}
}
export default withStyles(styles)(Search)
export default withStyles(styles)(Search);
+9 -9
View File
@@ -4,11 +4,11 @@ const styles = theme => ({
width: '100%',
backgroundColor: theme.palette.background.paper,
padding: 0,
margin: 0
margin: 0,
},
tabTitle: {
width: '25%',
maxWidth: 'none'
maxWidth: 'none',
},
card: {
flexGrow: 1,
@@ -16,18 +16,18 @@ const styles = theme => ({
marginTop: 20,
marginBottom: 20,
marginLeft: 400,
marginRight: 400
marginRight: 400,
},
buttonList: {
margin: theme.spacing.unit,
float: 'right'
float: 'right',
},
buttonGrid: {
marginTop: -20
marginTop: -20,
},
title: {
marginTop: 20
}
})
marginTop: 20,
},
});
export default styles
export default styles;