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