Skip to content
Snippets Groups Projects
Commit 7f87e416 authored by Chif Gergő's avatar Chif Gergő
Browse files

Fix some eslint errors --> format code

parent 660a41c3
Branches
Tags
No related merge requests found
...@@ -28,7 +28,9 @@ export const getUserData = () => ( ...@@ -28,7 +28,9 @@ export const getUserData = () => (
id, joinDate, nick, motivationAbout, motivationProfession, motivationExercise, signed, groups, id, joinDate, nick, motivationAbout, motivationProfession, motivationExercise, signed, groups,
}, },
}); });
} catch (e) {} } catch (e) {
console.log(e);
}
} }
); );
...@@ -41,8 +43,8 @@ export const getNews = () => ( ...@@ -41,8 +43,8 @@ export const getNews = () => (
payload: response.data, payload: response.data,
}); });
} catch (e) { } catch (e) {
console.log(e);
} }
} }
); );
...@@ -59,7 +61,7 @@ export const groupChange = groups => ( ...@@ -59,7 +61,7 @@ export const groupChange = groups => (
export const submitRegistration = ({ export const submitRegistration = ({
nick, groups, signed, motivationAbout, motivationProfession, motivationExercise, id, nick, groups, signed, motivationAbout, motivationProfession, motivationExercise, id,
}) => ( }) => (
async (dispatch) => { async () => {
try { try {
const response = await axios.patch(`/api/v1/profiles/${id}/`, { const response = await axios.patch(`/api/v1/profiles/${id}/`, {
nick, nick,
...@@ -74,6 +76,8 @@ export const submitRegistration = ({ ...@@ -74,6 +76,8 @@ export const submitRegistration = ({
} else { } else {
alert('Mentés nem sikerült!'); alert('Mentés nem sikerült!');
} }
} catch(e) {} } catch (e) {
console.log(e);
}
} }
); );
import { axios } from './auth' import { axios } from './auth';
import { GET_NEWS, WRITE_NEWS, ADD_NEWS, DELETE_NEWS, CLEAR_WRITE } from './types' import { GET_NEWS, WRITE_NEWS, ADD_NEWS, DELETE_NEWS, CLEAR_WRITE } from './types';
export const getNews = () => ( export const getNews = () => (
async (dispatch) => { async (dispatch) => {
...@@ -10,8 +10,8 @@ export const getNews = () => ( ...@@ -10,8 +10,8 @@ export const getNews = () => (
payload: response.data, payload: response.data,
}); });
} catch (e) { } catch (e) {
console.log(e);
} }
} }
); );
...@@ -19,10 +19,10 @@ export const postNews = ({title, author, text}) =>( ...@@ -19,10 +19,10 @@ export const postNews = ({title, author, text}) =>(
async (dispatch) => { async (dispatch) => {
try { try {
const response = await axios.post('/api/v1/news/', { const response = await axios.post('/api/v1/news/', {
"author": author, author,
"title": title, title,
"text": text, text,
}) });
if (response.data.id) { if (response.data.id) {
alert('Sikeres mentés!'); alert('Sikeres mentés!');
dispatch({ dispatch({
...@@ -38,7 +38,7 @@ export const postNews = ({title, author, text}) =>( ...@@ -38,7 +38,7 @@ export const postNews = ({title, author, text}) =>(
} }
); );
export const deleteNews = (news) =>( export const deleteNews = news => (
async (dispatch) => { async (dispatch) => {
try { try {
const response = await axios.delete(`/api/v1/news/${news.id}/`); const response = await axios.delete(`/api/v1/news/${news.id}/`);
......
...@@ -7,4 +7,4 @@ export const GROUP_CHANGE = 'group_change'; ...@@ -7,4 +7,4 @@ export const GROUP_CHANGE = 'group_change';
export const WRITE_NEWS = 'write_news'; export const WRITE_NEWS = 'write_news';
export const CLEAR_WRITE = 'clear_write'; export const CLEAR_WRITE = 'clear_write';
export const ADD_NEWS = 'add_news'; export const ADD_NEWS = 'add_news';
export const DELETE_NEWS = 'delete_news' export const DELETE_NEWS = 'delete_news';
...@@ -2,10 +2,9 @@ import React, { Component } from 'react'; ...@@ -2,10 +2,9 @@ import React, { Component } from 'react';
import { Modal, Button, Form, Input, TextArea, Icon } from 'semantic-ui-react'; import { Modal, Button, Form, Input, TextArea, Icon } from 'semantic-ui-react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { postNews, writeNews, clearWrite } from '../../actions/news.js' import { postNews, writeNews, clearWrite } from '../../actions/news';
class AddNewsForm extends Component { class AddNewsForm extends Component {
render() { render() {
const { title, text } = this.props.newNews; const { title, text } = this.props.newNews;
const author = this.props.user.id; const author = this.props.user.id;
...@@ -20,14 +19,16 @@ class AddNewsForm extends Component { ...@@ -20,14 +19,16 @@ class AddNewsForm extends Component {
name='title' name='title'
onChange={e => this.props.writeNews(e)} onChange={e => this.props.writeNews(e)}
value={title} value={title}
placeholder='Title' /> placeholder='Title'
/>
<Form.Field <Form.Field
control={TextArea} control={TextArea}
label='Text' label='Text'
name='text' name='text'
onChange={e => this.props.writeNews(e)} onChange={e => this.props.writeNews(e)}
value={text} value={text}
placeholder='Tell us what you want...' /> placeholder='Tell us what you want...'
/>
</Form> </Form>
</Modal.Content> </Modal.Content>
<Modal.Actions> <Modal.Actions>
...@@ -35,9 +36,13 @@ class AddNewsForm extends Component { ...@@ -35,9 +36,13 @@ class AddNewsForm extends Component {
<Icon name='remove' /> Cancel <Icon name='remove' /> Cancel
</Button> </Button>
<Button <Button
inverted color='green' inverted
onClick={() => {this.props.postNews({title, text, author}); color='green'
this.props.clearWrite()}}> onClick={() => {
this.props.postNews({ title, text, author });
this.props.clearWrite();
}}
>
<Icon name='checkmark' /> Add <Icon name='checkmark' /> Add
</Button> </Button>
</Modal.Actions> </Modal.Actions>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Container, Header, Segment, Divider, List, Modal, import { Container, Header, Segment, Divider, List, Button } from 'semantic-ui-react';
Button, Image, Form, Input, TextArea, Checkbox, Icon } from 'semantic-ui-react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import AddNewsForm from '../forms/AddNewsForm' import AddNewsForm from '../forms/AddNewsForm';
import { getNews, deleteNews } from '../../actions/news' import { getNews, deleteNews } from '../../actions/news';
class News extends Component { class News extends Component {
componentWillMount() { componentWillMount() {
this.props.getNews(); this.props.getNews();
} }
render_news() { renderNews() {
const news = this.props.news; return this.props.news.map((item, index) => (
<div key={item.id} id={index}>
return news.map( (item, index) => (
<div key={index} id={index}>
{ index > 0 ? <Divider /> : ''} { index > 0 ? <Divider /> : ''}
<Header as='h3' style={{ fontSize: '2em' }}>{item.title}</Header> <Header as='h3' style={{ fontSize: '2em' }}>{item.title}</Header>
<p style={{ fontSize: '1.33em' }}>{item.text}</p> <p style={{ fontSize: '1.33em' }}>{item.text}</p>
<Button <Button
color='red' color='red'
size='mini' size='mini'
onClick={() => this.props.deleteNews(item)} >Delete</Button> onClick={() => this.props.deleteNews(item)}
>
Delete
</Button>
</div> </div>
)); ));
} }
render_sidebar() { renderSidebar() {
const news = this.props.news; return this.props.news.map((item, index) => (
return news.map( (item, index) => (
<List.Item as='a' href={`#${index}`}> <List.Item as='a' href={`#${index}`}>
<List.Icon name='align justify' verticalAlign={"middle"}/> <List.Icon name='align justify' verticalAlign='middle' />
<List.Content> <List.Content>
<List.Header> <List.Header>
{item.title} {item.title}
...@@ -42,11 +38,9 @@ class News extends Component { ...@@ -42,11 +38,9 @@ class News extends Component {
</List.Content> </List.Content>
</List.Item> </List.Item>
)); ));
} }
render() { render() {
return ( return (
<div> <div>
{/* <Segment inverted textAlign='center' vertical> {/* <Segment inverted textAlign='center' vertical>
...@@ -67,15 +61,15 @@ class News extends Component { ...@@ -67,15 +61,15 @@ class News extends Component {
</Segment> </Segment>
*/} */}
<Segment floated={'left'} style={{ padding: '3em 3em' }} vertical> <Segment floated='left' style={{ padding: '3em 3em' }} vertical>
<AddNewsForm /> <AddNewsForm />
<Container text textAlign = {'center'}> <Container text textAlign='center'>
{this.render_news()} {this.renderNews()}
</Container> </Container>
</Segment> </Segment>
<Segment floated={'right'} style={{ padding: '1em 1em' }} vertical> <Segment floated='right' style={{ padding: '1em 1em' }} vertical>
<List size={'big'} link divided> <List size='big' link divided>
{this.render_sidebar()} {this.renderSidebar()}
</List> </List>
</Segment> </Segment>
</div> </div>
......
...@@ -5,7 +5,7 @@ const INITIAL_STATE = { title: '', text: ''}; ...@@ -5,7 +5,7 @@ const INITIAL_STATE = { title: '', text: ''};
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
case WRITE_NEWS: case WRITE_NEWS:
return {...state, [action.target]: action.payload} return { ...state, [action.target]: action.payload };
case CLEAR_WRITE: case CLEAR_WRITE:
return INITIAL_STATE; return INITIAL_STATE;
default: default:
......
...@@ -9,8 +9,8 @@ export default (state = INITIAL_STATE, action) => { ...@@ -9,8 +9,8 @@ export default (state = INITIAL_STATE, action) => {
case ADD_NEWS: case ADD_NEWS:
return [action.payload, ...state]; return [action.payload, ...state];
case DELETE_NEWS: case DELETE_NEWS:
let index = state.indexOf(action.payload); const index = state.indexOf(action.payload);
let array = [...state]; const array = [...state];
array.splice(index, 1); array.splice(index, 1);
return [...array]; return [...array];
default: default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment