From f30f041a1e373804526bc3e8789b7bf9f3c721fc Mon Sep 17 00:00:00 2001 From: rlacko <rlacko99@gmail.com> Date: Wed, 8 Apr 2020 21:45:39 +0200 Subject: [PATCH] fix eslint --- .eslintrc | 16 +- .gitlab-ci.yml | 1 - package-lock.json | 2 +- src/actions/auth.js | 23 +- src/actions/home.js | 2 +- src/actions/homework.js | 25 +- src/actions/mentors.js | 2 +- src/actions/news.js | 14 +- src/actions/notes.js | 12 +- src/actions/statistics.js | 30 +- src/components/App.js | 3 +- src/components/Footer.js | 4 +- src/components/Header.js | 186 ++++++------ src/components/Main.js | 4 +- src/components/extra/GroupCard.js | 25 +- src/components/forms/AddEventForm.js | 51 ++-- src/components/forms/AddNewsForm.js | 27 +- src/components/forms/AddSolutionForm.js | 297 +++++++++--------- src/components/forms/AddTaskForm.js | 48 +-- src/components/forms/ConfirmModal.js | 91 +++--- src/components/forms/CorrectSolutionForm.js | 59 ++-- src/components/forms/EditNewsForm.js | 60 ++-- src/components/forms/EditTaskForm.js | 47 ++- src/components/forms/HiddenForm.js | 28 +- src/components/forms/InfoModal.js | 66 ++-- src/components/forms/SolutionDetailsForm.js | 71 +++-- src/components/pages/ApplicantProfile.js | 136 ++++----- src/components/pages/Applications.js | 196 ++++++------ src/components/pages/EventDetail.js | 102 ++++--- src/components/pages/EventDetailTableRow.js | 191 ++++++------ src/components/pages/Events.js | 64 ++-- src/components/pages/Groups.js | 16 +- src/components/pages/Home.js | 183 +++++------ src/components/pages/Homework.js | 157 +++++----- src/components/pages/LeaderBoard.js | 36 ++- src/components/pages/Mentors.js | 70 +++-- src/components/pages/News.js | 73 +++-- src/components/pages/NotFound.js | 4 +- src/components/pages/Presence.js | 52 ++-- src/components/pages/Profile.js | 318 ++++++++++++-------- src/components/pages/Schedule.js | 63 ++-- src/components/pages/Statistics.js | 23 +- src/containers/TodoContainer.js | 7 +- src/reducers/AddSolutionReducer.js | 4 +- src/reducers/CorrectSolutionReducer.js | 4 +- src/reducers/EditTaskReducer.js | 4 +- src/reducers/EventReducer.js | 13 +- src/reducers/GroupsReducer.js | 2 +- src/reducers/HomeworksReducer.js | 9 +- src/reducers/NewsReducer.js | 6 +- src/reducers/TraineeReducer.js | 8 +- src/registerServiceWorker.js | 28 +- 52 files changed, 1661 insertions(+), 1302 deletions(-) diff --git a/.eslintrc b/.eslintrc index be0d25c..9ce5047 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,14 +1,26 @@ { "extends": "airbnb", + "parser": "babel-eslint", "globals": { "document": false }, "rules": { "react/jsx-filename-extension": 0, + "react/no-danger": 0, "jsx-quotes": ["error", "prefer-single"], "import/prefer-default-export": 0, - "react/prop-types": 1, + "react/prop-types": 0, + "react/destructuring-assignment": 0, "react/prefer-stateless-function": 0, - "no-case-declarations": 1 + "camelcase": 0, + "no-alert": "off", + "no-undef": "off", + "no-console": "off", + "no-prototype-builtins": "off", + "import/no-cycle": "off", + "jsx-a11y/label-has-associated-control": "off", + "react/no-access-state-in-setstate": "off", + "consistent-return": "off", + "no-case-declarations": "off" } } diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3231735..df72e83 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,4 +9,3 @@ Install_Test: script: - npm install - ./node_modules/.bin/eslint . - - npm run test diff --git a/package-lock.json b/package-lock.json index 1f41880..99dccd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "kszkepzes-frontend", - "version": "0.2.7", + "version": "0.2.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/actions/auth.js b/src/actions/auth.js index daec89e..0dafdfe 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -1,5 +1,7 @@ import axios from './session'; -import { GET_USERDATA, PROFILE_CHANGE, GROUP_CHANGE, GET_DEADLINE } from './types'; +import { + GET_USERDATA, PROFILE_CHANGE, GROUP_CHANGE, GET_DEADLINE, +} from './types'; export const getUserData = () => ( @@ -17,7 +19,7 @@ export const getUserData = () => ( signed, groups, role, - bits + bits, } = user.data; let permission; switch (role) { @@ -38,7 +40,18 @@ export const getUserData = () => ( dispatch({ type: GET_USERDATA, payload: { - id, joinDate, nick, motivationAbout, motivationProfession, motivationExercise, full_name, signed, groups, role, permission, bits + id, + joinDate, + nick, + motivationAbout, + motivationProfession, + motivationExercise, + full_name, + signed, + groups, + role, + permission, + bits, }, }); } catch (e) { @@ -68,8 +81,8 @@ export const textChange = ({ target: { name, value } }) => ( } ); -export const groupChange = groups => ( - dispatch => (dispatch({ type: GROUP_CHANGE, payload: groups })) +export const groupChange = (groups) => ( + (dispatch) => (dispatch({ type: GROUP_CHANGE, payload: groups })) ); export const submitRegistration = ({ diff --git a/src/actions/home.js b/src/actions/home.js index fcfb35a..56f5482 100644 --- a/src/actions/home.js +++ b/src/actions/home.js @@ -13,4 +13,4 @@ export const getImages = () => ( console.log(e); } } -); \ No newline at end of file +); diff --git a/src/actions/homework.js b/src/actions/homework.js index 9e7c2e3..741965c 100644 --- a/src/actions/homework.js +++ b/src/actions/homework.js @@ -1,5 +1,6 @@ import axios from './session'; -import { GET_TASKS, +import { + GET_TASKS, GET_SOLUTIONS, ADD_TASK, DELETE_TASK, @@ -15,7 +16,8 @@ import { GET_TASKS, GET_DOCUMENTS, CORRECT_SOLUTION, SELECT_SOLUTION, - CHECK, SETCHECKTRUE } from './types'; + CHECK, SETCHECKTRUE, +} from './types'; export const getTasks = () => ( async (dispatch) => { @@ -31,7 +33,7 @@ export const getTasks = () => ( } ); -export const getSolutions = taskId => ( +export const getSolutions = (taskId) => ( async (dispatch) => { try { const response = await axios.get('/api/v1/homework/solutions/', { task: taskId }); @@ -45,7 +47,9 @@ export const getSolutions = taskId => ( } ); -export const addTask = ({ title, text, deadline, bits }) => ( +export const addTask = ({ + title, text, deadline, bits, +}) => ( async (dispatch) => { try { const response = await axios.post('/api/v1/homework/tasks/', { @@ -94,7 +98,7 @@ export const editTask = ({ } ); -export const deleteTask = task => ( +export const deleteTask = (task) => ( async (dispatch) => { try { const response = await axios.delete(`/api/v1/homework/tasks/${task.id}/`); @@ -109,7 +113,7 @@ export const deleteTask = task => ( } }); -export const setSelectedTask = task => ( +export const setSelectedTask = (task) => ( (dispatch) => { dispatch({ type: SELECT_TASK, payload: task }); } @@ -189,8 +193,7 @@ export const addSolution = ({ export const getDocuments = (solutionID) => ( async (dispatch) => { try { - const response = - await axios.get('/api/v1/documents', { params: { solution: solutionID } }); + const response = await axios.get('/api/v1/documents', { params: { solution: solutionID } }); dispatch({ type: GET_DOCUMENTS, payload: response.data, @@ -266,19 +269,19 @@ export const correctSolution = (id, corrected, accepted, note) => ( } ); -export const check = name => ( +export const check = (name) => ( (dispatch) => { dispatch({ type: CHECK, target: name }); } ); -export const setchecktrue = name => ( +export const setchecktrue = (name) => ( (dispatch) => { dispatch({ type: SETCHECKTRUE, target: name }); } ); -export const selectSolution = solution => ( +export const selectSolution = (solution) => ( (dispatch) => { dispatch({ type: SELECT_SOLUTION, diff --git a/src/actions/mentors.js b/src/actions/mentors.js index 9dcaa5c..bba7cb1 100644 --- a/src/actions/mentors.js +++ b/src/actions/mentors.js @@ -13,4 +13,4 @@ export const getMentors = () => ( console.log(e); } } -); \ No newline at end of file +); diff --git a/src/actions/news.js b/src/actions/news.js index d096cde..29bdbc8 100644 --- a/src/actions/news.js +++ b/src/actions/news.js @@ -1,6 +1,8 @@ import axios from './session'; -import { GET_NEWS, WRITE_NEWS, ADD_NEWS, DELETE_NEWS, - CLEAR_WRITE, SELECT_NEWS, EDIT_NEWS } from './types'; +import { + GET_NEWS, WRITE_NEWS, ADD_NEWS, DELETE_NEWS, + CLEAR_WRITE, SELECT_NEWS, EDIT_NEWS, +} from './types'; export const getNews = () => ( async (dispatch) => { @@ -39,7 +41,9 @@ export const postNews = ({ title, updated_by, text }) => ( } ); -export const editNews = ({ id, title, text, updated_by}) => ( +export const editNews = ({ + id, title, text, updated_by, +}) => ( async (dispatch) => { try { const response = await axios.patch(`/api/v1/news/${id}/`, { @@ -63,7 +67,7 @@ export const editNews = ({ id, title, text, updated_by}) => ( } ); -export const deleteNews = news => ( +export const deleteNews = (news) => ( async (dispatch) => { try { const response = await axios.delete(`/api/v1/news/${news.id}/`); @@ -93,7 +97,7 @@ export const clearWrite = () => ( } ); -export const setSelectedNews = item => ( +export const setSelectedNews = (item) => ( (dispatch) => { dispatch({ type: SELECT_NEWS, payload: item }); } diff --git a/src/actions/notes.js b/src/actions/notes.js index 52074a9..b9a5b4c 100644 --- a/src/actions/notes.js +++ b/src/actions/notes.js @@ -6,7 +6,7 @@ import { CLEAR_WRITE, } from './types'; -export const getNotesByEvent = id => ( +export const getNotesByEvent = (id) => ( async (dispatch) => { try { const response = await axios.get('/api/v1/notes/', { params: { eventID: id } }); @@ -20,16 +20,16 @@ export const getNotesByEvent = id => ( } ); -export const writeNote = (event) => { - return (dispatch => (dispatch({ type: WRITE_NOTE, payload: event.target.value }))); -}; +export const writeNote = (event) => ((dispatch) => (dispatch( + { type: WRITE_NOTE, payload: event.target.value }, +))); export const postEventNote = ({ eventid, userid, note }) => ( async (dispatch) => { try { const response = await axios.post('/api/v1/notes/', { - event: eventid ? eventid : '', - profile: userid ? userid : '', + event: eventid || '', + profile: userid || '', note, }); if (response.data.id) { diff --git a/src/actions/statistics.js b/src/actions/statistics.js index a2b3f81..eddbcff 100644 --- a/src/actions/statistics.js +++ b/src/actions/statistics.js @@ -42,7 +42,7 @@ export const getStudentEvents = () => ( } ); -export const getEventById = id => ( +export const getEventById = (id) => ( async (dispatch) => { try { const response = await axios.get(`/api/v1/staff_events/${id}`); @@ -71,14 +71,15 @@ export const getTrainees = () => ( ); export const visitorChange = ({ id, value }) => { - switch (value){ + switch (value) { case 'Visitor': - return (dispatch => (dispatch({ type: VISITOR_CHANGE, payload: id }))); + return ((dispatch) => (dispatch({ type: VISITOR_CHANGE, payload: id }))); case 'Absent': - return (dispatch => (dispatch({ type: ABSENT_CHANGE, payload: id }))); + return ((dispatch) => (dispatch({ type: ABSENT_CHANGE, payload: id }))); case 'No': - return (dispatch => (dispatch({ type: CHANGE_NO, payload: id }))); + return ((dispatch) => (dispatch({ type: CHANGE_NO, payload: id }))); default: + return null; } }; @@ -86,17 +87,16 @@ export const submitVisitors = ({ id, visitors, absent }) => ( async () => { try { const response = await axios.patch(`/api/v1/staff_events/${id}/`, { - visitors: visitors, - absent: absent - }) - if(response.data.id === id) { - return true - } else { - return false + visitors, + absent, + }); + if (response.data.id === id) { + return true; } + return false; } catch (e) { console.log(e); - return false + return false; } } ); @@ -138,7 +138,7 @@ export const addEvent = ({ name, date, description }) => ( } ); -export const deleteEvent = event => ( +export const deleteEvent = (event) => ( async (dispatch) => { try { const response = await axios.delete(`/api/v1/staff_events/${event.id}/`); @@ -188,7 +188,7 @@ export const setStatus = (id, status) => ( } ); -export const getSelectedProfile = id => ( +export const getSelectedProfile = (id) => ( async (dispatch) => { try { const response = await axios.get(`/api/v1/profiles/${id}/`); diff --git a/src/components/App.js b/src/components/App.js index bf61f96..490fd7e 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -4,10 +4,9 @@ import Main from './Main'; import Footer from './Footer'; - const App = () => ( <div style={{ minHeight: '100%', position: 'relative' }}> - <header id='header' > + <header id='header'> <Header /> </header> <main id='main' style={{ minHeight: '100%', position: 'relative' }}> diff --git a/src/components/Footer.js b/src/components/Footer.js index aa62a0f..69b3e06 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -3,9 +3,9 @@ import { Container, Segment } from 'semantic-ui-react'; const Footer = () => ( - <Segment inverted vertical textAlign='center' > + <Segment inverted vertical textAlign='center'> <Container> - <p textalign='center' >Created by DevTeam © 2018-2020.</p> + <p textalign='center'>Created by DevTeam © 2018-2020.</p> </Container> </Segment> diff --git a/src/components/Header.js b/src/components/Header.js index 6eb131f..8cbdab7 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -74,6 +74,7 @@ class Header extends Component { isOpen: false, }; } + // Fetch the userData-s UNSAFE_componentWillMount() { this.props.getUserData(); @@ -83,99 +84,102 @@ class Header extends Component { handleOpen = () => { this.setState({ isOpen: true }); } + handleClose = () => { this.setState({ isOpen: false }); } - renderHeader(inHeader, hasArrowMenu) { - let renderedItemNum = 0 - let current = 0 - let maxNum = 0 - if(this.props.user.id) { - maxNum = menuItems.filter(item => { - return this.props.user.permission >= item.permissionLevel - }).length + renderHeader(inHeader) { + let renderedItemNum = 0; + let current = 0; + let maxNum = 0; + if (this.props.user.id) { + maxNum = menuItems + .filter((item) => this.props.user.permission >= item.permissionLevel) + .length; } else { - maxNum = 3 + maxNum = 3; } - + return ( <Segment inverted textAlign='center' vertical> <Container> <Menu inverted secondary size='large'> {/* Default Menu items */} - {menuItems.map((item, i) => { + {menuItems.map((item) => { if (item.permissionLevel === 0) { - renderedItemNum += 1 + renderedItemNum += 1; return ( - <Menu.Item key={i} as={Link} to={item.to}> - {item.prefix}{item.text} - </Menu.Item> - ) - }else { - return null + <Menu.Item key={Math.random()} as={Link} to={item.to}> + {item.prefix} + {item.text} + </Menu.Item> + ); } - }) - } + return null; + })} {/* After default menu items */} {menuItems.map((item, i) => { - if (this.props.user.permission >= item.permissionLevel && item.permissionLevel > 0 && renderedItemNum < inHeader && current < i) { - renderedItemNum += 1 - current = i + renderedItemNum += 1; + current = i; return ( - <Menu.Item key={i} as={Link} to={item.to}> - {item.prefix}{item.text} + <Menu.Item key={Math.random()} as={Link} to={item.to}> + {item.prefix} + {item.text} </Menu.Item> - ) - } else { - return null + ); } - }) - } + return null; + })} {/* Arrow menu */} - { this.props.user.id && (current + 1) < maxNum ? - <Popup flowing hoverable inverted - trigger={ - <Menu.Item> - <Icon name='angle down' size='large' /> - </Menu.Item> - } - position='top center' - > - <Menu inverted secondary size='large'> - {menuItems.map((item, i) => { - return (this.props.user.permission >= item.permissionLevel + { this.props.user.id && (current + 1) < maxNum + ? ( + <Popup + flowing + hoverable + inverted + trigger={( + <Menu.Item> + <Icon name='angle down' size='large' /> + </Menu.Item> + )} + position='top center' + > + <Menu inverted secondary size='large'> + {menuItems.map((item, i) => (this.props.user.permission >= item.permissionLevel && item.permissionLevel > 0 - && current < i ? - <Menu.Item key={i} as={Link} to={item.to}> - {item.prefix}{item.text} + && current < i + ? ( + <Menu.Item key={Math.random()} as={Link} to={item.to}> + {item.prefix} + {item.text} </Menu.Item> + ) : null - )}) - } - </Menu> - </Popup> - : null - } + ))} + </Menu> + </Popup> + ) + : null} {/* Login Button */} <Menu.Item position='right'> - {this.props.user.id ? - <Button.Group> - <Button inverted as={Link} to='/profile'>Profilom</Button> - <Button as='a' href='/api/v1/logout/' icon='sign out' /> - </Button.Group> - : - <Button as='a' href='/api/v1/login/authsch/' inverted>Bejelentkezés</Button> - } + {this.props.user.id + ? ( + <Button.Group> + <Button inverted as={Link} to='/profile'>Profilom</Button> + <Button as='a' href='/api/v1/logout/' icon='sign out' /> + </Button.Group> + ) + : <Button as='a' href='/api/v1/login/authsch/' inverted>Bejelentkezés</Button>} </Menu.Item> </Menu> </Container> </Segment> - ) + ); } render() { @@ -207,15 +211,22 @@ class Header extends Component { <Menu inverted secondary size='large'> {/* kszk logo + home link */} <Menu.Item as={Link} to={menuItems[0].to}> - {menuItems[0].prefix}{menuItems[0].text} - </Menu.Item> + {menuItems[0].prefix} + {menuItems[0].text} + </Menu.Item> {/* Sandwich menu */} - <Popup flowing hoverable inverted trigger={ - <Menu.Item onClick={this.handleClose} - position='right'> + <Popup + flowing + hoverable + inverted + trigger={( + <Menu.Item + onClick={this.handleClose} + position='right' + > <Icon name='bars' size='large' /> </Menu.Item> - } + )} position='top center' open={this.state.isOpen} onOpen={this.handleOpen} @@ -223,25 +234,30 @@ class Header extends Component { size='huge' > <Menu vertical inverted secondary size='large'> - {menuItems.map((item, i) => - ((this.props.user.permission >= item.permissionLevel - ||item.permissionLevel === 0) && i>0? - <Menu.Item onClick={this.handleClose} - key={i} as={Link} to={item.to}> - {item.prefix}{item.text} - </Menu.Item> - : null - )) - } + {menuItems.map((item, i) => ((this.props.user.permission >= item.permissionLevel + || item.permissionLevel === 0) && i > 0 + ? ( + <Menu.Item + onClick={this.handleClose} + key={Math.random()} + as={Link} + to={item.to} + > + {item.prefix} + {item.text} + </Menu.Item> + ) + : null + ))} <Menu.Item> - {this.props.user.id ? - <Button.Group> - <Button onClick={this.handleClose} inverted as={Link} to='/profile'>Profilom</Button> - <Button onClick={this.handleClose} as='a' href='/api/v1/logout/' icon='sign out' /> - </Button.Group> - : - <Button onClick={this.handleClose} as='a' href='/api/v1/login/authsch/' inverted>Bejelentkezés</Button> - } + {this.props.user.id + ? ( + <Button.Group> + <Button onClick={this.handleClose} inverted as={Link} to='/profile'>Profilom</Button> + <Button onClick={this.handleClose} as='a' href='/api/v1/logout/' icon='sign out' /> + </Button.Group> + ) + : <Button onClick={this.handleClose} as='a' href='/api/v1/login/authsch/' inverted>Bejelentkezés</Button>} </Menu.Item> </Menu> </Popup> @@ -258,4 +274,4 @@ const mapStateToProps = ({ user }) => ({ user, }); -export default connect(mapStateToProps, { getUserData })(Header); \ No newline at end of file +export default connect(mapStateToProps, { getUserData })(Header); diff --git a/src/components/Main.js b/src/components/Main.js index 8f6e410..0b66f61 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -1,5 +1,7 @@ import React from 'react'; -import { Switch, Route, Redirect, withRouter } from 'react-router-dom'; +import { + Switch, Route, Redirect, withRouter, +} from 'react-router-dom'; import Home from './pages/Home'; import Mentors from './pages/Mentors'; diff --git a/src/components/extra/GroupCard.js b/src/components/extra/GroupCard.js index 1033929..4cc2b11 100644 --- a/src/components/extra/GroupCard.js +++ b/src/components/extra/GroupCard.js @@ -1,16 +1,19 @@ -import React, {Component} from 'react' +import React, { Component } from 'react'; import { Segment, Header, Divider } from 'semantic-ui-react'; class GroupCard extends Component { - render(){ - return ( - <Segment style={{ marginTop: 0 }}> - <Divider style={{ fontSize: '2em'}} horizontal><Header as='h3' style={{ fontSize: '1.2em'}}>{this.props.label}</Header></Divider> - <div className='paragraph' dangerouslySetInnerHTML={{__html: this.props.value}}> - </div> - </Segment> - ) - } + render() { + return ( + <Segment style={{ marginTop: 0 }}> + <Divider style={{ fontSize: '2em' }} horizontal> + <Header as='h3' style={{ fontSize: '1.2em' }}> + {this.props.label} + </Header> + </Divider> + <div className='paragraph' dangerouslySetInnerHTML={{ __html: this.props.value }} /> + </Segment> + ); + } } -export default GroupCard \ No newline at end of file +export default GroupCard; diff --git a/src/components/forms/AddEventForm.js b/src/components/forms/AddEventForm.js index 0bfb971..79ce80a 100644 --- a/src/components/forms/AddEventForm.js +++ b/src/components/forms/AddEventForm.js @@ -1,9 +1,11 @@ import React, { Component } from 'react'; -import { Modal, Button, Form, Input, Icon } from 'semantic-ui-react'; +import { + Modal, Button, Form, Input, Icon, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import { DateTimeInput } from 'semantic-ui-calendar-react'; -import { writeEvent, eventDate, addEvent } from '../../actions/statistics' -import { clearWrite } from '../../actions/news' +import { writeEvent, eventDate, addEvent } from '../../actions/statistics'; +import { clearWrite } from '../../actions/news'; class AddEventForm extends Component { constructor(props) { @@ -17,11 +19,11 @@ class AddEventForm extends Component { // Handling change in redux action creator throws an exception // Temporal solotion using the components state to display, instead redux state - handleChange = (event, {name, value}) => { + handleChange = (event, { name, value }) => { if (this.state.hasOwnProperty(name)) { this.setState({ [name]: value }); } - this.props.eventDate(name, value) + this.props.eventDate(name, value); } render() { @@ -29,13 +31,14 @@ class AddEventForm extends Component { return ( <Modal open={this.state.showModal} - trigger={ + trigger={( <Button size='big' onClick={() => { this.setState({ showModal: true }); }} - >Alkalom hozzáadása + > +Alkalom hozzáadása </Button> - } + )} > <Modal.Header>Új alkalom:</Modal.Header> <Modal.Content @@ -48,7 +51,7 @@ class AddEventForm extends Component { control={Input} label='Név' name='name' - onChange={e => this.props.writeEvent(e)} + onChange={(e) => this.props.writeEvent(e)} value={name} style={{ marginBottom: '20px', @@ -60,15 +63,15 @@ class AddEventForm extends Component { label='LeÃrás:' placeholder='Rövid leÃrás' value={description} - onChange={e => this.props.writeEvent(e)} + onChange={(e) => this.props.writeEvent(e)} /> <DateTimeInput - name="date" - label="Dátum:" + name='date' + label='Dátum:' dateFormat='YYYY-MM-DD' - placeholder="Date" + placeholder='Date' value={this.state.date} - iconPosition="left" + iconPosition='left' onChange={this.handleChange} /> </Form> @@ -77,8 +80,10 @@ class AddEventForm extends Component { <Button inverted color='red' - onClick={() => { this.setState({ showModal: false }); - this.props.clearWrite();}} + onClick={() => { + this.setState({ showModal: false }); + this.props.clearWrite(); + }} > <Icon name='remove' /> Cancel @@ -87,11 +92,13 @@ class AddEventForm extends Component { inverted color='green' onClick={() => { - this.props.addEvent(this.props.newEvent); - this.setState({ showModal: false, date: '' }); - }} + this.props.addEvent(this.props.newEvent); + this.setState({ showModal: false, date: '' }); + }} > - <Icon name='checkmark' /> Add + <Icon name='checkmark' /> + {' '} +Add </Button> </Modal.Actions> </Modal> @@ -101,4 +108,6 @@ class AddEventForm extends Component { const mapStateToProps = ({ events: { newEvent } }) => ({ newEvent }); -export default connect(mapStateToProps, { writeEvent, addEvent, eventDate, clearWrite })(AddEventForm); +export default connect(mapStateToProps, { + writeEvent, addEvent, eventDate, clearWrite, +})(AddEventForm); diff --git a/src/components/forms/AddNewsForm.js b/src/components/forms/AddNewsForm.js index d2af3b1..4de1fb7 100644 --- a/src/components/forms/AddNewsForm.js +++ b/src/components/forms/AddNewsForm.js @@ -1,5 +1,7 @@ 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 { postNews, writeNews, clearWrite } from '../../actions/news'; @@ -18,13 +20,14 @@ class AddNewsForm extends Component { return ( <Modal open={this.state.showModal} - trigger={ + trigger={( <Button size='big' onClick={() => { this.setState({ showModal: true }); }} - >HÃr hozzáadása + > +HÃr hozzáadása </Button> - } + )} > <Modal.Header>Új hÃr:</Modal.Header> <Modal.Content> @@ -33,7 +36,7 @@ class AddNewsForm extends Component { control={Input} label='Title' name='title' - onChange={e => this.props.writeNews(e)} + onChange={(e) => this.props.writeNews(e)} value={title} placeholder='Title' /> @@ -41,7 +44,7 @@ class AddNewsForm extends Component { control={TextArea} label='Text' name='text' - onChange={e => this.props.writeNews(e)} + onChange={(e) => this.props.writeNews(e)} value={text} placeholder='Tell us what you want...' /> @@ -60,12 +63,14 @@ class AddNewsForm extends Component { inverted color='green' onClick={() => { - this.props.postNews({ title, text, updated_by }); - this.setState({ showModal: false }); - this.props.clearWrite(); - }} + this.props.postNews({ title, text, updated_by }); + this.setState({ showModal: false }); + this.props.clearWrite(); + }} > - <Icon name='checkmark' /> Add + <Icon name='checkmark' /> + {' '} +Add </Button> </Modal.Actions> </Modal> diff --git a/src/components/forms/AddSolutionForm.js b/src/components/forms/AddSolutionForm.js index b179dd9..8e6ca88 100644 --- a/src/components/forms/AddSolutionForm.js +++ b/src/components/forms/AddSolutionForm.js @@ -1,14 +1,31 @@ import React, { Component } from 'react'; -import { Modal, Button, Form, Input, TextArea, Icon, Header, Segment, Divider, Dimmer, Loader } from 'semantic-ui-react'; +import { + Modal, + Button, + Form, + Input, + TextArea, + Icon, + Header, + Segment, + Divider, + Dimmer, + Loader, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; -import { addSolution, writeSolution, writeSolutionFile, addDocument, clearWrite } from '../../actions/homework'; -import './Forms.css'; -import ConfirmModal from '../forms/ConfirmModal'; -import { customMessage } from '../pages/Homework'; import { + addSolution, + writeSolution, + writeSolutionFile, + addDocument, + clearWrite, getDocuments, getSolutions, } from '../../actions/homework'; +import './Forms.css'; +import ConfirmModal from './ConfirmModal'; +import { customMessage } from '../pages/Homework'; + const allowedFileTypes = [ 'image/jpeg', @@ -20,7 +37,6 @@ const allowedFileTypes = [ const maxFileSize = 50; class AddSolutionForm extends Component { - constructor(props) { super(props); this.state = { @@ -31,19 +47,19 @@ class AddSolutionForm extends Component { render() { const { - name, description, file - } = this.props.newSolution + name, description, file, + } = this.props.newSolution; const task = this.props.taskid; const thisTaskSolution = this.props.homeworks.solutions - .filter(solution => solution.task === task) + .filter((solution) => solution.task === task); const thisTaskDocument = this.props.homeworks.documents - .filter(document => document.solution === thisTaskSolution[0]?.id) + .filter((document) => document.solution === thisTaskSolution[0]?.id); - const lastName = thisTaskDocument[0]?.name - const lastDesc = thisTaskDocument[0]?.description - const lastFile = thisTaskDocument[0]?.file_url + const lastName = thisTaskDocument[0]?.name; + const lastDesc = thisTaskDocument[0]?.description; + const lastFile = thisTaskDocument[0]?.file_url; const corrected = false; const accepted = false; @@ -56,102 +72,108 @@ class AddSolutionForm extends Component { open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={ + trigger={( <button + type='button' id='task' - onClick={() => { + onClick={() => { this.setState({ showModal: true }); }} > <Icon name='external' /> {this.props.tasktitle} </button> - } + )} > <Modal.Header> - {this.props.multiple ? 'Másik megoldás' : 'Megoldás'} beadása a(z) {this.props.tasktitle} nevű feladathoz: + {this.props.multiple ? 'Másik megoldás' : 'Megoldás'} + {' '} +beadása a(z) + {this.props.tasktitle} + {' '} +nevű feladathoz: </Modal.Header> <Modal.Content> <Modal.Description style={{ marginBottom: '2em' }}> <Header as='h5'>Feladat leÃrása:</Header> - {sentences.map(s => (<p key={Math.random()}>{s}</p>))} + {sentences.map((s) => (<p key={Math.random()}>{s}</p>))} </Modal.Description> - {this.props.disabled ? - <div> - {lastName ? - <div style={{paddingBottom: '1em'}}> - <div style={{ marginBottom: '1em', fontWeight: 'bold' }}>Legutóbbi megoldásod:</div> - <Segment attached='top'> - <h5 style={{paddingBottom: '0.4em'}}>CÃm:</h5> - {lastName} - </Segment> - <Segment attached> - <h5 style={{paddingBottom: '0.4em'}}>LeÃrás:</h5> - {lastDesc} - </Segment> - <Segment attached='bottom'> - <h5>Beadott fájl:</h5> - {lastFile ? - <a href={lastFile} rel='noreferrer noopener' target='_blank'>Fájl letöltése</a> - : - <span>-</span> - } - </Segment> - </div> - : - customMessage(disabledText, undefined, undefined, this.props.disabled) - } - </div> - - : - <Form> - {lastName ? - <div style={{paddingBottom: '1em'}}> - <div style={{ fontWeight: 'bold' }}>Legutóbbi megoldásod:</div> - <Segment attached='top'> - <h5 style={{paddingBottom: '0.4em'}}>CÃm:</h5> - {lastName} - </Segment> - <Segment attached> - <h5 style={{paddingBottom: '0.4em'}}>LeÃrás:</h5> - {lastDesc} - </Segment> - <Segment attached='bottom'> - <h5>Beadott fájl:</h5> - {lastFile ? - <a href={lastFile} rel='noreferrer noopener' target='_blank'>Fájl letöltése</a> - : - <span>-</span> - } - </Segment> - </div> - - : - null - } - <Divider /> - <Form.Field - control={Input} - label='Megoldás cÃme:' - name='name' - onChange={e => this.props.writeSolution(e)} - value={name} - placeholder='Adj meg egy cÃmet a beadandó megoldásodnak...' - /> - <Form.Field - control={TextArea} - label='Megoldás leÃrása:' - name='description' - onChange={e => this.props.writeSolution(e)} - value={description} - placeholder='Add meg a megoldás leÃrását...' - /> - <Form.Field> - <label>Fájl (Megengedett fájltÃpusok: png, jpeg, jpg, zip. Maximum 50 MB.):</label> - <Input type='file' onChange={e => this.props.writeSolutionFile(e)} /> - </Form.Field> - </Form> - } + {this.props.disabled + ? ( + <div> + {lastName + ? ( + <div style={{ paddingBottom: '1em' }}> + <div style={{ marginBottom: '1em', fontWeight: 'bold' }}>Legutóbbi megoldásod:</div> + <Segment attached='top'> + <h5 style={{ paddingBottom: '0.4em' }}>CÃm:</h5> + {lastName} + </Segment> + <Segment attached> + <h5 style={{ paddingBottom: '0.4em' }}>LeÃrás:</h5> + {lastDesc} + </Segment> + <Segment attached='bottom'> + <h5>Beadott fájl:</h5> + {lastFile + ? <a href={lastFile} rel='noreferrer noopener' target='_blank'>Fájl letöltése</a> + : <span>-</span>} + </Segment> + </div> + ) + : customMessage(disabledText, undefined, undefined, this.props.disabled)} + </div> + ) + + : ( + <Form> + {lastName + ? ( + <div style={{ paddingBottom: '1em' }}> + <div style={{ fontWeight: 'bold' }}>Legutóbbi megoldásod:</div> + <Segment attached='top'> + <h5 style={{ paddingBottom: '0.4em' }}>CÃm:</h5> + {lastName} + </Segment> + <Segment attached> + <h5 style={{ paddingBottom: '0.4em' }}>LeÃrás:</h5> + {lastDesc} + </Segment> + <Segment attached='bottom'> + <h5>Beadott fájl:</h5> + {lastFile + ? <a href={lastFile} rel='noreferrer noopener' target='_blank'>Fájl letöltése</a> + : <span>-</span>} + </Segment> + </div> + ) + + : null} + <Divider /> + <Form.Field + control={Input} + label='Megoldás cÃme:' + name='name' + onChange={(e) => this.props.writeSolution(e)} + value={name} + placeholder='Adj meg egy cÃmet a beadandó megoldásodnak...' + /> + <Form.Field + control={TextArea} + label='Megoldás leÃrása:' + name='description' + onChange={(e) => this.props.writeSolution(e)} + value={description} + placeholder='Add meg a megoldás leÃrását...' + /> + <Form.Field> + <label> + Fájl (Megengedett fájltÃpusok: png, jpeg, jpg, zip. Maximum 50 MB.): + </label> + <Input type='file' onChange={(e) => this.props.writeSolutionFile(e)} /> + </Form.Field> + </Form> + )} </Modal.Content> <Modal.Actions> <Button @@ -162,73 +184,78 @@ class AddSolutionForm extends Component { this.props.clearWrite(); }} > - <Icon name='remove' /> Mégse + <Icon name='remove' /> + {' '} +Mégse </Button> {this.props.multiple - ? + ? ( <ConfirmModal - button={ + button={( <Button disabled={ - !name || !description || - (!file ? false : !allowedFileTypes.includes(file.type) || - file.size > (maxFileSize) * (1024 ** 2)) + !name || !description + || (!file ? false : !allowedFileTypes.includes(file.type) + || file.size > (maxFileSize) * (1024 ** 2)) } inverted color='green' > - <Icon name='checkmark' /> - Beadás - {this.state.loading? - <Dimmer active> - <Loader size='massive'/> - </Dimmer> - : null } + <Icon name='checkmark' /> + Beadás + {this.state.loading + ? ( + <Dimmer active> + <Loader size='massive' /> + </Dimmer> + ) + : null } </Button> - } + )} text='beadod az új megoldást, ami felülÃrja az elÅ‘zÅ‘t' onAccept={() => { this.setState({ - loading: true - }) + loading: true, + }); this.props.addSolution({ task, accepted, corrected, note, name, description, file, - }).then( (response)=> { - this.setState({ - loading: false, - showModal: false - }) - this.props.clearWrite(); - }, (response)=> { - this.setState({ - loading: false, - }) - alert('Sikertelen feltöltés!') + }).then(() => { + this.setState({ + loading: false, + showModal: false, }); - } - } + this.props.clearWrite(); + }, () => { + this.setState({ + loading: false, + }); + alert('Sikertelen feltöltés!'); + }); + }} /> - : + ) + : ( <Button inverted color='green' disabled={ - !name || !description || - (!file ? false : !allowedFileTypes.includes(file.type) || - file.size > (maxFileSize) * (1024 ** 2)) + !name || !description + || (!file ? false : !allowedFileTypes.includes(file.type) + || file.size > (maxFileSize) * (1024 ** 2)) } onClick={() => { - this.props.addSolution({ - task, accepted, corrected, note, name, description, file, + this.props.addSolution({ + task, accepted, corrected, note, name, description, file, }); - this.setState({ showModal: false }); - this.props.clearWrite(); - } - } + this.setState({ showModal: false }); + this.props.clearWrite(); + }} > - <Icon name='checkmark' /> Beadás + <Icon name='checkmark' /> + {' '} +Beadás </Button> - } + )} </Modal.Actions> </Modal> ); diff --git a/src/components/forms/AddTaskForm.js b/src/components/forms/AddTaskForm.js index 46f74bb..c8729b0 100644 --- a/src/components/forms/AddTaskForm.js +++ b/src/components/forms/AddTaskForm.js @@ -1,9 +1,13 @@ 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 { DateTimeInput } from 'semantic-ui-calendar-react'; import moment from 'moment'; -import { addTask, writeTask, writeTaskDeadline, clearWrite } from '../../actions/homework'; +import { + addTask, writeTask, writeTaskDeadline, clearWrite, +} from '../../actions/homework'; class AddTaskForm extends Component { constructor(props) { @@ -14,22 +18,26 @@ class AddTaskForm extends Component { } render() { - const { title, text, deadline, bits = 1 } = this.props.newTask; + const { + title, text, deadline, bits = 1, + } = this.props.newTask; return ( <Modal open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={ + trigger={( <Button inverted style={{ marginRight: '2em' }} color='blue' onClick={() => { this.setState({ showModal: true }); }} > - <Icon name='plus' /> Új feladat hozzáadása + <Icon name='plus' /> + {' '} +Új feladat hozzáadása </Button> - } + )} > <Modal.Header>Új feladat:</Modal.Header> <Modal.Content> @@ -38,7 +46,7 @@ class AddTaskForm extends Component { control={Input} label='CÃm:' name='title' - onChange={e => this.props.writeTask(e)} + onChange={(e) => this.props.writeTask(e)} value={title} placeholder='Add meg a feladat cÃmét.' /> @@ -46,7 +54,7 @@ class AddTaskForm extends Component { control={TextArea} label='LeÃrás:' name='text' - onChange={e => this.props.writeTask(e)} + onChange={(e) => this.props.writeTask(e)} value={text} placeholder='Add meg a feladat leÃrását...' /> @@ -67,7 +75,7 @@ class AddTaskForm extends Component { type='number' label='Bitek száma:' name='bits' - onChange={e => this.props.writeTask(e)} + onChange={(e) => this.props.writeTask(e)} value={bits} placeholder='Add meg a feladatért kapható bitek számát ...' /> @@ -82,24 +90,30 @@ class AddTaskForm extends Component { this.props.clearWrite(); }} > - <Icon name='remove' /> Mégse + <Icon name='remove' /> + {' '} +Mégse </Button> <Button inverted color='green' disabled={ - title === '' || - title.length > 150 || - text === '' || - deadline === '' || moment().isAfter(deadline) + title === '' + || title.length > 150 + || text === '' + || deadline === '' || moment().isAfter(deadline) } onClick={() => { - this.props.addTask({ title, text, deadline, bits }); + this.props.addTask({ + title, text, deadline, bits, + }); this.setState({ showModal: false }); this.props.clearWrite(); - }} + }} > - <Icon name='checkmark' /> Hozzáadás + <Icon name='checkmark' /> + {' '} +Hozzáadás </Button> </Modal.Actions> </Modal> diff --git a/src/components/forms/ConfirmModal.js b/src/components/forms/ConfirmModal.js index 91a68e2..0fbbaac 100644 --- a/src/components/forms/ConfirmModal.js +++ b/src/components/forms/ConfirmModal.js @@ -1,5 +1,7 @@ import React, { Component } from 'react'; -import { Button, Header, Icon, Modal } from 'semantic-ui-react'; +import { + Button, Header, Icon, Modal, +} from 'semantic-ui-react'; class ConfirmModal extends Component { constructor(props) { @@ -11,47 +13,54 @@ class ConfirmModal extends Component { close = () => this.setState({ showModal: false }) - open = () => this.setState({ showModal: true}) + open = () => this.setState({ showModal: true }) - render() { - const { button, text, onAccept } = this.props; - const open = this.state.showModal; - return ( - <Modal - open={open} - closeOnDimmerClick - trigger={button} - onOpen={this.open} - onClose={this.close} - size='small' - basic - > - <Header icon='question' content='MegerÅ‘sÃtés' /> - <Modal.Content> - <p> - Biztos hogy {text}? - </p> - </Modal.Content> - <Modal.Actions> - <Button - basic - color='red' - inverted - onClick={() => this.close()} - > - <Icon name='remove' /> Nem - </Button> - <Button - color='green' - inverted - onClick={() => { onAccept(); this.close(); }} - > - <Icon name='checkmark' /> Igen - </Button> - </Modal.Actions> - </Modal> - ); - } + render() { + const { button, text, onAccept } = this.props; + const open = this.state.showModal; + return ( + <Modal + open={open} + closeOnDimmerClick + trigger={button} + onOpen={this.open} + onClose={this.close} + size='small' + basic + > + <Header icon='question' content='MegerÅ‘sÃtés' /> + <Modal.Content> + <p> + Biztos hogy + {' '} + {text} +? + </p> + </Modal.Content> + <Modal.Actions> + <Button + basic + color='red' + inverted + onClick={() => this.close()} + > + <Icon name='remove' /> + {' '} +Nem + </Button> + <Button + color='green' + inverted + onClick={() => { onAccept(); this.close(); }} + > + <Icon name='checkmark' /> + {' '} +Igen + </Button> + </Modal.Actions> + </Modal> + ); + } } export default ConfirmModal; diff --git a/src/components/forms/CorrectSolutionForm.js b/src/components/forms/CorrectSolutionForm.js index 374769b..87d9ef6 100644 --- a/src/components/forms/CorrectSolutionForm.js +++ b/src/components/forms/CorrectSolutionForm.js @@ -1,14 +1,18 @@ import React, { Component } from 'react'; -import { Modal, Button, Icon, Checkbox, Form, TextArea, Header } from 'semantic-ui-react'; +import { + Modal, Button, Icon, Checkbox, Form, TextArea, Header, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; -import { correctSolution, +import { + correctSolution, writeSolution, check, setchecktrue, clearWrite, getSolutions, getDocuments, - selectSolution } from '../../actions/homework'; + selectSolution, +} from '../../actions/homework'; class CorrectSolutionForm extends Component { constructor(props) { @@ -22,12 +26,12 @@ class CorrectSolutionForm extends Component { const { studentFullName, studentId, taskTitle, taskSolutions, } = this.props; - const taskSolutionsProfile = - taskSolutions.filter(solution => solution.created_by === studentId); + const taskSolutionsProfile = taskSolutions + .filter((solution) => solution.created_by === studentId); const relevantSolution = taskSolutionsProfile.slice(-1)[0]; - const relevantDocuments = this.props.homeworks.documents.filter(document => - document.solution === relevantSolution.id).filter(document => - document.uploaded_by_name === studentFullName); + const relevantDocuments = this.props.homeworks.documents + .filter((document) => document.solution === relevantSolution.id) + .filter((document) => document.uploaded_by_name === studentFullName); const relevantDocument = relevantDocuments.slice(-1)[0]; let fileLink; if (relevantDocument && relevantDocument.file_url) { @@ -45,7 +49,7 @@ class CorrectSolutionForm extends Component { open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={ + trigger={( <Button inverted color={this.props.color} @@ -57,27 +61,32 @@ class CorrectSolutionForm extends Component { > {studentFullName} </Button> - } + )} > <Modal.Header> - A(z) {taskTitle} nevű feladat {studentFullName} által beadott megoldásának kijavÃtása: + A(z) + {' '} + {taskTitle} + {' '} +nevű feladat + {' '} + {studentFullName} + {' '} +által beadott megoldásának kijavÃtása: </Modal.Header> <Modal.Content> <Header as='h5'>A megoldás cÃme:</Header> {(relevantDocument && relevantDocument.description) ? <p>{relevantDocument.name}</p> - : <p>Nincs cÃm.</p> - } + : <p>Nincs cÃm.</p>} <Header as='h5'>A megoldás leÃrása:</Header> {(relevantDocument && relevantDocument.description) - ? relevantDocument.description.split('\n').map(s => (<p key={Math.random()}>{s}</p>)) - : <p>Nincs leÃrás.</p> - } + ? relevantDocument.description.split('\n').map((s) => (<p key={Math.random()}>{s}</p>)) + : <p>Nincs leÃrás.</p>} <Header as='h5'>A beadott dokumentum:</Header> {fileLink ? <a href={fileLink} rel='noreferrer noopener' target='_blank'>Fájl letöltése</a> - : <p>Nincs fájl.</p> - } + : <p>Nincs fájl.</p>} <Header as='h5'>KijavÃtás állapotának változtatása:</Header> <Button color='orange' @@ -94,8 +103,8 @@ class CorrectSolutionForm extends Component { color='green' inverted={!accepted} onClick={() => { - this.props.check('accepted') - this.props.setchecktrue('corrected') + this.props.check('accepted'); + this.props.setchecktrue('corrected'); }} > <Checkbox @@ -118,7 +127,7 @@ class CorrectSolutionForm extends Component { <Form.Field control={TextArea} name='note' - onChange={e => this.props.writeSolution(e)} + onChange={(e) => this.props.writeSolution(e)} value={note} placeholder='Ãrhatsz megjegyzést a megoldásra...' /> @@ -133,7 +142,9 @@ class CorrectSolutionForm extends Component { this.props.clearWrite(); }} > - <Icon name='remove' /> Mégse + <Icon name='remove' /> + {' '} +Mégse </Button> <Button inverted @@ -149,7 +160,9 @@ class CorrectSolutionForm extends Component { this.props.clearWrite(); }} > - <Icon name='checkmark' /> Beadás + <Icon name='checkmark' /> + {' '} +Beadás </Button> </Modal.Actions> </Modal> diff --git a/src/components/forms/EditNewsForm.js b/src/components/forms/EditNewsForm.js index 816ce71..9d6035c 100644 --- a/src/components/forms/EditNewsForm.js +++ b/src/components/forms/EditNewsForm.js @@ -1,5 +1,7 @@ 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 moment from 'moment'; @@ -14,13 +16,15 @@ class EditNewsForm extends Component { } render() { - const { id, title, text, author, last_update_by, created_at, updated_at } = this.props.selectedNews; + const { + id, title, text, author, last_update_by, created_at, updated_at, + } = this.props.selectedNews; const updated_by = this.props.user.id; return ( <Modal open={this.state.showModal} onOpen={this.props.onClick} - trigger={ + trigger={( <Button compact onClick={() => { this.setState({ showModal: true }); }} @@ -28,20 +32,36 @@ class EditNewsForm extends Component { > Edit </Button> - } + )} > <Modal.Header>Szerkesztés:</Modal.Header> <Modal.Content> - <p style={{fontStyle: 'italic' }}><b>Közzétéve:</b> {moment(created_at).format('LLLL')} <br /> - <b>Ãrta:</b> {author} <br /> - <b>Szerkesztve:</b> {moment(updated_at).format('LLLL')} <br /> - <b>Szerkesztette:</b> {last_update_by}</p> + <p style={{ fontStyle: 'italic' }}> + <b>Közzétéve:</b> + {' '} + {moment(created_at).format('LLLL')} + {' '} + <br /> + <b>Ãrta:</b> + {' '} + {author} + {' '} + <br /> + <b>Szerkesztve:</b> + {' '} + {moment(updated_at).format('LLLL')} + {' '} + <br /> + <b>Szerkesztette:</b> + {' '} + {last_update_by} + </p> <Form> <Form.Field control={Input} label='Title' name='title' - onChange={e => this.props.writeNews(e)} + onChange={(e) => this.props.writeNews(e)} value={title} placeholder='Title' /> @@ -49,7 +69,7 @@ class EditNewsForm extends Component { control={TextArea} label='Text' name='text' - onChange={e => this.props.writeNews(e)} + onChange={(e) => this.props.writeNews(e)} value={text} placeholder='Tell us what you want...' /> @@ -61,20 +81,24 @@ class EditNewsForm extends Component { color='red' onClick={() => { this.setState({ showModal: false }); }} > - <Icon name='remove' /> Cancel + <Icon name='remove' /> + {' '} +Cancel </Button> <Button inverted color='green' onClick={() => { - this.props.editNews({ - id, title, text, updated_by, - }); - this.setState({ showModal: false }); - this.props.clearWrite(); - }} + this.props.editNews({ + id, title, text, updated_by, + }); + this.setState({ showModal: false }); + this.props.clearWrite(); + }} > - <Icon name='checkmark' /> Edit + <Icon name='checkmark' /> + {' '} +Edit </Button> </Modal.Actions> </Modal> diff --git a/src/components/forms/EditTaskForm.js b/src/components/forms/EditTaskForm.js index 83b4ad2..04f684c 100644 --- a/src/components/forms/EditTaskForm.js +++ b/src/components/forms/EditTaskForm.js @@ -1,9 +1,13 @@ 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 { DateTimeInput } from 'semantic-ui-calendar-react'; import moment from 'moment'; -import { writeTask, writeTaskDeadline, editTask, clearWrite } from '../../actions/homework'; +import { + writeTask, writeTaskDeadline, editTask, clearWrite, +} from '../../actions/homework'; class EditTaskForm extends Component { constructor(props) { @@ -27,25 +31,32 @@ class EditTaskForm extends Component { onOpen={this.props.onClick} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={ + trigger={( <Button inverted style={{ marginRight: '2em' }} color='orange' onClick={() => { this.setState({ showModal: true }); }} > - <Icon name='edit' /> MódosÃtás + <Icon name='edit' /> + {' '} +MódosÃtás </Button> - } + )} > - <Modal.Header>A {title} nevű feladat módosÃtása:</Modal.Header> + <Modal.Header> +A + {title} + {' '} +nevű feladat módosÃtása: + </Modal.Header> <Modal.Content> <Form> <Form.Field control={Input} label='CÃm:' name='title' - onChange={e => this.props.writeTask(e)} + onChange={(e) => this.props.writeTask(e)} value={title} placeholder='Add meg a feladat cÃmét.' /> @@ -53,7 +64,7 @@ class EditTaskForm extends Component { control={TextArea} label='LeÃrás:' name='text' - onChange={e => this.props.writeTask(e)} + onChange={(e) => this.props.writeTask(e)} value={text} placeholder='Add meg a feladat leÃrását...' /> @@ -74,7 +85,7 @@ class EditTaskForm extends Component { type='number' label='Bitek száma:' name='bits' - onChange={e => this.props.writeTask(e)} + onChange={(e) => this.props.writeTask(e)} value={bits} placeholder='Add meg a feladatért kapható bitek számát ...' /> @@ -89,16 +100,18 @@ class EditTaskForm extends Component { this.props.clearWrite(); }} > - <Icon name='remove' /> Mégse + <Icon name='remove' /> + {' '} +Mégse </Button> <Button inverted color='green' disabled={ - title === '' || - (title !== undefined ? title.length > 150 : false) || - text === '' || - deadline === '' || moment().isAfter(deadline) + title === '' + || (title !== undefined ? title.length > 150 : false) + || text === '' + || deadline === '' || moment().isAfter(deadline) } onClick={() => { this.props.editTask({ @@ -110,9 +123,11 @@ class EditTaskForm extends Component { }); this.setState({ showModal: false }); this.props.clearWrite(); - }} + }} > - <Icon name='checkmark' /> MódosÃtás + <Icon name='checkmark' /> + {' '} +MódosÃtás </Button> </Modal.Actions> </Modal> diff --git a/src/components/forms/HiddenForm.js b/src/components/forms/HiddenForm.js index 0aaeecc..200c34e 100644 --- a/src/components/forms/HiddenForm.js +++ b/src/components/forms/HiddenForm.js @@ -1,19 +1,19 @@ -import React, {Component} from 'react' +import React, { Component } from 'react'; import { Segment } from 'semantic-ui-react'; class HiddenForm extends Component { - render(){ - return ( - <div> - <div style={{ marginBottom: 0, fontWeight: this.props.fontWeight }}>{this.props.label}</div> - <Segment style={{ marginTop: 0 }}> - <div> - {this.props.value} - </div> - </Segment> - </div> - ) - } + render() { + return ( + <div> + <div style={{ marginBottom: 0, fontWeight: this.props.fontWeight }}>{this.props.label}</div> + <Segment style={{ marginTop: 0 }}> + <div> + {this.props.value} + </div> + </Segment> + </div> + ); + } } -export default HiddenForm \ No newline at end of file +export default HiddenForm; diff --git a/src/components/forms/InfoModal.js b/src/components/forms/InfoModal.js index e64dad9..e3d23d8 100644 --- a/src/components/forms/InfoModal.js +++ b/src/components/forms/InfoModal.js @@ -1,5 +1,7 @@ import React, { Component } from 'react'; -import { Button, Header, Icon, Modal } from 'semantic-ui-react'; +import { + Button, Header, Icon, Modal, +} from 'semantic-ui-react'; class InfoModal extends Component { constructor(props) { @@ -11,37 +13,39 @@ class InfoModal extends Component { close = () => this.setState({ showModal: false }) - open = () => this.setState({ showModal: true}) + open = () => this.setState({ showModal: true }) - render() { - const { button, title, content } = this.props; - const open = this.state.showModal; - return ( - <Modal - open={open} - closeOnDimmerClick - trigger={button} - onOpen={this.open} - onClose={this.close} - size='small' - basic - > - <Header icon='info' content={title} /> - <Modal.Content> - {content.split('\n').map(s => (<p key={Math.random()}>{s}</p>))} - </Modal.Content> - <Modal.Actions> - <Button - color='green' - inverted - onClick= {() => this.close()} - > - <Icon name='checkmark' /> Rendben - </Button> - </Modal.Actions> - </Modal> - ); - } + render() { + const { button, title, content } = this.props; + const open = this.state.showModal; + return ( + <Modal + open={open} + closeOnDimmerClick + trigger={button} + onOpen={this.open} + onClose={this.close} + size='small' + basic + > + <Header icon='info' content={title} /> + <Modal.Content> + {content.split('\n').map((s) => (<p key={Math.random()}>{s}</p>))} + </Modal.Content> + <Modal.Actions> + <Button + color='green' + inverted + onClick={() => this.close()} + > + <Icon name='checkmark' /> + {' '} +Rendben + </Button> + </Modal.Actions> + </Modal> + ); + } } export default InfoModal; diff --git a/src/components/forms/SolutionDetailsForm.js b/src/components/forms/SolutionDetailsForm.js index b7ab9b7..9d766c5 100644 --- a/src/components/forms/SolutionDetailsForm.js +++ b/src/components/forms/SolutionDetailsForm.js @@ -1,5 +1,7 @@ import React, { Component } from 'react'; -import { Modal, Button, Header, Icon, Divider } from 'semantic-ui-react'; +import { + Modal, Button, Header, Icon, Divider, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import CorrectSolutionForm from './CorrectSolutionForm'; import { customMessage } from '../pages/Homework'; @@ -18,8 +20,8 @@ class SolutionDetailsForm extends Component { } render() { - const taskSolutions = this.props.homeworks.solutions.filter(solution => - solution.task === this.props.taskid); + const taskSolutions = this.props.homeworks.solutions + .filter((solution) => solution.task === this.props.taskid); const noSubmitStudents = []; const waitForCorrectionStudents = []; @@ -27,8 +29,8 @@ class SolutionDetailsForm extends Component { const acceptedStudents = []; this.props.homeworks.profiles.forEach((profile) => { - const profileSolutions = taskSolutions.filter(solution => - solution.created_by === profile.id); + const profileSolutions = taskSolutions + .filter((solution) => solution.created_by === profile.id); if (profile.role === 'Student') { if (profileSolutions.length === 0) { @@ -50,8 +52,9 @@ class SolutionDetailsForm extends Component { open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={ + trigger={( <button + type='button' id='task' onClick={() => { this.setState({ showModal: true }); @@ -62,27 +65,30 @@ class SolutionDetailsForm extends Component { <Icon name='external' /> {this.props.tasktitle} </button> - } + )} > <Modal.Header> - A megoldások beadásának állapota a(z) {this.props.tasktitle} nevű feladatnál: + A megoldások beadásának állapota a(z) + {' '} + {this.props.tasktitle} + {' '} +nevű feladatnál: </Modal.Header> <Modal.Content> <Header as='h3'>A feladat leÃrása:</Header> - {this.props.taskdesc.split('\n').map(s => (<p key={Math.random()}>{s}</p>))} + {this.props.taskdesc.split('\n').map((s) => (<p key={Math.random()}>{s}</p>))} <Divider /> <Header as='h3'>Nem érkezett még megoldás:</Header> - {noSubmitStudents.length === 0 ? - customMessage(noStudentText) : - noSubmitStudents.map(student => ( - <Button key={Math.random()} color='blue' style={{ marginRight: '1.5em', marginTop: '1.5em' }}>{student.full_name}</Button> - )) - } + {noSubmitStudents.length === 0 + ? customMessage(noStudentText) + : noSubmitStudents.map((student) => ( + <Button key={Math.random()} color='blue' style={{ marginRight: '1.5em', marginTop: '1.5em' }}>{student.full_name}</Button> + ))} <Divider /> <Header as='h3'>JavÃtásra vár (A névre kattintva kijavÃtható a megoldás):</Header> - {waitForCorrectionStudents.length === 0 ? - customMessage(noStudentText) : - waitForCorrectionStudents.map(student => ( + {waitForCorrectionStudents.length === 0 + ? customMessage(noStudentText) + : waitForCorrectionStudents.map((student) => ( <CorrectSolutionForm key={Math.random()} color='orange' @@ -92,13 +98,12 @@ class SolutionDetailsForm extends Component { taskTitle={this.props.tasktitle} taskSolutions={taskSolutions} /> - )) - } + ))} <Divider /> <Header as='h3'>A megoldás nem elfogadható (A névre kattintva módosÃtható a javÃtás):</Header> - {noAcceptStudents.length === 0 ? - customMessage(noStudentText) : - noAcceptStudents.map(student => ( + {noAcceptStudents.length === 0 + ? customMessage(noStudentText) + : noAcceptStudents.map((student) => ( <CorrectSolutionForm key={Math.random()} color='red' @@ -108,13 +113,12 @@ class SolutionDetailsForm extends Component { taskTitle={this.props.tasktitle} taskSolutions={taskSolutions} /> - )) - } + ))} <Divider /> <Header as='h3'>Elfogadva (A névre kattintva módosÃtható a javÃtás):</Header> - {acceptedStudents.length === 0 ? - customMessage(noStudentText) : - acceptedStudents.map(student => ( + {acceptedStudents.length === 0 + ? customMessage(noStudentText) + : acceptedStudents.map((student) => ( <CorrectSolutionForm key={Math.random()} color='green' @@ -124,8 +128,7 @@ class SolutionDetailsForm extends Component { taskTitle={this.props.tasktitle} taskSolutions={taskSolutions} /> - )) - } + ))} </Modal.Content> <Modal.Actions> <Button @@ -133,9 +136,11 @@ class SolutionDetailsForm extends Component { color='green' onClick={() => { this.setState({ showModal: false }); - }} + }} > - <Icon name='checkmark' /> Kész + <Icon name='checkmark' /> + {' '} +Kész </Button> </Modal.Actions> </Modal> @@ -147,4 +152,4 @@ const mapStateToProps = ({ homeworks, user }) => ({ homeworks, user }); export default connect(mapStateToProps, { getSolutions, getDocuments, -})(SolutionDetailsForm); \ No newline at end of file +})(SolutionDetailsForm); diff --git a/src/components/pages/ApplicantProfile.js b/src/components/pages/ApplicantProfile.js index 3a6d641..0c7ec84 100644 --- a/src/components/pages/ApplicantProfile.js +++ b/src/components/pages/ApplicantProfile.js @@ -1,5 +1,7 @@ import React, { Component } from 'react'; -import { Container, Header, Item, Button, Label } from 'semantic-ui-react'; +import { + Container, Header, Item, Button, Label, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import { getSelectedProfile, setStatus } from '../../actions/statistics'; import ConfirmModal from '../forms/ConfirmModal'; @@ -33,97 +35,97 @@ class ApplicantProfile extends Component { } render() { - const { id, signed, role, full_name, - nick, motivation_about, motivation_exercise, - motivation_profession, groups } - = this.props.selectedProfile; + const { + id, signed, role, full_name, + nick, motivation_about, motivation_exercise, + motivation_profession, groups, + } = this.props.selectedProfile; return ( <Container style={{ paddingTop: '3em', paddingBottom: '6em' }}> <Item> <Item.Content> - <Container textAlign='center' style={{paddingBottom: '2em'}}> + <Container textAlign='center' style={{ paddingBottom: '2em' }}> <Header as='h2'>{full_name}</Header> <Item.Meta>{nick}</Item.Meta> - <Header as='h2'>{groups?.map(group => { - return ( - <Label color={groupTypes[group].color}> - {groupTypes[group].name} - </Label> - ) - })}</Header> + <Header as='h2'> + {groups?.map((group) => ( + <Label color={groupTypes[group].color}> + {groupTypes[group].name} + </Label> + ))} + </Header> </Container> <Item.Description> <Container textAlign='justified' style={{ padding: '1em' }}> <Header as='h3'>Magamról, eddigi tevékenységem:</Header> - <p>{motivation_about + <p> + {motivation_about ?.split ('\n').map ((item, i) => <div key={i}>{item}</div>)} </p> <Header as='h3'>Szakmai motiváció:</Header> - <p>{motivation_profession + <p> + {motivation_profession ?.split ('\n').map ((item, i) => <div key={i}>{item}</div>)} </p> <Header as='h3'>Feladatok megoldása:</Header> - <p>{motivation_exercise + <p> + {motivation_exercise ?.split ('\n').map ((item, i) => <div key={i}>{item}</div>)} </p> - + </Container> <Container textAlign='center' style={{ padding: '1em' }}> <Header as='h3'>Státusz:</Header> - { signed ? - <div> - { role === 'Student' ? - <Label color='green' size='huge'>Elfogadva</Label> - : - null - } - { role === 'Staff' ? - <Label color='blue' size='huge'>Staff</Label> - : - null - } - { role === 'Applicant' ? - <Label color='orange' size='huge'>Jelentkezett</Label> - : - null - } - { role === 'Denied' ? - <Label color='red' size='huge'>ElutasÃtva</Label> - : - null - } - </div> - : - <Label color='red' size='huge'>Nem jelentkezett</Label> - } + { signed + ? ( + <div> + { role === 'Student' + ? <Label color='green' size='huge'>Elfogadva</Label> + : null} + { role === 'Staff' + ? <Label color='blue' size='huge'>Staff</Label> + : null} + { role === 'Applicant' + ? <Label color='orange' size='huge'>Jelentkezett</Label> + : null} + { role === 'Denied' + ? <Label color='red' size='huge'>ElutasÃtva</Label> + : null} + </div> + ) + : <Label color='red' size='huge'>Nem jelentkezett</Label>} </Container> </Item.Description> </Item.Content> </Item> - { signed && role !== 'Staff' ? - <Container textAlign='center'> - <ConfirmModal - button={ - <Button - color='green' - >Jelentkezés elfogadása - </Button>} - text='elfogadod a jelentkezést' - onAccept={() => this.props.setStatus(id, 'Student')} - /> - <ConfirmModal - button={ - <Button - color='red' - >Jelentkezés elutasÃtása - </Button>} - text='elutasÃtod a jelentkezést' - onAccept={() => this.props.setStatus(id, 'Denied')} - /> - </Container> - : - null - } + { signed && role !== 'Staff' + ? ( + <Container textAlign='center'> + <ConfirmModal + button={( + <Button + color='green' + > +Jelentkezés elfogadása + </Button> + )} + text='elfogadod a jelentkezést' + onAccept={() => this.props.setStatus(id, 'Student')} + /> + <ConfirmModal + button={( + <Button + color='red' + > +Jelentkezés elutasÃtása + </Button> + )} + text='elutasÃtod a jelentkezést' + onAccept={() => this.props.setStatus(id, 'Denied')} + /> + </Container> + ) + : null} </Container> ); } diff --git a/src/components/pages/Applications.js b/src/components/pages/Applications.js index f3c2a1a..6a372ba 100644 --- a/src/components/pages/Applications.js +++ b/src/components/pages/Applications.js @@ -1,6 +1,8 @@ import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -import { Container, Table, Label, Button } from 'semantic-ui-react'; +import { + Container, Table, Label, Button, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import { getProfiles, setStatus } from '../../actions/statistics'; import ConfirmModal from '../forms/ConfirmModal'; @@ -9,27 +11,27 @@ const role = [ { role: 'Staff', text: 'Staff', - color: 'blue' + color: 'blue', }, { role: 'Student', text: 'Elfogadott', - color: 'green' + color: 'green', }, { role: 'Applicant', text: 'Jelentkezett', - color: 'orange' + color: 'orange', }, { role: 'Denied', text: 'ElutasÃtott', - color: 'red' + color: 'red', }, { role: 'no', text: 'Nem jelentkezett', - color: 'red' + color: 'red', }, ]; @@ -39,65 +41,71 @@ class Applications extends Component { } renderApplicants(format) { - return this.props.profiles.map((profile) => - { return ( - profile.role === format.role - && (profile.signed === true || - profile.role === 'Staff') ? - <Table.Row key={profile.id}> - <Table.Cell textAlign='center'> - <Link to={`applicant/${profile.id}`}> - {profile.full_name} - </Link> - </Table.Cell> - { format.role === 'Staff' ? null : + return this.props.profiles.map((profile) => ( + profile.role === format.role + && (profile.signed === true + || profile.role === 'Staff') + ? ( + <Table.Row key={profile.id}> <Table.Cell textAlign='center'> - <ConfirmModal - button = {<Button - color='blue' - size='tiny' - > - ADD STAFF STATUS - </Button>} - text='staff jogot adsz neki' - onAccept={() => this.props.setStatus(profile.id, 'Staff')} - /> + <Link to={`applicant/${profile.id}`}> + {profile.full_name} + </Link> </Table.Cell> - } - </Table.Row> - : null - ); - }); + { format.role === 'Staff' ? null + : ( + <Table.Cell textAlign='center'> + <ConfirmModal + button={( + <Button + color='blue' + size='tiny' + > + ADD STAFF STATUS + </Button> +)} + text='staff jogot adsz neki' + onAccept={() => this.props.setStatus(profile.id, 'Staff')} + /> + </Table.Cell> + )} + </Table.Row> + ) + : null + )); } renderNotApplicants(format) { - return this.props.profiles.map((profile) => - { return ( - profile.signed === false && profile.role !== 'Staff'? - <Table.Row key={profile.id}> - <Table.Cell textAlign='center'> - <Link to={`applicant/${profile.id}`}> - {profile.full_name} - </Link> - </Table.Cell> - { format.role === 'Staff' ? null : + return this.props.profiles.map((profile) => ( + profile.signed === false && profile.role !== 'Staff' + ? ( + <Table.Row key={profile.id}> <Table.Cell textAlign='center'> - <ConfirmModal - button = {<Button - color='blue' - size='tiny' - > - ADD STAFF STATUS - </Button>} - text='staff jogot adsz neki' - onAccept={() => this.props.setStatus(profile.id, 'Staff')} - /> + <Link to={`applicant/${profile.id}`}> + {profile.full_name} + </Link> </Table.Cell> - } - </Table.Row> - : null - ); - }); + { format.role === 'Staff' ? null + : ( + <Table.Cell textAlign='center'> + <ConfirmModal + button={( + <Button + color='blue' + size='tiny' + > + ADD STAFF STATUS + </Button> +)} + text='staff jogot adsz neki' + onAccept={() => this.props.setStatus(profile.id, 'Staff')} + /> + </Table.Cell> + )} + </Table.Row> + ) + : null + )); } renderTable(format) { @@ -108,52 +116,56 @@ class Applications extends Component { <Table.HeaderCell textAlign='center'> <Label color={format.color}>{format.text}</Label> </Table.HeaderCell> - {format.role !== 'Staff' ? - <Table.HeaderCell width={3} textAlign='center'> - <Label color={null}> - {format.role === 'no' ? - this.props.profiles.filter(profile => { - return profile.signed === false - && profile.role !== 'Staff' - }).length - : - this.props.profiles.filter(profile => { - return profile.role === format.role - && (profile.signed === true - || profile.role === 'Staff') - }).length - } fÅ‘ - </Label> - </Table.HeaderCell> - : null - } - + {format.role !== 'Staff' + ? ( + <Table.HeaderCell width={3} textAlign='center'> + <Label color={null}> + {format.role === 'no' + ? this.props.profiles.filter((profile) => profile.signed === false + && profile.role !== 'Staff').length + : this.props.profiles.filter((profile) => profile.role === format.role + && (profile.signed === true + || profile.role === 'Staff')).length} + {' '} +fÅ‘ + </Label> + </Table.HeaderCell> + ) + : null} + </Table.Row> </Table.Header> <Table.Body> - {format.role === 'no' ? - this.renderNotApplicants(format) - : - this.renderApplicants(format) - } + {format.role === 'no' + ? this.renderNotApplicants(format) + : this.renderApplicants(format)} </Table.Body> </Table> - ) + ); } - - render() { return ( <Container - textAlign='center' style={{paddingTop: '1em', paddingBottom: '5em'}} + textAlign='center' + style={{ paddingTop: '1em', paddingBottom: '5em' }} > - {this.renderTable(role[2])} {/* Applicant */} - {this.renderTable(role[1])} {/* Student */} - {this.renderTable(role[0])} {/* Staff */} - {this.renderTable(role[3])} {/* Denied */} - {this.renderTable(role[4])} {/* Not Signed */} + {this.renderTable(role[2])} + {' '} + {/* Applicant */} + {this.renderTable(role[1])} + {' '} + {/* Student */} + {this.renderTable(role[0])} + {' '} + {/* Staff */} + {this.renderTable(role[3])} + {' '} + {/* Denied */} + {this.renderTable(role[4])} + {' '} + {/* Not Signed */} </Container> ); } diff --git a/src/components/pages/EventDetail.js b/src/components/pages/EventDetail.js index a3282e6..eb215cf 100644 --- a/src/components/pages/EventDetail.js +++ b/src/components/pages/EventDetail.js @@ -12,8 +12,12 @@ import { } from 'semantic-ui-react'; import { connect } from 'react-redux'; import moment from 'moment'; -import { getEventById, getTrainees, visitorChange, submitVisitors } from '../../actions/statistics'; -import { getNotesByEvent, writeNote, clearWrite, postEventNote } from '../../actions/notes'; +import { + getEventById, getTrainees, visitorChange, submitVisitors, +} from '../../actions/statistics'; +import { + getNotesByEvent, writeNote, clearWrite, postEventNote, +} from '../../actions/notes'; import TraineeTableRow from './EventDetailTableRow'; @@ -35,17 +39,19 @@ class EventDetail extends Component { renderTrainees() { const event = this.props.selectedEvent; return this.props.trainees?.map((item) => { - const notes = this.props.eventNotes?.filter(note => note.profile === item.id); + const notes = this.props.eventNotes?.filter((note) => note.profile === item.id); return ( - item.role === 'Student' ? - <TraineeTableRow - selectedEvent={event} - notes={notes} - trainee={item} - edit={this.state.edit} - key={item.id} - /> - : null + item.role === 'Student' + ? ( + <TraineeTableRow + selectedEvent={event} + notes={notes} + trainee={item} + edit={this.state.edit} + key={item.id} + /> + ) + : null ); }); } @@ -55,10 +61,10 @@ class EventDetail extends Component { return ( <Segment> <Item> - <Divider style={{ fontSize: '2em'}} horizontal> + <Divider style={{ fontSize: '2em' }} horizontal> <Header as='h1'> {name} - <Item.Header style={{ fontSize: '0.6em'}}> + <Item.Header style={{ fontSize: '0.6em' }}> {moment(date).format('LL')} </Item.Header> </Header> @@ -89,7 +95,8 @@ class EventDetail extends Component { </Comment.Text> </Comment.Content> </Comment> - </Segment>); + </Segment> + ); } return ''; }); @@ -99,13 +106,11 @@ class EventDetail extends Component { const event = this.props.selectedEvent; const note = this.props.actualNote; return ( - <Container style={{paddingTop: '1em', paddingBottom: '7em'}}> + <Container style={{ paddingTop: '1em', paddingBottom: '7em' }}> <Container textAlign='center'> - { this.props.selectedEvent && this.props.trainees ? - this.renderEvent() - : - '' - } + { this.props.selectedEvent && this.props.trainees + ? this.renderEvent() + : ''} </Container> <Table celled unstackable> <Table.Header> @@ -116,46 +121,47 @@ class EventDetail extends Component { </Table.Row> </Table.Header> <Table.Body> - { this.props.selectedEvent ? - this.renderTrainees() - : - null - } + { this.props.selectedEvent + ? this.renderTrainees() + : null} </Table.Body> </Table> - {!this.state.edit ? - <Button onClick={() => this.setState({ edit: true })}> + {!this.state.edit + ? ( + <Button onClick={() => this.setState({ edit: true })}> MódosÃtás - </Button> - : - <Button onClick={() => { + </Button> + ) + : ( + <Button onClick={() => { this.setState({ edit: false }); this.props.submitVisitors(this.props.selectedEvent); }} - > Kész - </Button> - } + > + {' '} +Kész + </Button> + )} <Comment.Group> <Header dividing> Megjegyzések </Header> - {this.props.eventNotes ? - this.renderComments() - : - '' - } + {this.props.eventNotes + ? this.renderComments() + : ''} <Form reply> <Form.TextArea value={note.note} - onChange={e => this.props.writeNote(e)} + onChange={(e) => this.props.writeNote(e)} /> <Button onClick={() => { - this.props.postEventNote({ eventid: event.id, - note: note.note }); - this.props.clearWrite(); - } - } + this.props.postEventNote({ + eventid: event.id, + note: note.note, + }); + this.props.clearWrite(); + }} content='Megjegyzés hozzáadása' labelPosition='left' icon='edit' @@ -171,8 +177,10 @@ class EventDetail extends Component { const mapStateToProps = ({ notes: { eventNotes, actualNote }, events: { selectedEvent }, - trainees: { trainees } -}) => ({ eventNotes, selectedEvent, trainees, actualNote }); + trainees: { trainees }, +}) => ({ + eventNotes, selectedEvent, trainees, actualNote, +}); export default connect(mapStateToProps, { getEventById, diff --git a/src/components/pages/EventDetailTableRow.js b/src/components/pages/EventDetailTableRow.js index ce5988f..b81b6be 100644 --- a/src/components/pages/EventDetailTableRow.js +++ b/src/components/pages/EventDetailTableRow.js @@ -25,8 +25,8 @@ const visitStates = [ { text: 'Nem', value: 'No', - } -] + }, +]; class TraineeTableRow extends Component { constructor(props) { @@ -37,8 +37,9 @@ class TraineeTableRow extends Component { }; } - // Hides and shows the Add and More popup - triggerAdd = () => this.setState({ ...this.state, showAddPopup: !this.state.showAddPopup}) + // Hides and shows the Add and More popup + triggerAdd = () => this.setState({ ...this.state, showAddPopup: !this.state.showAddPopup }) + triggerMore = () => this.setState({ ...this.state, showMorePopup: !this.state.showMorePopup }) render() { @@ -46,118 +47,136 @@ class TraineeTableRow extends Component { const { trainee, selectedEvent, notes } = this.props; const isVisitor = selectedEvent.visitors.includes(trainee.id); const isAbsent = selectedEvent.absent.includes(trainee.id); + let visitorStatusIcon; + let visitorStatusDropdown; + if (isVisitor) { + visitorStatusIcon = <Icon color='green' name='checkmark' />; + visitorStatusDropdown = 'Visitor'; + } else if (isAbsent) { + visitorStatusIcon = <Icon color='orange' name='minus' />; + visitorStatusDropdown = 'Absent'; + } else { + visitorStatusIcon = <Icon color='red' name='cancel' />; + visitorStatusDropdown = 'No'; + } + return ( <Table.Row> <Table.Cell textAlign='center'> {trainee.full_name} </Table.Cell> {/* Show and change Visitors status */} - {!this.props.edit ? - <Table.Cell textAlign='center'> - { - isVisitor ? - <Icon color='green' name='checkmark' /> - : - isAbsent ? - <Icon color='orange' name='minus' /> - : - <Icon color='red' name='cancel' /> + {!this.props.edit + ? ( + <Table.Cell textAlign='center'> + { + visitorStatusIcon } - </Table.Cell> - : - <Table.Cell textAlign='center'> - <Dropdown - defaultValue={isVisitor ? 'Visitor' : isAbsent ? 'Absent' : 'No'} - selection - options={visitStates} - onChange={(_, v) => { - this.props.visitorChange({ id : trainee.id, value: v.value }) - // Submit with error check - this.props.submitVisitors(this.props.selectedEvent) - .then( value => { - if(value === true) { - console.log('success') - } else { - console.log('error') - } - }) - }} - /> - - </Table.Cell> - } + </Table.Cell> + ) + : ( + <Table.Cell textAlign='center'> + <Dropdown + defaultValue={visitorStatusDropdown} + selection + options={visitStates} + onChange={(_, v) => { + this.props.visitorChange({ id: trainee.id, value: v.value }); + // Submit with error check + this.props.submitVisitors(this.props.selectedEvent) + .then((value) => { + if (value === true) { + console.log('success'); + } else { + console.log('error'); + } + }); + }} + /> + + </Table.Cell> + )} {/* Notes for trainees */} <Table.Cell> <Grid> <Grid.Row> {/* Note text */} <Grid.Column floated='left' width={8}> - {notes.length > 0 ? - <Comment> - <Comment.Content> - <Comment.Author><b>{notes[0].created_by_name}:</b></Comment.Author> - <Comment.Text style={{wordWrap: 'break-word'}}> - {notes[0].note.length > 25 ? - notes[0].note.slice(0, 25).concat('...') - : - notes[0].note - } - </Comment.Text> - </Comment.Content> - </Comment> - : - null - } + {notes.length > 0 + ? ( + <Comment> + <Comment.Content> + <Comment.Author> + <b> + {notes[0].created_by_name} +: + </b> + </Comment.Author> + <Comment.Text style={{ wordWrap: 'break-word' }}> + {notes[0].note.length > 25 + ? notes[0].note.slice(0, 25).concat('...') + : notes[0].note} + </Comment.Text> + </Comment.Content> + </Comment> + ) + : null} </Grid.Column> {/* Note buttons */} <Grid.Column floated='right' width={6} textAlign='right'> - {notes.length > 0 ? - <Popup basic - open={this.state.showMorePopup} - trigger={ - <Button icon='comment alternate outline' onClick={this.triggerMore} /> + {notes.length > 0 + ? ( + <Popup + basic + open={this.state.showMorePopup} + trigger={ + <Button icon='comment alternate outline' onClick={this.triggerMore} /> } - content={notes.map((note) => { - return ( + content={notes.map((oneNote) => ( <Comment.Content> - <Comment.Author><b>{note.created_by_name}:</b></Comment.Author> + <Comment.Author> + <b> + {oneNote.created_by_name} + : + </b> + </Comment.Author> <Comment.Text> - {note.note} + {oneNote.note} </Comment.Text> </Comment.Content> - ); - })} - /> - : - null - } - <Popup basic + ))} + /> + ) + : null} + <Popup + basic trigger={ - <Button icon='plus' onClick={this.triggerAdd}/> + <Button icon='plus' onClick={this.triggerAdd} /> } open={this.state.showAddPopup} - content={ + content={( <Form reply> <Form.TextArea value={note.note} - onChange={e => this.props.writeNote(e)} + onChange={(e) => this.props.writeNote(e)} /> - <Button primary + <Button + primary onClick={() => { - this.triggerAdd() - this.props.postEventNote({ + this.triggerAdd(); + this.props.postEventNote({ eventid: selectedEvent.id, userid: trainee.id, - note: note.note - }) - this.props.clearWrite() + note: note.note, + }); + this.props.clearWrite(); }} content='Megjegyzés hozzáadása' labelPosition='left' icon='edit' /> </Form> - } + )} /> </Grid.Column> </Grid.Row> @@ -167,9 +186,13 @@ class TraineeTableRow extends Component { ); } } -const mapStateToProps = ({ notes: { actualNote } }) => ({ actualNote }) +const mapStateToProps = ({ notes: { actualNote } }) => ({ actualNote }); -export default connect(mapStateToProps, - { writeNote, clearWrite, postEventNote, - visitorChange, submitVisitors}) - (TraineeTableRow) +export default connect(mapStateToProps, + { + writeNote, + clearWrite, + postEventNote, + visitorChange, + submitVisitors, + })(TraineeTableRow); diff --git a/src/components/pages/Events.js b/src/components/pages/Events.js index bc920fb..f11b673 100644 --- a/src/components/pages/Events.js +++ b/src/components/pages/Events.js @@ -12,41 +12,45 @@ class Events extends Component { } renderEvents() { - return this.props.events.map((event) => { - return ( - <Table.Row key={event.id}> - <Table.Cell textAlign='center'> - <Link to={`events/${event.id}`}> - {event.name} - </Link> - </Table.Cell> - <Table.Cell textAlign='center'> - {moment(event.date).format('LL')} - </Table.Cell> - <Table.Cell textAlign='center'> - {event.visitor_number} - </Table.Cell> - <Table.Cell textAlign='center'> - <Button - onClick={() => this.props.deleteEvent(event)} - color='red' - compact - size='small' - > + return this.props.events.map((event) => ( + <Table.Row key={event.id}> + <Table.Cell textAlign='center'> + <Link to={`events/${event.id}`}> + {event.name} + </Link> + </Table.Cell> + <Table.Cell textAlign='center'> + {moment(event.date).format('LL')} + </Table.Cell> + <Table.Cell textAlign='center'> + {event.visitor_number} + </Table.Cell> + <Table.Cell textAlign='center'> + <Button + onClick={() => this.props.deleteEvent(event)} + color='red' + compact + size='small' + > Törlés - </Button> - </Table.Cell> - </Table.Row> - ); - }); + </Button> + </Table.Cell> + </Table.Row> + )); } render() { return ( <Container textAlign='center'> - <div style={{overflowX: 'scroll'}}> - <Table color='blue' unstackable celled selectable compact - size='small'> + <div style={{ overflowX: 'scroll' }}> + <Table + color='blue' + unstackable + celled + selectable + compact + size='small' + > <Table.Header> <Table.Row> <Table.HeaderCell textAlign='center'>Alkalom neve</Table.HeaderCell> @@ -61,7 +65,7 @@ class Events extends Component { </Table> </div> <br /> - <AddEventForm/> + <AddEventForm /> </Container> ); } diff --git a/src/components/pages/Groups.js b/src/components/pages/Groups.js index da6dc34..fadf91b 100644 --- a/src/components/pages/Groups.js +++ b/src/components/pages/Groups.js @@ -1,15 +1,15 @@ import React, { Component } from 'react'; import { Container, Header, Segment } from 'semantic-ui-react'; import './Groups.css'; -import GroupCard from '../extra/GroupCard' - import { connect } from 'react-redux'; +import GroupCard from '../extra/GroupCard'; + import { getGroups } from '../../actions/groups'; class Groups extends Component { UNSAFE_componentWillMount() { - this.props.getGroups() + this.props.getGroups(); } render() { @@ -30,12 +30,14 @@ class Groups extends Component { /> </Container> </Segment> - + <Segment style={{ padding: '1em 0em 5em' }} vertical> <Container text> - { this.props.groups.map(item => { - return <GroupCard key={item.id} label={item.name} value={item.description}/> - })} + { this.props.groups + // eslint-disable-next-line arrow-body-style + .map((item) => { + return <GroupCard key={item.id} label={item.name} value={item.description} />; + })} </Container> </Segment> </div> diff --git a/src/components/pages/Home.js b/src/components/pages/Home.js index 3dce0fe..598c1a1 100644 --- a/src/components/pages/Home.js +++ b/src/components/pages/Home.js @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-props-no-spreading */ import React, { Component } from 'react'; import { Button, @@ -14,7 +15,7 @@ import Slider from 'react-slick'; import { Link } from 'react-router-dom'; import './Home.css'; import KSZKbiglogo from '../images/kszk_with_shadow.png'; -import { getImages } from '../../actions/home' +import { getImages } from '../../actions/home'; const settings = { dots: false, @@ -36,12 +37,12 @@ class Home extends Component { } renderSlider(view, imageWidth) { - if(view === 0) { + if (view === 0) { return ( <div> <Slider {...settings}> { - this.props.images.map(image => ( + this.props.images.map((image) => ( <div key={image}> <img src={image.image} width={imageWidth} alt='' /> </div> @@ -100,51 +101,54 @@ class Home extends Component { /> <Container> { - this.props.user.id ? - <Button - as={Link} - to='/profile' - primary - size='huge' - style={{ - fontSize: '2vw', - marginTop: '1vw', - marginBottom: '1vw', - fontWeight: 'bold', - letterSpacing: '0.13vw' - }} - > + this.props.user.id + ? ( + <Button + as={Link} + to='/profile' + primary + size='huge' + style={{ + fontSize: '2vw', + marginTop: '1vw', + marginBottom: '1vw', + fontWeight: 'bold', + letterSpacing: '0.13vw', + }} + > Jelentkezés - <Icon name='right arrow' /> - </Button> - : - <Button - href='/api/v1/login/authsch/' - primary - size='huge' - style={{ - fontSize: '2vw', - marginTop: '1vw', - marginBottom: '1vw', - fontWeight: 'bold', - letterSpacing: '0.13vw' - }} - > + <Icon name='right arrow' /> + </Button> + ) + : ( + <Button + href='/api/v1/login/authsch/' + primary + size='huge' + style={{ + fontSize: '2vw', + marginTop: '1vw', + marginBottom: '1vw', + fontWeight: 'bold', + letterSpacing: '0.13vw', + }} + > Bejelentkezés - <Icon name='right arrow' /> - </Button> + <Icon name='right arrow' /> + </Button> + ) } </Container> </Segment> </div> </div> - ) - } else if (view === 1) { + ); + } if (view === 1) { return ( <div> <Slider {...settings}> { - this.props.images.map(image => ( + this.props.images.map((image) => ( <div key={image}> <img src={image.image} width={imageWidth} alt='' /> </div> @@ -204,50 +208,54 @@ class Home extends Component { /> <Container> { - this.props.user.id ? - <Button - as={Link} - to='/profile' - primary - size='massive' - style={{ - fontSize: '4vw', - marginTop: '1.5vw', - marginBottom: '1vw', - fontWeight: 'bold', - letterSpacing: '0.15vw' - }} - > + this.props.user.id + ? ( + <Button + as={Link} + to='/profile' + primary + size='massive' + style={{ + fontSize: '4vw', + marginTop: '1.5vw', + marginBottom: '1vw', + fontWeight: 'bold', + letterSpacing: '0.15vw', + }} + > Jelentkezés - <Icon name='right arrow' /> - </Button> - : - <Button - href='/api/v1/login/authsch/' - primary - size='massive' - style={{ - fontSize: '4vw', - marginTop: '1vw', - marginBottom: '1vw', - fontWeight: 'bold', - letterSpacing: '0.15vw' - }} - > + <Icon name='right arrow' /> + </Button> + ) + : ( + <Button + href='/api/v1/login/authsch/' + primary + size='massive' + style={{ + fontSize: '4vw', + marginTop: '1vw', + marginBottom: '1vw', + fontWeight: 'bold', + letterSpacing: '0.15vw', + }} + > Bejelentkezés - <Icon name='right arrow' /> - </Button> + <Icon name='right arrow' /> + </Button> + ) } </Container> </Segment> </div> </div> - ) + ); } } - renderText(){ - const kszk_age = new Date().getFullYear() - 1976 + // eslint-disable-next-line class-methods-use-this + renderText() { + const kszk_age = new Date().getFullYear() - 1976; return ( <Segment style={{ padding: '8em 0em', fontFamily: 'Arial' }} vertical> <Container text> @@ -257,14 +265,19 @@ class Home extends Component { <p style={{ fontSize: '1.33em', fontFamily: 'Arial' }}> A Kollégiumi SzámÃtástechnikai Kör az Egyetem legrégebben működÅ‘ és legnagyobb aktÃv, informatikával foglalkozó öntevékeny - csoportosulása, idén ünnepeljük {kszk_age}. születésnapunkat. A patinás + csoportosulása, idén ünnepeljük + {' '} + {kszk_age} +. születésnapunkat. A patinás név mögött vidám hangulatú, alkotó kedvű csapat rejlik, mely a Kar jó szakmai képességű, számÃtástechnika iránt kiemelten érdeklÅ‘dÅ‘ tagjaiból verbuválódott, és bÅ‘vül évente új tehetségekkel, lelkes informatikusokkal, villamosmérnökökkel. </p> <Button as={Link} size='large' to='/groups'> - Ismerd meg a köreinket! <Icon name='right arrow' /> + Ismerd meg a köreinket! + {' '} + <Icon name='right arrow' /> </Button> <Divider as='h4' className='header' style={{ margin: '3em 0em' }} /> <Header as='h3' style={{ fontSize: '2em', fontFamily: 'Arial' }}> @@ -285,13 +298,13 @@ class Home extends Component { Képzésünk </Header> <p style={{ fontSize: '1.33em', fontFamily: 'Arial' }}> - Kilenc alkalmas képzésünk végén Te is igazi KSZK-ssá válhatsz, - hiszen rengeteg szakmai tudást igyekszünk átadni nektek. - A képzésalkalmak rendkÃvül jó hangulatban telnek, és a szociális - irányultságú foglalkozások alatt egy nagyon jó csapat kovácsolódik - az érdeklÅ‘dÅ‘kbÅ‘l. Az elsÅ‘ képzés idÅ‘pontja február 16. vasárnap 18:00, - ettÅ‘l kezdve pedig minden héten találkozunk ugyanabban az idÅ‘pontban. - A képzés ideje alatt április 17-19 között rendezünk tábort. + Kilenc alkalmas képzésünk végén Te is igazi KSZK-ssá válhatsz, + hiszen rengeteg szakmai tudást igyekszünk átadni nektek. + A képzésalkalmak rendkÃvül jó hangulatban telnek, és a szociális + irányultságú foglalkozások alatt egy nagyon jó csapat kovácsolódik + az érdeklÅ‘dÅ‘kbÅ‘l. Az elsÅ‘ képzés idÅ‘pontja február 16. vasárnap 18:00, + ettÅ‘l kezdve pedig minden héten találkozunk ugyanabban az idÅ‘pontban. + A képzés ideje alatt április 17-19 között rendezünk tábort. Az alkalmakon és a táboron kötelezÅ‘ a részvétel. </p> <Divider as='h4' className='header' style={{ margin: '3em 0em' }} /> @@ -314,20 +327,20 @@ class Home extends Component { </Segment> </Container> </Segment> - ) + ); } render() { return ( <div> - <Responsive minWidth={600} > + <Responsive minWidth={600}> <div className='car-image-kszk'> - <div></div> + <div /> { this.renderSlider(0, '120%') } </div> { this.renderText() } </Responsive> - <Responsive maxWidth={600} > + <Responsive maxWidth={600}> <div className='car-image-kszk'> { this.renderSlider(1, '200%') } </div> @@ -339,7 +352,7 @@ class Home extends Component { } const mapStateToProps = ({ user, images }) => ({ - user, images + user, images, }); export default connect(mapStateToProps, { getImages })(Home); diff --git a/src/components/pages/Homework.js b/src/components/pages/Homework.js index 7108ae3..e3de25e 100644 --- a/src/components/pages/Homework.js +++ b/src/components/pages/Homework.js @@ -1,3 +1,4 @@ +/* eslint-disable no-nested-ternary */ import React, { Component } from 'react'; import { Container, @@ -71,16 +72,16 @@ export const customMessage = (header, text, marginBottom, warning) => ( class Homework extends Component { componentDidMount() { - this.props.getTasks() - this.props.getProfiles() - this.props.getSolutions() - this.props.getDocuments() + this.props.getTasks(); + this.props.getProfiles(); + this.props.getSolutions(); + this.props.getDocuments(); } // Returns a table style for the given task getTaskDisplayStyle(task) { const taskSolution = this.props.homeworks.solutions - .filter(solution => solution.task === task.id) + .filter((solution) => solution.task === task.id); if (taskSolution.length === 0) { if (moment().isBefore(task.deadline)) { @@ -106,14 +107,13 @@ class Homework extends Component { renderTaskList(active, staff) { const { user, homeworks } = this.props; const profileSolutions = homeworks.solutions - .filter(solution => solution.created_by === user.id); - + .filter((solution) => solution.created_by === user.id); // Normal user if (!staff) { return homeworks.tasks - .filter(task => moment().isBefore(task.deadline) === active) - .map(task => ( + .filter((task) => moment().isBefore(task.deadline) === active) + .map((task) => ( // Style <Table.Row key={task.id} @@ -144,42 +144,52 @@ class Homework extends Component { <Table.Cell> <Label color={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive ? - 'green' - : moment().isAfter(task.deadline) ? 'red' - : displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative ? 'red': null}> - {task.bits} bit + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive + ? 'green' + : moment().isAfter(task.deadline) ? 'red' + : displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative ? 'red' : null +} + > + {task.bits} + {' '} +bit </Label> </Table.Cell> {/* Status (JavÃtásra vár, ...) */} <Table.Cell> - <Icon name={displayTypes[this.getTaskDisplayStyle(task)].icon} />{' '} + <Icon name={displayTypes[this.getTaskDisplayStyle(task)].icon} /> + {' '} {displayTypes[this.getTaskDisplayStyle(task)].text} - {profileSolutions.filter(solution => solution.task === task.id) - && profileSolutions.filter(solution => solution.task === task.id).slice(-1)[0] - && profileSolutions.filter(solution => solution.task === task.id).slice(-1)[0].note - ? + {profileSolutions.filter((solution) => solution.task === task.id) + && profileSolutions.filter((solution) => solution.task === task.id) + .slice(-1)[0] + && profileSolutions.filter((solution) => solution.task === task.id) + .slice(-1)[0].note + ? ( <div> <InfoModal - button={ - <button id='tasknote'> - (Megjegyzés <Icon name='external' />) + button={( + <button type='button' id='tasknote'> + (Megjegyzés + {' '} + <Icon name='external' /> +) </button> - } + )} title='Megjegyzés a feladathoz' - content={profileSolutions.filter(solution => - solution.task === task.id).slice(-1)[0].note} + content={profileSolutions + .filter((solution) => solution.task === task.id).slice(-1)[0].note} onAccept={() => {}} /> </div> - : '' - } + ) + : ''} </Table.Cell> </Table.Row> )); } - // Staff + // Staff const deleteButton = ( <Button @@ -187,13 +197,15 @@ class Homework extends Component { style={{ marginRight: '2em' }} color='red' > - <Icon name='x' /> Törlés + <Icon name='x' /> + {' '} +Törlés </Button> ); return this.props.homeworks.tasks - .filter(task => moment().isBefore(task.deadline) === active) - .map(task => ( + .filter((task) => moment().isBefore(task.deadline) === active) + .map((task) => ( <Table.Row key={task.id} warning={ @@ -220,10 +232,12 @@ class Homework extends Component { </Table.Cell> {/* Bits */} <Table.Cell> - <Label color={null}> - {task.bits} bit - </Label> - </Table.Cell> + <Label color={null}> + {task.bits} + {' '} +bit + </Label> + </Table.Cell> {/* Admin buttons */} <Table.Cell> <EditTaskForm onClick={() => this.props.setSelectedTask(task)} /> @@ -309,8 +323,8 @@ class Homework extends Component { headerText = 'AktÃv feladatok kijavÃtása, módosÃtása vagy törlése'; } - if (this.props.homeworks.tasks.filter(task => - moment().isBefore(task.deadline) === active).length === 0 + if (this.props.homeworks.tasks.filter((task) => moment() + .isBefore(task.deadline) === active).length === 0 ) { noTask = true; } @@ -335,39 +349,42 @@ class Homework extends Component { headerText } style={{ - fontSize: '2em', - fontWeight: 'normal', - marginBottom: 0, - marginTop: '0.5em', - }} + fontSize: '2em', + fontWeight: 'normal', + marginBottom: 0, + marginTop: '0.5em', + }} /> - {noTask ? - customMessage(noTaskHeaderText, noTaskText, marginBottom, false) - : - <div> - {this.renderHomeworksTable(active, staff)} - </div> - } - {!active && !staff ? + {noTask + ? customMessage(noTaskHeaderText, noTaskText, marginBottom, false) + : ( + <div> + {this.renderHomeworksTable(active, staff)} + </div> + )} + {!active && !staff + ? ( <Header as='h3' - content={ - <div > + content={( + <div> Jelenlegi bitjeid száma: <Label color='green' size='large'> - {this.props.user.bits} bit + {this.props.user.bits} + {' '} +bit </Label> </div> - } + )} style={{ - fontWeight: 'normal', - marginTop: '0.5em', - marginBottom: '1em' - }} + fontWeight: 'normal', + marginTop: '0.5em', + marginBottom: '1em', + }} textAlign='right' /> - : null - } + ) + : null} </Container> </Segment> ); @@ -378,24 +395,26 @@ class Homework extends Component { if (user.role === 'Student') { return ( - <div style={{paddingBottom: '2em'}}> + <div style={{ paddingBottom: '2em' }}> {this.renderHomeworks(true, false)} {this.renderHomeworks(false, false)} </div> ); - } else if (user.role === 'Staff') { + } if (user.role === 'Staff') { return ( - <div style={{paddingBottom: '2em'}}> + <div style={{ paddingBottom: '2em' }}> <Segment style={{ padding: '0 0 2em 0' }} vertical basic> <Container> - <Header dividing as='h1' + <Header + dividing + as='h1' content='Új házi feladat létrehozása' style={{ - fontSize: '2em', - fontWeight: 'normal', - marginBottom: '0.5em', - marginTop: '0.5em', - }} + fontSize: '2em', + fontWeight: 'normal', + marginBottom: '0.5em', + marginTop: '0.5em', + }} /> <Button.Group> <AddTaskForm /> diff --git a/src/components/pages/LeaderBoard.js b/src/components/pages/LeaderBoard.js index 25f917b..9ae0762 100644 --- a/src/components/pages/LeaderBoard.js +++ b/src/components/pages/LeaderBoard.js @@ -10,17 +10,15 @@ class LeaderBoard extends Component { // Every event rendered renderTraineeBits() { - return this.props.trainees.sort( (a,b) => { - return (Number(b.homework_bits) + b.events_visited) - - (Number(a.homework_bits) + a.events_visited) - }).map((trainee) => { - return ( - trainee.role === 'Student' ? + return this.props.trainees.sort((a, b) => (Number(b.homework_bits) + b.events_visited) + - (Number(a.homework_bits) + a.events_visited)).map((trainee) => ( + trainee.role === 'Student' + ? ( <Table.Row key={trainee.nick}> <Table.Cell textAlign='center'> - {trainee.full_name} + {trainee.full_name} </Table.Cell> - <Table.Cell textAlign='center' > + <Table.Cell textAlign='center'> {trainee.events_visited} </Table.Cell> <Table.Cell textAlign='center'> @@ -30,14 +28,14 @@ class LeaderBoard extends Component { {Number(trainee.homework_bits) + trainee.events_visited} </Table.Cell> </Table.Row> + ) : null - ) - }) + )); } render() { return ( - <Container textAlign='center' style={{overflowX: 'scroll'}}> + <Container textAlign='center' style={{ overflowX: 'scroll' }}> <Table color='blue' unstackable celled selectable compact> <Table.Header> <Table.Row> @@ -56,15 +54,15 @@ class LeaderBoard extends Component { </Table.Row> </Table.Header> <Table.Body> - {this.props.trainees ? - this.renderTraineeBits() - : - <Table.Row> - <Table.Cell> + {this.props.trainees + ? this.renderTraineeBits() + : ( + <Table.Row> + <Table.Cell> Nincsenek képzÅ‘dÅ‘k - </Table.Cell> - </Table.Row> - } + </Table.Cell> + </Table.Row> + )} </Table.Body> </Table> </Container> diff --git a/src/components/pages/Mentors.js b/src/components/pages/Mentors.js index 31fa8b4..bc17ae4 100644 --- a/src/components/pages/Mentors.js +++ b/src/components/pages/Mentors.js @@ -1,7 +1,9 @@ -import React, { Component } from 'react' - import { Container, Segment, Item, Header, Card, Label, Icon, Responsive, Image } from 'semantic-ui-react' -import { connect } from 'react-redux' -import { getMentors } from '../../actions/mentors' +import React, { Component } from 'react'; +import { + Container, Segment, Item, Header, Card, Label, Icon, Responsive, Image, +} from 'semantic-ui-react'; +import { connect } from 'react-redux'; +import { getMentors } from '../../actions/mentors'; class Mentors extends Component { UNSAFE_componentWillMount() { @@ -9,37 +11,38 @@ class Mentors extends Component { } renderMentorsNormal() { - return this.props.mentors.map( (item, index) => ( - <Card style={{maxWidth: '100%', minWidth: '100%'}}> - <Card.Content style={{padding: '0'}}> - <Item.Group> - <Item> - {index%2 === 0 ? - <Item.Image size='medium' src={item.image} /> : null - } - <Item.Content style={{padding: '1rem'}}> - <Item.Header>{item.name}</Item.Header> - <Item.Description> - <p>{item.text}</p> - </Item.Description> - <Item.Extra> - <Label><Icon name='mail'></Icon>{item.email}</Label> - </Item.Extra> - </Item.Content> - {index%2 === 1 ? - <Item.Image size='medium' src={item.image} /> : null - } - </Item> - </Item.Group> + return this.props.mentors.map((item, index) => ( + <Card style={{ maxWidth: '100%', minWidth: '100%' }}> + <Card.Content style={{ padding: '0' }}> + <Item.Group> + <Item> + {index % 2 === 0 + ? <Item.Image size='medium' src={item.image} /> : null} + <Item.Content style={{ padding: '1rem' }}> + <Item.Header>{item.name}</Item.Header> + <Item.Description> + <p>{item.text}</p> + </Item.Description> + <Item.Extra> + <Label> + <Icon name='mail' /> + {item.email} + </Label> + </Item.Extra> + </Item.Content> + {index % 2 === 1 + ? <Item.Image size='medium' src={item.image} /> : null} + </Item> + </Item.Group> </Card.Content> </Card> )); } renderMentorsMobile() { - return this.props.mentors.map( (item, index) => ( + return this.props.mentors.map((item) => ( <Card key={item.id}> - <Image src={item.image} wrapped ui={false}/> + <Image src={item.image} wrapped ui={false} /> <Card.Content> <Card.Header>{item.name}</Card.Header> <Card.Description> @@ -47,7 +50,10 @@ class Mentors extends Component { </Card.Description> </Card.Content> <Card.Content extra> - <Label><Icon name='mail'></Icon>{item.email}</Label> + <Label> + <Icon name='mail' /> + {item.email} + </Label> </Card.Content> </Card> )); @@ -73,13 +79,13 @@ class Mentors extends Component { </Segment> <Responsive minWidth={768}> - <Container style={{paddingTop: '2em', paddingBottom: '5em'}}> + <Container style={{ paddingTop: '2em', paddingBottom: '5em' }}> {this.renderMentorsNormal()} </Container> </Responsive> <Responsive minWidth={551} maxWidth={767}> - <Container style={{paddingTop: '2em', paddingBottom: '5em'}}> + <Container style={{ paddingTop: '2em', paddingBottom: '5em' }}> <Card.Group centered itemsPerRow={2}> {this.renderMentorsMobile()} </Card.Group> @@ -87,7 +93,7 @@ class Mentors extends Component { </Responsive> <Responsive maxWidth={550}> - <Container style={{paddingTop: '2em', paddingBottom: '5em'}}> + <Container style={{ paddingTop: '2em', paddingBottom: '5em' }}> <Card.Group centered itemsPerRow={1}> {this.renderMentorsMobile()} </Card.Group> diff --git a/src/components/pages/News.js b/src/components/pages/News.js index 6faf5d1..0283887 100644 --- a/src/components/pages/News.js +++ b/src/components/pages/News.js @@ -1,12 +1,14 @@ import React, { Component } from 'react'; -import { Container, Segment, Item, Button, Grid } from 'semantic-ui-react'; +import { + Container, Segment, Item, Button, Grid, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import moment from 'moment'; -import AddNewsForm from '../forms/AddNewsForm' -import EditNewsForm from '../forms/EditNewsForm' +import AddNewsForm from '../forms/AddNewsForm'; +import EditNewsForm from '../forms/EditNewsForm'; -import ConfirmModal from '../forms/ConfirmModal' +import ConfirmModal from '../forms/ConfirmModal'; import { getNews, deleteNews, setSelectedNews } from '../../actions/news'; @@ -16,8 +18,9 @@ class News extends Component { UNSAFE_componentWillMount() { this.props.getNews(); } + renderNews() { - return this.props.news.map(item => ( + return this.props.news.map((item) => ( <Item key={item.id}> <Item.Content> <Container text textAlign='left'> @@ -31,53 +34,57 @@ class News extends Component { > {item.title} </Grid.Column> - { this.props.user.role === 'Staff' ? - <Grid.Column floated='right' width={4}> - <EditNewsForm - onClick={() => this.props.setSelectedNews(item)} - /> - <ConfirmModal - text={`törölni akarod a következÅ‘ hÃrt: ${item.title}`} - button={ - <Button - compact - color='red' - size='mini' - > + { this.props.user.role === 'Staff' + ? ( + <Grid.Column floated='right' width={4}> + <EditNewsForm + onClick={() => this.props.setSelectedNews(item)} + /> + <ConfirmModal + text={`törölni akarod a következÅ‘ hÃrt: ${item.title}`} + button={( + <Button + compact + color='red' + size='mini' + > Törlés - </Button> - } - onAccept={() => this.props.deleteNews(item)} - /> - </Grid.Column> + </Button> + )} + onAccept={() => this.props.deleteNews(item)} + /> + </Grid.Column> + ) : null } </Grid> </Item.Header> - <Item.Meta style={{ fontSize: '0.75em', fontStyle: 'italic' }}>Közzétéve: {moment(item.created_at).format('LLLL')}</Item.Meta> + <Item.Meta style={{ fontSize: '0.75em', fontStyle: 'italic' }}> +Közzétéve: + {moment(item.created_at).format('LLLL')} + </Item.Meta> <Item.Description className='news-text' style={{ fontSize: '1em' }}> {this.renderMultiLine(item.text)} </Item.Description> - </Container> + </Container> </Item.Content> </Item> )); } - renderMultiLine(text) { + renderMultiLine = (text) => { const strings = text.split('\n'); - return strings.map(string => <p key={Math.random()}>{string}</p>); + return strings.map((string) => <p key={Math.random()}>{string}</p>); } render() { return ( - <div style={{paddingTop: '1em', paddingBottom: '5em'}}> + <div style={{ paddingTop: '1em', paddingBottom: '5em' }}> <Segment vertical> {/* { this.props.user.is_superuser ? <AddNewsForm /> : ''} */} <Container text textAlign='center'> - {this.props.user.role === 'Staff' ? - <AddNewsForm /> - : - null} + {this.props.user.role === 'Staff' + ? <AddNewsForm /> + : null} <Item.Group divided> {this.renderNews()} </Item.Group> @@ -91,4 +98,4 @@ class News extends Component { const mapStateToProps = ({ news, user }) => ({ news, user }); -export default connect(mapStateToProps, { getNews, deleteNews, setSelectedNews })(News); \ No newline at end of file +export default connect(mapStateToProps, { getNews, deleteNews, setSelectedNews })(News); diff --git a/src/components/pages/NotFound.js b/src/components/pages/NotFound.js index be13943..b8432a9 100644 --- a/src/components/pages/NotFound.js +++ b/src/components/pages/NotFound.js @@ -1,5 +1,7 @@ import React, { Component } from 'react'; -import { Button, Container, Header, Icon, Segment } from 'semantic-ui-react'; +import { + Button, Container, Header, Icon, Segment, +} from 'semantic-ui-react'; export default class NotFound extends Component { render() { diff --git a/src/components/pages/Presence.js b/src/components/pages/Presence.js index 02763a7..1f67b2d 100644 --- a/src/components/pages/Presence.js +++ b/src/components/pages/Presence.js @@ -29,34 +29,32 @@ class Presence extends Component { // Every event rendered renderTraineesWithEvents() { - return this.props.trainees.map((trainee) => - { return ( - trainee.role === 'Student' ? - <Table.Row key={Math.random()}> - <Table.Cell textAlign='center'> - {trainee.full_name} - </Table.Cell> - {this.renderVisitedStatus(trainee)} - </Table.Row> - : null - ); - }); + return this.props.trainees.map((trainee) => ( + trainee.role === 'Student' + ? ( + <Table.Row key={Math.random()}> + <Table.Cell textAlign='center'> + {trainee.full_name} + </Table.Cell> + {this.renderVisitedStatus(trainee)} + </Table.Row> + ) + : null + )); } // Column for each event renderTableHeaderEvents() { - return (this.props.events.map(event => { - return ( + return (this.props.events.map((event) => ( <Table.HeaderCell textAlign='center' key={event.id}> {event.name} </Table.HeaderCell> - ) - })); + ))); } render() { return ( - <Container textAlign='center' style={{overflowX: 'scroll'}}> + <Container textAlign='center' style={{ overflowX: 'scroll' }}> <Table color='blue' unstackable celled selectable compact> <Table.Header> <Table.Row> @@ -68,15 +66,15 @@ class Presence extends Component { </Table.Header> <Table.Body> - {this.props.trainees ? - this.renderTraineesWithEvents() - : - <Table.Row> - <Table.Cell> + {this.props.trainees + ? this.renderTraineesWithEvents() + : ( + <Table.Row> + <Table.Cell> Nincsenek képzÅ‘dÅ‘k - </Table.Cell> - </Table.Row> - } + </Table.Cell> + </Table.Row> + )} </Table.Body> </Table> </Container> @@ -84,6 +82,8 @@ class Presence extends Component { } } -const mapStateToProps = ({ trainees: { trainees }, events: { events }, user }) => ({ trainees, events, user }); +const mapStateToProps = ( + { trainees: { trainees }, events: { events }, user }, +) => ({ trainees, events, user }); export default connect(mapStateToProps, { getTrainees, getStaffEvents })(Presence); diff --git a/src/components/pages/Profile.js b/src/components/pages/Profile.js index 3bd0b07..d987aa8 100644 --- a/src/components/pages/Profile.js +++ b/src/components/pages/Profile.js @@ -1,9 +1,11 @@ import React, { Component } from 'react'; -import { Container, Form, Dropdown, Divider, Segment } from 'semantic-ui-react'; +import { + Container, Form, Dropdown, Divider, Segment, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import { textChange, submitRegistration, groupChange } from '../../actions'; -import { getDeadline } from '../../actions/auth' -import HiddenForm from '../forms/HiddenForm' +import { getDeadline } from '../../actions/auth'; +import HiddenForm from '../forms/HiddenForm'; const options = [ { key: 'DT', text: 'DevTeam', value: 'DT' }, @@ -15,7 +17,7 @@ const options = [ class Profile extends Component { UNSAFE_componentWillMount() { - this.props.getDeadline() + this.props.getDeadline(); if (!this.props.id) { this.props.history.push('/home'); } @@ -23,95 +25,109 @@ class Profile extends Component { render() { const { - nick, groups, motivationAbout, motivationProfession, - motivationExercise, signed, id, deadline, messageBefore, - messageAfter + nick, groups, motivationAbout, motivationProfession, + motivationExercise, signed, id, deadline, messageBefore, + messageAfter, } = this.props; - const endDate = new Date(deadline) - let canEdit = Date.now()<endDate + const endDate = new Date(deadline); + const canEdit = Date.now() < endDate; return ( <Container style={{ marginTop: '1em', }} > - {canEdit ? - <Segment inverted color='red' tertiary> - <p style={{ fontSize: '1.3em' }} dangerouslySetInnerHTML={{__html: messageBefore}} /> - </Segment> - : - <Segment inverted color='red' tertiary> - <p style={{ fontSize: '1.3em' }} dangerouslySetInnerHTML={{__html: messageAfter}} /> - </Segment>} + {canEdit + ? ( + <Segment inverted color='red' tertiary> + <p style={{ fontSize: '1.3em' }} dangerouslySetInnerHTML={{ __html: messageBefore }} /> + </Segment> + ) + : ( + <Segment inverted color='red' tertiary> + <p style={{ fontSize: '1.3em' }} dangerouslySetInnerHTML={{ __html: messageAfter }} /> + </Segment> + )} <Form> - {canEdit ? - <Form.Input - fluid - name='nick' - label='Becenév' - onChange={e => this.props.textChange(e)} - placeholder='Becenév' - value={nick} - /> : - <HiddenForm fontWeight='bold' label='Becenév' value={nick} /> - } + {canEdit + ? ( + <Form.Input + fluid + name='nick' + label='Becenév' + onChange={(e) => this.props.textChange(e)} + placeholder='Becenév' + value={nick} + /> + ) + : <HiddenForm fontWeight='bold' label='Becenév' value={nick} />} <Divider horizontal>Motiváció</Divider> - {canEdit ? - <Form.TextArea - rows={10} - name='motivationAbout' - label='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?' - onChange={e => this.props.textChange(e)} - placeholder='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?' - value={motivationAbout} - /> : - <HiddenForm - fontWeight='bold' - label='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?' - value={motivationAbout} /> - } + {canEdit + ? ( + <Form.TextArea + rows={10} + name='motivationAbout' + label='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?' + onChange={(e) => this.props.textChange(e)} + placeholder='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?' + value={motivationAbout} + /> + ) + : ( + <HiddenForm + fontWeight='bold' + label='Mesélj nekünk egy kicsit magadról. Milyen szakmai vagy más eredményeket értél el, amikre büszke vagy?' + value={motivationAbout} + /> + )} <Divider horizontal /> - {canEdit ? - <Form.TextArea - rows={10} - label='Mit vársz el a képzéstÅ‘l, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?' - name='motivationProfession' - onChange={e => this.props.textChange(e)} - placeholder='Mit vársz el a képzéstÅ‘l, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?' - value={motivationProfession} - /> : - <HiddenForm - fontWeight='bold' - label='Mit vársz el a képzéstÅ‘l, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?' - value={motivationProfession} /> - } + {canEdit + ? ( + <Form.TextArea + rows={10} + label='Mit vársz el a képzéstÅ‘l, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?' + name='motivationProfession' + onChange={(e) => this.props.textChange(e)} + placeholder='Mit vársz el a képzéstÅ‘l, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?' + value={motivationProfession} + /> + ) + : ( + <HiddenForm + fontWeight='bold' + label='Mit vársz el a képzéstÅ‘l, miért szeretnél rá jelentkezni, szerinted mire tudod majd használni az itt megszerzett tudást? Mit szeretnél elérni a szakmádban?' + value={motivationProfession} + /> + )} <Divider horizontal /> - {canEdit ? - <Form.TextArea - rows={10} - name='motivationExercise' - onChange={e => this.props.textChange(e)} - placeholder='' - label={ - <div> - <b>Alább találsz néhány elgondolkodtató kérdést, megoldandó feladatot. + {canEdit + ? ( + <Form.TextArea + rows={10} + name='motivationExercise' + onChange={(e) => this.props.textChange(e)} + placeholder='' + label={( + <div> + <b> +Alább találsz néhány elgondolkodtató kérdést, megoldandó feladatot. A kérdések és feladatok elkészÃtése opcionális, nem titkolt célunk ezzel a lelkesedés felmérése. A válaszokat a kérdések alatti szövegdobozba várjuk. - </b> - <ul> - <li> + </b> + <ul> + <li> Szeretnéd kedvenc tantárgyad vik.wiki oldalát elérni, de szomorúan látod, hogy az oldal nem jön be. A Steam pedig hibátlanul megy a háttérben és az emailek is megérkeznek... Szobatársadnak pont megvan a vik.wiki szerverének IP-cÃme. Csodálkozva látod, hogy a böngészÅ‘ cÃmsorába Ãrva eléred a kiszolgáló webszervert. Mi lehet a baj? - </li> - <br /> - <li> + </li> + <br /> + <li> Két elÅ‘adás közti szünetben úgy döntesz, hogy laptopoddal az index.hu tech cikkeit fogod görgetni. Ãm az oldal nem válaszol, a hiba okát megpróbálod kiderÃteni. @@ -119,42 +135,60 @@ class Profile extends Component { sze.hu, 444.hu, corvinus.hu, startlap.hu. Ugyanakkor a Facebook, a Gmail, a YouTube, de még az egyetemi oldalak többsége is működik. Szerinted mi lehet a hiba oka? - </li> - <br /> - <li> - Találsz egy értelmetlen szöveget egy honlapon (például: <a href='https://ujonc.kszk.bme.hu/zebra.html'>https://ujonc.kszk.bme.hu/zebra.html</a>), de feltűnik, hogy két egyenlÅ‘ségjellel fejezÅ‘dik be. Nyomozz, s a végeredményt (amit találtál) Ãrd ide! - </li> - <br /> - <li> - A <b>ujonc.kszk.bme.hu</b> cÃmen elérhetÅ‘ gépen - fut egy szolgáltatás az alapértelmezett <b>5432</b> porton + </li> + <br /> + <li> + Találsz egy értelmetlen szöveget egy honlapon (például: + {' '} + <a href='https://ujonc.kszk.bme.hu/zebra.html'> + https://ujonc.kszk.bme.hu/zebra.html + </a> + ), de feltűnik, hogy két egyenlÅ‘ségjellel fejezÅ‘dik be. + Nyomozz, s a végeredményt (amit találtál) Ãrd ide! + </li> + <br /> + <li> + A + {' '} + <b>ujonc.kszk.bme.hu</b> + {' '} + cÃmen elérhetÅ‘ gépen + fut egy szolgáltatás az alapértelmezett + {' '} + <b>5432</b> + {' '} + porton (használd az elÅ‘zÅ‘ feladatban kapott adatokat). Belépés után keresd meg a feladat megoldását! - </li> - </ul> - </div> - } - value={motivationExercise} - /> : - <HiddenForm - fontWeight='normal' - label={ - <div> - <b>Alább találsz néhány elgondolkodtató kérdést, megoldandó feladatot. + </li> + </ul> + </div> + )} + value={motivationExercise} + /> + ) + : ( + <HiddenForm + fontWeight='normal' + label={( + <div> + <b> + Alább találsz néhány elgondolkodtató kérdést, megoldandó feladatot. A kérdések és feladatok elkészÃtése opcionális, nem titkolt célunk ezzel a lelkesedés felmérése. A válaszokat a kérdések alatti szövegdobozba várjuk. - </b> - <ul> - <li> + </b> + <ul> + <li> Szeretnéd kedvenc tantárgyad vik.wiki oldalát elérni, de szomorúan látod, hogy az oldal nem jön be. A Steam pedig hibátlanul megy a háttérben és az emailek is megérkeznek... Szobatársadnak pont megvan a vik.wiki szerverének IP-cÃme. - Csodálkozva látod, hogy a böngészÅ‘ cÃmsorába Ãrva eléred a kiszolgáló webszervert. + Csodálkozva látod, + hogy a böngészÅ‘ cÃmsorába Ãrva eléred a kiszolgáló webszervert. Mi lehet a baj? - </li> - <li> + </li> + <li> Két elÅ‘adás közti szünetben úgy döntesz, hogy laptopoddal az index.hu tech cikkeit fogod görgetni. Ãm az oldal nem válaszol, a hiba okát megpróbálod kiderÃteni. @@ -162,21 +196,34 @@ class Profile extends Component { sze.hu, 444.hu, corvinus.hu, startlap.hu. Ugyanakkor a Facebook, a Gmail, a YouTube, de még az egyetemi oldalak többsége is működik. Szerinted mi lehet a hiba oka? - </li> - <li> - Találsz egy értelmetlen szöveget egy honlapon (például: <a href='https://ujonc.kszk.bme.hu/zebra.html'>https://ujonc.kszk.bme.hu/zebra.html</a>), de feltűnik, hogy két egyenlÅ‘ségjellel fejezÅ‘dik be. Nyomozz, s a végeredményt (amit találtál) Ãrd ide! - </li> - <li> - A <b>ujonc.kszk.bme.hu</b> cÃmen elérhetÅ‘ gépen - fut egy szolgáltatás az alapértelmezett <b>5432</b> porton + </li> + <li> + Találsz egy értelmetlen szöveget egy honlapon (például: + {' '} + <a href='https://ujonc.kszk.bme.hu/zebra.html'>https://ujonc.kszk.bme.hu/zebra.html</a> + ), de feltűnik, hogy két egyenlÅ‘ségjellel fejezÅ‘dik be. + Nyomozz, s a végeredményt (amit találtál) Ãrd ide! + </li> + <li> + A + {' '} + <b>ujonc.kszk.bme.hu</b> + {' '} + cÃmen elérhetÅ‘ gépen + fut egy szolgáltatás az alapértelmezett + {' '} + <b>5432</b> + {' '} + porton (használd az elÅ‘zÅ‘ feladatban kapott adatokat). Belépés után keresd meg a feladat megoldását! - </li> - </ul> - </div> - } - value={motivationExercise} /> - } + </li> + </ul> + </div> + )} + value={motivationExercise} + /> + )} <Divider horizontal>ÉrdekelÅ‘dés</Divider> <Dropdown @@ -193,24 +240,33 @@ class Profile extends Component { <Form.Checkbox name='signed' label='Szeretnék a képzés során emaileket kapni és jelentkezni a KSZKépzésre' - onChange={(_, v) => - this.props.textChange({ target: { name: v.name, value: v.checked } }) - } + onChange={(_, v) => this.props.textChange({ + target: { name: v.name, value: v.checked }, + })} checked={signed} readOnly={!canEdit} - style={ !canEdit ? { marginBottom: '5em' } : null} + style={!canEdit ? { marginBottom: '5em' } : null} /> - {canEdit ? - <Form.Button - primary - style={{ marginBottom: '5em' }} disabled={!signed} - onClick={() => this.props.submitRegistration({ - nick, motivationAbout, motivationProfession, motivationExercise, signed, groups, id, - })} - > + {canEdit + ? ( + <Form.Button + primary + style={{ marginBottom: '5em' }} + disabled={!signed} + onClick={() => this.props.submitRegistration({ + nick, + motivationAbout, + motivationProfession, + motivationExercise, + signed, + groups, + id, + })} + > Mentés - </Form.Button> - : '' } + </Form.Button> + ) + : '' } </Form> </Container> ); @@ -219,10 +275,10 @@ class Profile extends Component { const mapStateToProps = ({ user: { - nick, groups, motivationAbout, motivationProfession, - motivationExercise, signed, id, deadline, messageBefore, - messageAfter - } + nick, groups, motivationAbout, motivationProfession, + motivationExercise, signed, id, deadline, messageBefore, + messageAfter, + }, }) => ({ nick, groups, @@ -233,7 +289,9 @@ const mapStateToProps = ({ id, deadline, messageBefore, - messageAfter + messageAfter, }); -export default connect(mapStateToProps, { textChange, submitRegistration, groupChange, getDeadline })(Profile); +export default connect(mapStateToProps, { + textChange, submitRegistration, groupChange, getDeadline, +})(Profile); diff --git a/src/components/pages/Schedule.js b/src/components/pages/Schedule.js index cda5bc0..1ba7d60 100644 --- a/src/components/pages/Schedule.js +++ b/src/components/pages/Schedule.js @@ -1,30 +1,33 @@ import React, { Component } from 'react'; -import { Container, Accordion, Icon, Grid, Header, Segment } from 'semantic-ui-react'; +import { + Container, Accordion, Icon, Grid, Header, Segment, +} from 'semantic-ui-react'; import { connect } from 'react-redux'; import moment from 'moment'; import 'moment/locale/hu'; import { getStudentEvents } from '../../actions/statistics'; class Schedule extends Component { + // eslint-disable-next-line react/state-in-constructor state = { activeIndex: 0 } UNSAFE_componentWillMount() { - this.props.getStudentEvents(); + this.props.getStudentEvents(); } handleClick = (e, titleProps) => { - const { index } = titleProps - const { activeIndex } = this.state - const newIndex = activeIndex === index ? -1 : index + const { index } = titleProps; + const { activeIndex } = this.state; + const newIndex = activeIndex === index ? -1 : index; - this.setState({ activeIndex: newIndex }) + this.setState({ activeIndex: newIndex }); } render() { - const { activeIndex } = this.state + const { activeIndex } = this.state; - const events = this.props.events; - const panels = events.map(event => ( + const { events } = this.props; + const panels = events.map((event) => ( <Accordion key={Math.random()}> <Accordion.Title active={activeIndex === event.id} @@ -32,23 +35,25 @@ class Schedule extends Component { onClick={this.handleClick} > <h2> - <Grid> + <Grid> <Grid.Column floated='left' width={5} textAlign='left'> - <Icon name='calendar alternate outline' color='blue' /> {event.name} + <Icon name='calendar alternate outline' color='blue' /> + {' '} + {event.name} </Grid.Column> <Grid.Column floated='right' width={8} textAlign='right'> {moment(event.date).locale('hu').format('LLLL')} </Grid.Column> </Grid> </h2> - </Accordion.Title> - <Accordion.Content active={activeIndex === event.id} > - <Segment textAlign='left' style={{overflowWrap:'break-word'}}> - {event.description} - </Segment> - </Accordion.Content> - </Accordion> - )); + </Accordion.Title> + <Accordion.Content active={activeIndex === event.id}> + <Segment textAlign='left' style={{ overflowWrap: 'break-word' }}> + {event.description} + </Segment> + </Accordion.Content> + </Accordion> + )); return ( <div> @@ -57,11 +62,11 @@ class Schedule extends Component { as='h1' content='Képzés alkalmak' style={{ - fontSize: '2em', - fontWeight: 'bold', - marginBottom: '0.5em', - marginTop: '0.5em', - }} + fontSize: '2em', + fontWeight: 'bold', + marginBottom: '0.5em', + marginTop: '0.5em', + }} /> <Accordion fluid styled> {panels} @@ -70,11 +75,11 @@ class Schedule extends Component { as='h1' content='Tábor' style={{ - fontSize: '2em', - fontWeight: 'bold', - marginBottom: '0.5em', - marginTop: '1.5em', - }} + fontSize: '2em', + fontWeight: 'bold', + marginBottom: '0.5em', + marginTop: '1.5em', + }} /> </Container> </div> diff --git a/src/components/pages/Statistics.js b/src/components/pages/Statistics.js index 89ec148..57c8fa8 100644 --- a/src/components/pages/Statistics.js +++ b/src/components/pages/Statistics.js @@ -1,25 +1,28 @@ import React, { Component } from 'react'; import { Container, Menu } from 'semantic-ui-react'; -import Events from './Events' -import Presence from './Presence' -import LeaderBoard from './LeaderBoard' +import Events from './Events'; +import Presence from './Presence'; +import LeaderBoard from './LeaderBoard'; export default class Statistics extends Component { + // eslint-disable-next-line react/state-in-constructor state = { activeItem: 'events' } + handleItemClick = (e, { name }) => this.setState({ activeItem: name }) render() { - const { activeItem } = this.state + const { activeItem } = this.state; return ( <div> - <Container - textAlign="center" - style={{paddingBottom: '5em', paddingTop: '1em'}} - > - <Menu tabular + <Container + textAlign='center' + style={{ paddingBottom: '5em', paddingTop: '1em' }} + > + <Menu + tabular attached='top' size='huge' - compact={true} + compact > <Menu.Item name='events' diff --git a/src/containers/TodoContainer.js b/src/containers/TodoContainer.js index 41d6898..37420c7 100644 --- a/src/containers/TodoContainer.js +++ b/src/containers/TodoContainer.js @@ -1,3 +1,6 @@ +/* eslint-disable import/no-unresolved */ +/* eslint-disable import/named */ +/* eslint-disable import/extensions */ import React, { Component } from 'react'; import { connect } from 'react-redux'; // eslint-disable-next-line @@ -12,7 +15,7 @@ class TodoContainer extends Component { return ( <div> { - todos.map(todo => ( + todos.map((todo) => ( <Todo onClick={onTodoClick} key={Math.random()}> {todo.data} </Todo> @@ -31,7 +34,7 @@ const mapStateToProps = (state) => { }; }; -const mapDispatchToProps = dispatch => ({ +const mapDispatchToProps = (dispatch) => ({ onTodoClick: (data) => { dispatch(addTodo(data)); }, diff --git a/src/reducers/AddSolutionReducer.js b/src/reducers/AddSolutionReducer.js index 96da9a5..c95892b 100644 --- a/src/reducers/AddSolutionReducer.js +++ b/src/reducers/AddSolutionReducer.js @@ -1,4 +1,6 @@ -import { WRITE_SOLUTION, WRITE_SOLUTION_FILE, GET_SOLUTIONS, CLEAR_WRITE } from '../actions/types'; +import { + WRITE_SOLUTION, WRITE_SOLUTION_FILE, GET_SOLUTIONS, CLEAR_WRITE, +} from '../actions/types'; const INITIAL_STATE = { task: '', diff --git a/src/reducers/CorrectSolutionReducer.js b/src/reducers/CorrectSolutionReducer.js index c3c010b..3cba471 100644 --- a/src/reducers/CorrectSolutionReducer.js +++ b/src/reducers/CorrectSolutionReducer.js @@ -1,4 +1,6 @@ -import { WRITE_SOLUTION, CHECK, SETCHECKTRUE, CLEAR_WRITE, SELECT_SOLUTION } from '../actions/types'; +import { + WRITE_SOLUTION, CHECK, SETCHECKTRUE, CLEAR_WRITE, SELECT_SOLUTION, +} from '../actions/types'; const INITIAL_STATE = { accepted: false, diff --git a/src/reducers/EditTaskReducer.js b/src/reducers/EditTaskReducer.js index 0dc50e0..4f012f4 100644 --- a/src/reducers/EditTaskReducer.js +++ b/src/reducers/EditTaskReducer.js @@ -1,4 +1,6 @@ -import { SELECT_TASK, WRITE_TASK, WRITE_TASK_DEADLINE, CLEAR_WRITE } from '../actions/types'; +import { + SELECT_TASK, WRITE_TASK, WRITE_TASK_DEADLINE, CLEAR_WRITE, +} from '../actions/types'; const INITIAL_STATE = { }; diff --git a/src/reducers/EventReducer.js b/src/reducers/EventReducer.js index 5dd067d..e3a16d8 100644 --- a/src/reducers/EventReducer.js +++ b/src/reducers/EventReducer.js @@ -21,13 +21,13 @@ export default (state = INITIAL_STATE, action) => { case VISITOR_CHANGE: if (state.selectedEvent.visitors.includes(action.payload)) { // Benne van nem kell megváltoztatni - return { ...state } + return { ...state }; } if (state.selectedEvent.absent.indexOf(action.payload) > -1) { // Ha az absentbe van ki kell venni state.selectedEvent.absent.splice(state.selectedEvent.absent.indexOf(action.payload), 1); } - state.selectedEvent.visitors.push(action.payload) + state.selectedEvent.visitors.push(action.payload); return { ...state, selectedEvent: { @@ -41,7 +41,8 @@ export default (state = INITIAL_STATE, action) => { return { ...state }; } if (state.selectedEvent.visitors.indexOf(action.payload) > -1) { - state.selectedEvent.visitors.splice(state.selectedEvent.visitors.indexOf(action.payload), 1); + state.selectedEvent.visitors + .splice(state.selectedEvent.visitors.indexOf(action.payload), 1); } state.selectedEvent.absent.push(action.payload); return { @@ -54,11 +55,13 @@ export default (state = INITIAL_STATE, action) => { }; case CHANGE_NO: if (state.selectedEvent.visitors.indexOf(action.payload) > -1) { - state.selectedEvent.visitors.splice(state.selectedEvent.visitors.indexOf(action.payload), 1); + state.selectedEvent.visitors + .splice(state.selectedEvent.visitors.indexOf(action.payload), 1); } if (state.selectedEvent.absent.indexOf(action.payload) > -1) { // Ha az absentbe van ki kell venni - state.selectedEvent.absent.splice(state.selectedEvent.absent.indexOf(action.payload), 1); + state.selectedEvent.absent + .splice(state.selectedEvent.absent.indexOf(action.payload), 1); } return { ...state, diff --git a/src/reducers/GroupsReducer.js b/src/reducers/GroupsReducer.js index 22b4baa..9ddff33 100644 --- a/src/reducers/GroupsReducer.js +++ b/src/reducers/GroupsReducer.js @@ -5,7 +5,7 @@ const INITIAL_STATE = []; export default (state = INITIAL_STATE, action) => { switch (action.type) { case GET_GROUPS: - return action.payload ; + return action.payload; default: return state; } diff --git a/src/reducers/HomeworksReducer.js b/src/reducers/HomeworksReducer.js index 870c476..9c5e58e 100644 --- a/src/reducers/HomeworksReducer.js +++ b/src/reducers/HomeworksReducer.js @@ -1,4 +1,6 @@ -import { GET_TASKS, +/* eslint-disable no-case-declarations */ +import { + GET_TASKS, GET_SOLUTIONS, CORRECT_SOLUTION, ADD_TASK, @@ -6,7 +8,8 @@ import { GET_TASKS, EDIT_TASK, ADD_SOLUTION, GET_PROFILES, - GET_DOCUMENTS } from '../actions/types'; + GET_DOCUMENTS, +} from '../actions/types'; const INITIAL_STATE = { id: 0, @@ -24,7 +27,7 @@ export default (state = INITIAL_STATE, action) => { case GET_SOLUTIONS: return { ...state, solutions: action.payload }; case CORRECT_SOLUTION: - const modifiedSolution = state.solutions.find(sol => sol.id === action.payload.id); + const modifiedSolution = state.solutions.find((sol) => sol.id === action.payload.id); const modifiedSolutions = state.solutions.slice(); modifiedSolutions.splice(state.solutions.indexOf(modifiedSolution), 1, action.payload); return { ...state, solutions: [...modifiedSolutions] }; diff --git a/src/reducers/NewsReducer.js b/src/reducers/NewsReducer.js index 68a263d..f59d62f 100644 --- a/src/reducers/NewsReducer.js +++ b/src/reducers/NewsReducer.js @@ -1,4 +1,6 @@ -import { GET_NEWS, ADD_NEWS, DELETE_NEWS, EDIT_NEWS } from '../actions/types'; +import { + GET_NEWS, ADD_NEWS, DELETE_NEWS, EDIT_NEWS, +} from '../actions/types'; const INITIAL_STATE = []; @@ -9,7 +11,7 @@ export default (state = INITIAL_STATE, action) => { case ADD_NEWS: return [action.payload, ...state]; case EDIT_NEWS: - const array = state.filter(item => item.id === action.payload.id); + const array = state.filter((item) => item.id === action.payload.id); state.splice(state.indexOf(array.pop()), 1, action.payload); return [...state]; case DELETE_NEWS: diff --git a/src/reducers/TraineeReducer.js b/src/reducers/TraineeReducer.js index 526cd7a..c2f7a9f 100644 --- a/src/reducers/TraineeReducer.js +++ b/src/reducers/TraineeReducer.js @@ -1,4 +1,6 @@ -import { GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE, SET_STATUS } from '../actions/types'; +import { + GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE, SET_STATUS, +} from '../actions/types'; const INITIAL_STATE = { profiles: [], selectedProfile: {} }; @@ -11,12 +13,12 @@ export default (state = INITIAL_STATE, action) => { case GET_SELECTED_PROFILE: return { ...state, selectedProfile: action.payload }; case SET_STATUS: - const index = state.profiles.findIndex(item => item.id === action.payload.id); + const index = state.profiles.findIndex((item) => item.id === action.payload.id); state.profiles.splice(index, 1, action.payload); if (action.payload.id === state.selectedProfile.id) { return { ...state, profiles: [...state.profiles], selectedProfile: action.payload }; } - return { ...state, profiles: [...state.profiles] } + return { ...state, profiles: [...state.profiles] }; default: return state; } diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index 4a3ccf0..e91fcf1 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -1,3 +1,5 @@ +/* eslint-disable no-param-reassign */ +/* eslint-disable no-use-before-define */ // In production, we register a service worker to serve assets from local cache. // This lets the app load faster on subsequent visits in production, and gives @@ -9,13 +11,13 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === 'localhost' || + window.location.hostname === 'localhost' // [::1] is the IPv6 localhost address. - window.location.hostname === '[::1]' || + || window.location.hostname === '[::1]' // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) + || window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/, + ), ); export default function register() { @@ -46,7 +48,7 @@ export default function register() { function registerValidSW(swUrl) { navigator.serviceWorker .register(swUrl) - .then(registration => { + .then((registration) => { registration.onupdatefound = () => { const installingWorker = registration.installing; installingWorker.onstatechange = () => { @@ -67,7 +69,7 @@ function registerValidSW(swUrl) { }; }; }) - .catch(error => { + .catch((error) => { console.error('Error during service worker registration:', error); }); } @@ -75,14 +77,14 @@ function registerValidSW(swUrl) { function checkValidServiceWorker(swUrl) { // Check if the service worker can be found. If it can't reload the page. fetch(swUrl) - .then(response => { + .then((response) => { // Ensure service worker exists, and that we really are getting a JS file. if ( - response.status === 404 || - response.headers.get('content-type').indexOf('javascript') === -1 + response.status === 404 + || response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. - navigator.serviceWorker.ready.then(registration => { + navigator.serviceWorker.ready.then((registration) => { registration.unregister().then(() => { window.location.reload(); }); @@ -94,14 +96,14 @@ function checkValidServiceWorker(swUrl) { }) .catch(() => { console.log( - 'No internet connection found. App is running in offline mode.' + 'No internet connection found. App is running in offline mode.', ); }); } export function unregister() { if ('serviceWorker' in navigator) { - navigator.serviceWorker.ready.then(registration => { + navigator.serviceWorker.ready.then((registration) => { registration.unregister(); }); } -- GitLab