From 3e1e4abb7ae6eeecab5e2d179449e999121b6c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20L=C3=A1szl=C3=B3?= <rlacko99@gmail.com> Date: Tue, 19 Jan 2021 02:44:12 +0100 Subject: [PATCH] reformat all files --- src/actions/auth.js | 178 ++++---- src/actions/groups.js | 24 +- src/actions/home.js | 24 +- src/actions/homework.js | 451 +++++++++----------- src/actions/mentors.js | 24 +- src/actions/news.js | 162 ++++--- src/actions/notes.js | 79 ++-- src/actions/statistics.js | 289 ++++++------- src/components/App.js | 14 +- src/components/Footer.js | 7 +- src/components/Header.js | 193 +++++---- src/components/Main.js | 44 +- src/components/extra/GroupCard.js | 9 +- src/components/forms/AddEventForm.js | 61 +-- src/components/forms/AddNewsForm.js | 50 +-- src/components/forms/AddSolutionForm.js | 367 ++++++++-------- src/components/forms/AddTaskForm.js | 21 +- src/components/forms/ConfirmModal.js | 89 ++-- src/components/forms/CorrectSolutionForm.js | 136 +++--- src/components/forms/EditNewsForm.js | 85 ++-- src/components/forms/EditTaskForm.js | 94 ++-- src/components/forms/Forms.css | 6 +- src/components/forms/HiddenForm.js | 9 +- src/components/forms/InfoModal.js | 66 ++- src/components/forms/SolutionDetailsForm.js | 150 ++++--- src/components/pages/ApplicantProfile.js | 149 ++++--- src/components/pages/Applications.js | 182 ++++---- src/components/pages/EventDetail.js | 117 +++-- src/components/pages/EventDetailTableRow.js | 193 ++++----- src/components/pages/Events.js | 53 +-- src/components/pages/Groups.js | 26 +- src/components/pages/Home.css | 2 - src/components/pages/Home.js | 333 +++++++-------- src/components/pages/Homework.js | 276 ++++++------ src/components/pages/LeaderBoard.js | 74 ++-- src/components/pages/Mentors.js | 37 +- src/components/pages/News.css | 16 +- src/components/pages/News.js | 87 ++-- src/components/pages/NotFound.js | 16 +- src/components/pages/Presence.js | 82 ++-- src/components/pages/Profile.js | 423 +++++++++--------- src/components/pages/Schedule.js | 39 +- src/components/pages/Statistics.js | 30 +- src/configureStore.js | 9 +- src/containers/TodoContainer.js | 15 +- src/index.js | 17 +- src/reducers/AddNewsReducer.js | 2 +- src/reducers/AddSolutionReducer.js | 5 +- src/reducers/AddTaskReducer.js | 2 +- src/reducers/CorrectSolutionReducer.js | 6 +- src/reducers/EditNewsReducer.js | 4 +- src/reducers/EditTaskReducer.js | 7 +- src/reducers/EventReducer.js | 38 +- src/reducers/HomeworksReducer.js | 46 +- src/reducers/NewsReducer.js | 4 +- src/reducers/NoteReducer.js | 9 +- src/reducers/TraineeReducer.js | 15 +- src/reducers/UserReducer.js | 7 +- src/reducers/index.js | 20 +- src/registerServiceWorker.js | 16 +- 60 files changed, 2476 insertions(+), 2513 deletions(-) diff --git a/src/actions/auth.js b/src/actions/auth.js index 0dafdfe..937d872 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -1,110 +1,110 @@ -import axios from './session'; import { - GET_USERDATA, PROFILE_CHANGE, GROUP_CHANGE, GET_DEADLINE, + GET_DEADLINE, + GET_USERDATA, + GROUP_CHANGE, + PROFILE_CHANGE, } from './types'; +import axios from './session'; + +export const getUserData = () => async (dispatch) => { + try { + const user = await axios.get('/api/v1/profiles/me'); + const { + id, + join_date: joinDate, + nick, + motivation_about: motivationAbout, + motivation_profession: motivationProfession, + motivation_exercise: motivationExercise, + full_name, + signed, + groups, + role, + bits, + } = user.data; + let permission; + switch (role) { + case 'Applicant': + permission = 1; + break; + case 'Student': + permission = 2; + break; + case 'Staff': + permission = 3; + break; + default: + permission = 0; + break; + } -export const getUserData = () => ( - async (dispatch) => { - try { - const user = await axios.get('/api/v1/profiles/me'); - const { + dispatch({ + type: GET_USERDATA, + payload: { id, - join_date: joinDate, + joinDate, nick, - motivation_about: motivationAbout, - motivation_profession: motivationProfession, - motivation_exercise: motivationExercise, + motivationAbout, + motivationProfession, + motivationExercise, full_name, signed, groups, role, + permission, bits, - } = user.data; - let permission; - switch (role) { - case 'Applicant': - permission = 1; - break; - case 'Student': - permission = 2; - break; - case 'Staff': - permission = 3; - break; - default: - permission = 0; - break; - } - - dispatch({ - type: GET_USERDATA, - payload: { - id, - joinDate, - nick, - motivationAbout, - motivationProfession, - motivationExercise, - full_name, - signed, - groups, - role, - permission, - bits, - }, - }); - } catch (e) { - console.log(e); - } + }, + }); + } catch (e) { + console.log(e); } -); +}; -export const getDeadline = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/profiles/deadline'); +export const getDeadline = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/profiles/deadline'); - dispatch({ - type: GET_DEADLINE, - payload: response.data, - }); - } catch (e) { - console.log(e); - } + dispatch({ + type: GET_DEADLINE, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const textChange = ({ target: { name, value } }) => ( - (dispatch) => { - dispatch({ type: PROFILE_CHANGE, payload: value, target: name }); - } -); +export const textChange = ({ target: { name, value } }) => (dispatch) => { + dispatch({ type: PROFILE_CHANGE, payload: value, target: name }); +}; -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 = ({ - nick, groups, signed, motivationAbout, motivationProfession, motivationExercise, id, -}) => ( - async () => { - try { - const response = await axios.patch(`/api/v1/profiles/${id}/`, { - nick, - groups, - signed, - motivation_about: motivationAbout, - motivation_profession: motivationProfession, - motivation_exercise: motivationExercise, - }); - if (response.data.id === id) { - alert('Sikeres mentĂŠs!'); - } else { - alert('MentĂŠs nem sikerĂźlt!'); - } - } catch (e) { - console.log(e); + nick, + groups, + signed, + motivationAbout, + motivationProfession, + motivationExercise, + id, +}) => async () => { + try { + const response = await axios.patch(`/api/v1/profiles/${id}/`, { + nick, + groups, + signed, + motivation_about: motivationAbout, + motivation_profession: motivationProfession, + motivation_exercise: motivationExercise, + }); + if (response.data.id === id) { + alert('Sikeres mentĂŠs!'); + } else { + alert('MentĂŠs nem sikerĂźlt!'); } + } catch (e) { + console.log(e); } -); +}; diff --git a/src/actions/groups.js b/src/actions/groups.js index 100e4ff..e15621b 100644 --- a/src/actions/groups.js +++ b/src/actions/groups.js @@ -1,16 +1,14 @@ -import axios from './session'; import { GET_GROUPS } from './types'; +import axios from './session'; -export const getGroups = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/groups'); - dispatch({ - type: GET_GROUPS, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +export const getGroups = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/groups'); + dispatch({ + type: GET_GROUPS, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; diff --git a/src/actions/home.js b/src/actions/home.js index 56f5482..9ebb7d3 100644 --- a/src/actions/home.js +++ b/src/actions/home.js @@ -1,16 +1,14 @@ -import axios from './session'; import { GET_IMAGES } from './types'; +import axios from './session'; -export const getImages = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/images'); - dispatch({ - type: GET_IMAGES, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +export const getImages = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/images'); + dispatch({ + type: GET_IMAGES, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; diff --git a/src/actions/homework.js b/src/actions/homework.js index 741965c..5f231f6 100644 --- a/src/actions/homework.js +++ b/src/actions/homework.js @@ -1,291 +1,266 @@ -import axios from './session'; import { - GET_TASKS, - GET_SOLUTIONS, + ADD_DOCUMENT, + ADD_SOLUTION, ADD_TASK, + CHECK, + CLEAR_WRITE, + CORRECT_SOLUTION, DELETE_TASK, - WRITE_TASK, EDIT_TASK, + GET_DOCUMENTS, + GET_PROFILES, + GET_SOLUTIONS, + GET_TASKS, + SELECT_SOLUTION, SELECT_TASK, - CLEAR_WRITE, - ADD_SOLUTION, + SETCHECKTRUE, WRITE_SOLUTION, WRITE_SOLUTION_FILE, - GET_PROFILES, - ADD_DOCUMENT, - GET_DOCUMENTS, - CORRECT_SOLUTION, - SELECT_SOLUTION, - CHECK, SETCHECKTRUE, + WRITE_TASK, } from './types'; -export const getTasks = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/homework/tasks/'); +import axios from './session'; + +export const getTasks = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/homework/tasks/'); + dispatch({ + type: GET_TASKS, + payload: response.data, + }); + } catch (e) { + console.log(e); + } +}; + +export const getSolutions = (taskId) => async (dispatch) => { + try { + const response = await axios.get('/api/v1/homework/solutions/', { + task: taskId, + }); + dispatch({ + type: GET_SOLUTIONS, + payload: response.data, + }); + } catch (e) { + console.log(e); + } +}; + +export const addTask = ({ title, text, deadline, bits }) => async ( + dispatch +) => { + try { + const response = await axios.post('/api/v1/homework/tasks/', { + title, + text, + deadline, + bits, + }); + if (response.data.id) { dispatch({ - type: GET_TASKS, + type: ADD_TASK, payload: response.data, }); - } catch (e) { - console.log(e); } + } catch (e) { + console.log(e); } -); +}; -export const getSolutions = (taskId) => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/homework/solutions/', { task: taskId }); +export const editTask = ({ id, title, text, deadline, bits }) => async ( + dispatch +) => { + try { + const response = await axios.patch(`/api/v1/homework/tasks/${id}/`, { + title, + text, + deadline, + bits, + }); + if (response.data.id) { dispatch({ - type: GET_SOLUTIONS, + type: EDIT_TASK, payload: response.data, }); - } catch (e) { - console.log(e); } + } catch (e) { + console.log(e); } -); +}; -export const addTask = ({ - title, text, deadline, bits, -}) => ( - async (dispatch) => { - try { - const response = await axios.post('/api/v1/homework/tasks/', { - title, - text, - deadline, - bits, +export const deleteTask = (task) => async (dispatch) => { + try { + const response = await axios.delete(`/api/v1/homework/tasks/${task.id}/`); + if (!response.data.id) { + dispatch({ + type: DELETE_TASK, + payload: task, }); - if (response.data.id) { - dispatch({ - type: ADD_TASK, - payload: response.data, - }); - } - } catch (e) { - console.log(e); } + } catch (e) { + console.log(e); } -); +}; -export const editTask = ({ - id, - title, - text, - deadline, - bits, -}) => ( - async (dispatch) => { - try { - const response = await axios.patch(`/api/v1/homework/tasks/${id}/`, { - title, - text, - deadline, - bits, - }); - if (response.data.id) { - dispatch({ - type: EDIT_TASK, - payload: response.data, - - }); - } - } catch (e) { - console.log(e); - } - } -); +export const setSelectedTask = (task) => (dispatch) => { + dispatch({ type: SELECT_TASK, payload: task }); +}; -export const deleteTask = (task) => ( - async (dispatch) => { - try { - const response = await axios.delete(`/api/v1/homework/tasks/${task.id}/`); - if (!response.data.id) { - dispatch({ - type: DELETE_TASK, - payload: task, - }); - } - } catch (e) { - console.log(e); - } - }); - -export const setSelectedTask = (task) => ( - (dispatch) => { - dispatch({ type: SELECT_TASK, payload: task }); - } -); - -export const addDocument = ({ - name, description, file, solution, -}) => ( - async (dispatch) => { - try { - const formData = new FormData(); - formData.append('name', name); - formData.append('description', description); - formData.append('file', file); - formData.append('solution', solution); - const config = { - headers: { - 'content-type': 'multipart/form-data', - }, - }; - const response = await axios.post('/api/v1/documents/', formData, config); - if (response.data.id) { - dispatch({ - type: ADD_DOCUMENT, - payload: response.data, - }); - } - } catch (e) { - console.log(e); +export const addDocument = ({ name, description, file, solution }) => async ( + dispatch +) => { + try { + const formData = new FormData(); + formData.append('name', name); + formData.append('description', description); + formData.append('file', file); + formData.append('solution', solution); + const config = { + headers: { + 'content-type': 'multipart/form-data', + }, + }; + const response = await axios.post('/api/v1/documents/', formData, config); + if (response.data.id) { + dispatch({ + type: ADD_DOCUMENT, + payload: response.data, + }); } + } catch (e) { + console.log(e); } -); +}; export const addSolution = ({ - task, accepted, corrected, note, name, description, file, -}) => ( - async (dispatch) => { - try { - const response = await axios.post('/api/v1/homework/solutions/', { - task, - accepted, - corrected, - note, + task, + accepted, + corrected, + note, + name, + description, + file, +}) => async (dispatch) => { + try { + const response = await axios.post('/api/v1/homework/solutions/', { + task, + accepted, + corrected, + note, + }); + if (response.data.id) { + dispatch({ + type: ADD_SOLUTION, + payload: response.data, }); - if (response.data.id) { - dispatch({ - type: ADD_SOLUTION, - payload: response.data, - }); - } - - const solution = response.data.id; - - const formData = new FormData(); - formData.append('name', name); - formData.append('description', description); - formData.append('file', file); - formData.append('solution', solution); - const config = { - headers: { - 'content-type': 'multipart/form-data', - }, - }; - const responsedoc = await axios.post('/api/v1/documents/', formData, config); - if (responsedoc.data.id) { - dispatch({ - type: ADD_DOCUMENT, - payload: responsedoc.data, - }); - } - } catch (e) { - console.log(e); } - } -); -export const getDocuments = (solutionID) => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/documents', { params: { solution: solutionID } }); + const solution = response.data.id; + + const formData = new FormData(); + formData.append('name', name); + formData.append('description', description); + formData.append('file', file); + formData.append('solution', solution); + const config = { + headers: { + 'content-type': 'multipart/form-data', + }, + }; + const responsedoc = await axios.post( + '/api/v1/documents/', + formData, + config + ); + if (responsedoc.data.id) { dispatch({ - type: GET_DOCUMENTS, - payload: response.data, + type: ADD_DOCUMENT, + payload: responsedoc.data, }); - } catch (e) { - console.log(e); } + } catch (e) { + console.log(e); } -); +}; -export const writeSolution = ({ target: { name, value } }) => ( - (dispatch) => { - dispatch({ type: WRITE_SOLUTION, payload: value, target: name }); +export const getDocuments = (solutionID) => async (dispatch) => { + try { + const response = await axios.get('/api/v1/documents', { + params: { solution: solutionID }, + }); + dispatch({ + type: GET_DOCUMENTS, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const writeSolutionFile = ({ target: { files } }) => ( - (dispatch) => { - dispatch({ type: WRITE_SOLUTION_FILE, payload: files[0], target: 'file' }); - } -); +export const writeSolution = ({ target: { name, value } }) => (dispatch) => { + dispatch({ type: WRITE_SOLUTION, payload: value, target: name }); +}; -export const writeTask = ({ target: { name, value } }) => ( - (dispatch) => { - dispatch({ type: WRITE_TASK, payload: value, target: name }); - } -); +export const writeSolutionFile = ({ target: { files } }) => (dispatch) => { + dispatch({ type: WRITE_SOLUTION_FILE, payload: files[0], target: 'file' }); +}; -export const writeTaskDeadline = ({ name, value }) => ( - (dispatch) => { - dispatch({ type: WRITE_TASK, payload: value, target: name }); - } -); +export const writeTask = ({ target: { name, value } }) => (dispatch) => { + dispatch({ type: WRITE_TASK, payload: value, target: name }); +}; + +export const writeTaskDeadline = ({ name, value }) => (dispatch) => { + dispatch({ type: WRITE_TASK, payload: value, target: name }); +}; + +export const clearWrite = () => (dispatch) => { + dispatch({ type: CLEAR_WRITE }); +}; -export const clearWrite = () => ( - (dispatch) => { - dispatch({ type: CLEAR_WRITE }); +export const getProfiles = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/profiles/'); + dispatch({ + type: GET_PROFILES, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const getProfiles = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/profiles/'); +export const correctSolution = (id, corrected, accepted, note) => async ( + dispatch +) => { + try { + const response = await axios.patch(`/api/v1/homework/solutions/${id}/`, { + corrected, + accepted, + note, + }); + if (response.data.id) { dispatch({ - type: GET_PROFILES, + type: CORRECT_SOLUTION, payload: response.data, }); - } catch (e) { - console.log(e); } + } catch (e) { + console.log(e); } -); +}; -export const correctSolution = (id, corrected, accepted, note) => ( - async (dispatch) => { - try { - const response = await axios.patch(`/api/v1/homework/solutions/${id}/`, { - corrected, - accepted, - note, - }); - if (response.data.id) { - dispatch({ - type: CORRECT_SOLUTION, - payload: response.data, +export const check = (name) => (dispatch) => { + dispatch({ type: CHECK, target: name }); +}; - }); - } - } catch (e) { - console.log(e); - } - } -); - -export const check = (name) => ( - (dispatch) => { - dispatch({ type: CHECK, target: name }); - } -); - -export const setchecktrue = (name) => ( - (dispatch) => { - dispatch({ type: SETCHECKTRUE, target: name }); - } -); +export const setchecktrue = (name) => (dispatch) => { + dispatch({ type: SETCHECKTRUE, target: name }); +}; -export const selectSolution = (solution) => ( - (dispatch) => { - dispatch({ - type: SELECT_SOLUTION, - payload: solution, - }); - } -); +export const selectSolution = (solution) => (dispatch) => { + dispatch({ + type: SELECT_SOLUTION, + payload: solution, + }); +}; diff --git a/src/actions/mentors.js b/src/actions/mentors.js index bba7cb1..cb655e2 100644 --- a/src/actions/mentors.js +++ b/src/actions/mentors.js @@ -1,16 +1,14 @@ -import axios from './session'; import { GET_MENTORS } from './types'; +import axios from './session'; -export const getMentors = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/mentors'); - dispatch({ - type: GET_MENTORS, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +export const getMentors = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/mentors'); + dispatch({ + type: GET_MENTORS, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; diff --git a/src/actions/news.js b/src/actions/news.js index 29bdbc8..48ab8eb 100644 --- a/src/actions/news.js +++ b/src/actions/news.js @@ -1,104 +1,96 @@ -import axios from './session'; import { - GET_NEWS, WRITE_NEWS, ADD_NEWS, DELETE_NEWS, - CLEAR_WRITE, SELECT_NEWS, EDIT_NEWS, + ADD_NEWS, + CLEAR_WRITE, + DELETE_NEWS, + EDIT_NEWS, + GET_NEWS, + SELECT_NEWS, + WRITE_NEWS, } from './types'; -export const getNews = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/news'); +import axios from './session'; + +export const getNews = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/news'); + dispatch({ + type: GET_NEWS, + payload: response.data, + }); + } catch (e) { + console.log(e); + } +}; + +export const postNews = ({ title, updated_by, text }) => async (dispatch) => { + try { + const response = await axios.post('/api/v1/news/', { + updated_by, + title, + text, + }); + if (response.data.id) { + alert('Sikeres mentĂŠs!'); dispatch({ - type: GET_NEWS, + type: ADD_NEWS, payload: response.data, }); - } catch (e) { - console.log(e); + } else { + alert('MentĂŠs nem sikerĂźlt!'); } + } catch (e) { + console.log(e); } -); +}; -export const postNews = ({ title, updated_by, text }) => ( - async (dispatch) => { - try { - const response = await axios.post('/api/v1/news/', { - updated_by, - title, - text, +export const editNews = ({ id, title, text, updated_by }) => async ( + dispatch +) => { + try { + const response = await axios.patch(`/api/v1/news/${id}/`, { + updated_by, + title, + text, + }); + if (response.data.id) { + alert('Sikeres mentĂŠs!'); + dispatch({ + type: EDIT_NEWS, + payload: response.data, }); - if (response.data.id) { - alert('Sikeres mentĂŠs!'); - dispatch({ - type: ADD_NEWS, - payload: response.data, - }); - } else { - alert('MentĂŠs nem sikerĂźlt!'); - } - } catch (e) { - console.log(e); + } else { + alert('MentĂŠs nem sikerĂźlt!'); } + } catch (e) { + console.log(e); } -); +}; -export const editNews = ({ - id, title, text, updated_by, -}) => ( - async (dispatch) => { - try { - const response = await axios.patch(`/api/v1/news/${id}/`, { - updated_by, - title, - text, +export const deleteNews = (news) => async (dispatch) => { + try { + const response = await axios.delete(`/api/v1/news/${news.id}/`); + if (!response.data.id) { + alert('Sikeres tĂśrlĂŠs!'); + dispatch({ + type: DELETE_NEWS, + payload: news, }); - if (response.data.id) { - alert('Sikeres mentĂŠs!'); - dispatch({ - type: EDIT_NEWS, - payload: response.data, - - }); - } else { - alert('MentĂŠs nem sikerĂźlt!'); - } - } catch (e) { - console.log(e); + } else { + alert('A tĂśrlĂŠs nem sikerĂźlt!'); } + } catch (e) { + console.log(e); } -); +}; -export const deleteNews = (news) => ( - async (dispatch) => { - try { - const response = await axios.delete(`/api/v1/news/${news.id}/`); - if (!response.data.id) { - alert('Sikeres tĂśrlĂŠs!'); - dispatch({ - type: DELETE_NEWS, - payload: news, - }); - } else { - alert('A tĂśrlĂŠs nem sikerĂźlt!'); - } - } catch (e) { - console.log(e); - } - }); +export const writeNews = ({ target: { name, value } }) => (dispatch) => { + dispatch({ type: WRITE_NEWS, payload: value, target: name }); +}; -export const writeNews = ({ target: { name, value } }) => ( - (dispatch) => { - dispatch({ type: WRITE_NEWS, payload: value, target: name }); - } -); +export const clearWrite = () => (dispatch) => { + dispatch({ type: CLEAR_WRITE }); +}; -export const clearWrite = () => ( - (dispatch) => { - dispatch({ type: CLEAR_WRITE }); - } -); - -export const setSelectedNews = (item) => ( - (dispatch) => { - dispatch({ type: SELECT_NEWS, payload: 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 b9a5b4c..92ff4f1 100644 --- a/src/actions/notes.js +++ b/src/actions/notes.js @@ -1,51 +1,50 @@ -import axios from './session'; import { - GET_NOTES_BY_EVENT, - WRITE_NOTE, ADD_EVENT_NOTE, CLEAR_WRITE, + GET_NOTES_BY_EVENT, + WRITE_NOTE, } from './types'; -export const getNotesByEvent = (id) => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/notes/', { params: { eventID: id } }); - dispatch({ - type: GET_NOTES_BY_EVENT, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +import axios from './session'; + +export const getNotesByEvent = (id) => async (dispatch) => { + try { + const response = await axios.get('/api/v1/notes/', { + params: { eventID: id }, + }); + dispatch({ + type: GET_NOTES_BY_EVENT, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const writeNote = (event) => ((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 || '', - profile: userid || '', - note, +export const postEventNote = ({ eventid, userid, note }) => async ( + dispatch +) => { + try { + const response = await axios.post('/api/v1/notes/', { + event: eventid || '', + profile: userid || '', + note, + }); + if (response.data.id) { + alert('Sikeres mentĂŠs!'); + dispatch({ + type: ADD_EVENT_NOTE, + payload: response.data, }); - if (response.data.id) { - alert('Sikeres mentĂŠs!'); - dispatch({ - type: ADD_EVENT_NOTE, - payload: response.data, - }); - } - } catch (e) { - console.log(e); } - }); - -export const clearWrite = () => ( - (dispatch) => { - dispatch({ type: CLEAR_WRITE }); + } catch (e) { + console.log(e); } -); +}; + +export const clearWrite = () => (dispatch) => { + dispatch({ type: CLEAR_WRITE }); +}; diff --git a/src/actions/statistics.js b/src/actions/statistics.js index eddbcff..c8e118d 100644 --- a/src/actions/statistics.js +++ b/src/actions/statistics.js @@ -1,203 +1,180 @@ -import axios from './session'; import { - GET_EVENTS, - GET_EVENT_BY_ID, - GET_TRAINEES, - VISITOR_CHANGE, - WRITE_EVENT, + ABSENT_CHANGE, ADD_EVENT, + CHANGE_NO, DELETE_EVENT, + GET_EVENTS, + GET_EVENT_BY_ID, GET_PROFILES, GET_SELECTED_PROFILE, + GET_TRAINEES, SET_STATUS, - ABSENT_CHANGE, - CHANGE_NO, + VISITOR_CHANGE, + WRITE_EVENT, } from './types'; -export const getStaffEvents = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/staff_events/'); - dispatch({ - type: GET_EVENTS, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +import axios from './session'; + +export const getStaffEvents = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/staff_events/'); + dispatch({ + type: GET_EVENTS, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const getStudentEvents = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/student_events/'); - dispatch({ - type: GET_EVENTS, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +export const getStudentEvents = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/student_events/'); + dispatch({ + type: GET_EVENTS, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const getEventById = (id) => ( - async (dispatch) => { - try { - const response = await axios.get(`/api/v1/staff_events/${id}`); - dispatch({ - type: GET_EVENT_BY_ID, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +export const getEventById = (id) => async (dispatch) => { + try { + const response = await axios.get(`/api/v1/staff_events/${id}`); + dispatch({ + type: GET_EVENT_BY_ID, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const getTrainees = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/profiles/'); - dispatch({ - type: GET_TRAINEES, - payload: response.data, - }); - } catch (e) { - console.log(e); - } +export const getTrainees = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/profiles/'); + dispatch({ + type: GET_TRAINEES, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; export const visitorChange = ({ id, 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; } }; -export const submitVisitors = ({ id, visitors, absent }) => ( - async () => { - try { - const response = await axios.patch(`/api/v1/staff_events/${id}/`, { - visitors, - absent, - }); - if (response.data.id === id) { - return true; - } - return false; - } catch (e) { - console.log(e); - return false; +export const submitVisitors = ({ id, visitors, absent }) => async () => { + try { + const response = await axios.patch(`/api/v1/staff_events/${id}/`, { + visitors, + absent, + }); + if (response.data.id === id) { + return true; } + return false; + } catch (e) { + console.log(e); + return false; } -); - -export const writeEvent = ({ target: { name, value } }) => ( - (dispatch) => { - dispatch({ type: WRITE_EVENT, payload: value, target: name }); - } -); +}; +export const writeEvent = ({ target: { name, value } }) => (dispatch) => { + dispatch({ type: WRITE_EVENT, payload: value, target: name }); +}; -export const eventDate = (name, value) => ( - (dispatch) => { - dispatch({ type: WRITE_EVENT, payload: value, target: name }); - } -); +export const eventDate = (name, value) => (dispatch) => { + dispatch({ type: WRITE_EVENT, payload: value, target: name }); +}; -export const addEvent = ({ name, date, description }) => ( - async (dispatch) => { - try { - const response = await axios.post('/api/v1/staff_events/', { - name, - date, - description, - absent: [], +export const addEvent = ({ name, date, description }) => async (dispatch) => { + try { + const response = await axios.post('/api/v1/staff_events/', { + name, + date, + description, + absent: [], + }); + if (response.data.id) { + alert('Sikeres mentĂŠs!'); + dispatch({ + type: ADD_EVENT, + payload: response.data, }); - if (response.data.id) { - alert('Sikeres mentĂŠs!'); - dispatch({ - type: ADD_EVENT, - payload: response.data, - }); - } else { - alert('MentĂŠs nem sikerĂźlt!'); - } - } catch (e) { - console.log(e); + } else { + alert('MentĂŠs nem sikerĂźlt!'); } + } catch (e) { + console.log(e); } -); - -export const deleteEvent = (event) => ( - async (dispatch) => { - try { - const response = await axios.delete(`/api/v1/staff_events/${event.id}/`); - if (!response.data.id) { - alert('Sikeres tĂśrlĂŠs!'); - dispatch({ - type: DELETE_EVENT, - payload: event, - }); - } else { - alert('A tĂśrlĂŠs nem sikerĂźlt!'); - } - } catch (e) { - console.log(e); - } - }); +}; -export const getProfiles = () => ( - async (dispatch) => { - try { - const response = await axios.get('/api/v1/profiles/'); +export const deleteEvent = (event) => async (dispatch) => { + try { + const response = await axios.delete(`/api/v1/staff_events/${event.id}/`); + if (!response.data.id) { + alert('Sikeres tĂśrlĂŠs!'); dispatch({ - type: GET_PROFILES, - payload: response.data, + type: DELETE_EVENT, + payload: event, }); - } catch (e) { - console.log(e); + } else { + alert('A tĂśrlĂŠs nem sikerĂźlt!'); } + } catch (e) { + console.log(e); } -); +}; -export const setStatus = (id, status) => ( - async (dispatch) => { - try { - const response = await axios.patch(`/api/v1/profiles/${id}/`, { - role: status, - }); - if (response.data.id) { - dispatch({ - type: SET_STATUS, - payload: response.data, - }); - } - } catch (e) { - console.log(e); - } +export const getProfiles = () => async (dispatch) => { + try { + const response = await axios.get('/api/v1/profiles/'); + dispatch({ + type: GET_PROFILES, + payload: response.data, + }); + } catch (e) { + console.log(e); } -); +}; -export const getSelectedProfile = (id) => ( - async (dispatch) => { - try { - const response = await axios.get(`/api/v1/profiles/${id}/`); +export const setStatus = (id, status) => async (dispatch) => { + try { + const response = await axios.patch(`/api/v1/profiles/${id}/`, { + role: status, + }); + if (response.data.id) { dispatch({ - type: GET_SELECTED_PROFILE, + type: SET_STATUS, payload: response.data, }); - } catch (e) { - console.log(e); } + } catch (e) { + console.log(e); } -); +}; + +export const getSelectedProfile = (id) => async (dispatch) => { + try { + const response = await axios.get(`/api/v1/profiles/${id}/`); + dispatch({ + type: GET_SELECTED_PROFILE, + payload: response.data, + }); + } catch (e) { + console.log(e); + } +}; diff --git a/src/components/App.js b/src/components/App.js index 490fd7e..e861cc2 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,18 +1,20 @@ -import React from 'react'; +import Footer from './Footer'; import Header from './Header'; import Main from './Main'; -import Footer from './Footer'; - +import React from 'react'; const App = () => ( <div style={{ minHeight: '100%', position: 'relative' }}> - <header id='header'> + <header id="header"> <Header /> </header> - <main id='main' style={{ minHeight: '100%', position: 'relative' }}> + <main id="main" style={{ minHeight: '100%', position: 'relative' }}> <Main /> </main> - <footer id='footer' style={{ position: 'absolute', width: '100%', bottom: '0' }}> + <footer + id="footer" + style={{ position: 'absolute', width: '100%', bottom: '0' }} + > <Footer /> </footer> </div> diff --git a/src/components/Footer.js b/src/components/Footer.js index 69b3e06..750e14c 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -1,14 +1,13 @@ -import React from 'react'; import { Container, Segment } from 'semantic-ui-react'; +import React from '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> - ); export default Footer; diff --git a/src/components/Header.js b/src/components/Header.js index 8cbdab7..5b96356 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,26 +1,28 @@ -import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; import { - Menu, - Container, Button, - Segment, + Container, + Icon, Image, + Menu, Popup, - Icon, Responsive, + Segment, } from 'semantic-ui-react'; +import React, { Component } from 'react'; +import KSZKlogo from './images/kszk_logo.svg'; +import { Link } from 'react-router-dom'; import { connect } from 'react-redux'; import { getUserData } from '../actions'; -import KSZKlogo from './images/kszk_logo.svg'; // Objects that will be converted to menu items in the render method const menuItems = [ { text: 'FĹoldal', to: '/home', - prefix: <Image size='mini' src={KSZKlogo} style={{ marginRight: '1.5em' }} />, + prefix: ( + <Image size="mini" src={KSZKlogo} style={{ marginRight: '1.5em' }} /> + ), permissionLevel: 0, }, { @@ -83,28 +85,28 @@ class Header extends Component { // Hide the menu after clicking an item on mobile handleOpen = () => { this.setState({ isOpen: true }); - } + }; handleClose = () => { this.setState({ isOpen: false }); - } + }; 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; + maxNum = menuItems.filter( + (item) => this.props.user.permission >= item.permissionLevel + ).length; } else { maxNum = 3; } return ( - <Segment inverted textAlign='center' vertical> + <Segment inverted textAlign="center" vertical> <Container> - <Menu inverted secondary size='large'> + <Menu inverted secondary size="large"> {/* Default Menu items */} {menuItems.map((item) => { if (item.permissionLevel === 0) { @@ -120,10 +122,12 @@ class Header extends Component { })} {/* After default menu items */} {menuItems.map((item, i) => { - if (this.props.user.permission >= item.permissionLevel - && item.permissionLevel > 0 - && renderedItemNum < inHeader - && current < i) { + if ( + this.props.user.permission >= item.permissionLevel && + item.permissionLevel > 0 && + renderedItemNum < inHeader && + current < i + ) { renderedItemNum += 1; current = i; return ( @@ -136,45 +140,46 @@ class Header extends Component { 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) => (this.props.user.permission >= item.permissionLevel - && item.permissionLevel > 0 - && current < i - ? ( - <Menu.Item key={Math.random()} as={Link} to={item.to}> - {item.prefix} - {item.text} - </Menu.Item> - ) - : null - ))} - </Menu> - </Popup> - ) - : null} + {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={Math.random()} as={Link} to={item.to}> + {item.prefix} + {item.text} + </Menu.Item> + ) : 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>} + <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> + )} </Menu.Item> </Menu> </Container> @@ -201,14 +206,12 @@ class Header extends Component { <Responsive minWidth={1101} maxWidth={1200}> {this.renderHeader(7)} </Responsive> - <Responsive minWidth={1201}> - {this.renderHeader(8)} - </Responsive> + <Responsive minWidth={1201}>{this.renderHeader(8)}</Responsive> {/* Mobile view */} <Responsive maxWidth={599}> - <Segment inverted textAlign='center' vertical> + <Segment inverted textAlign="center" vertical> <Container> - <Menu inverted secondary size='large'> + <Menu inverted secondary size="large"> {/* kszk logo + home link */} <Menu.Item as={Link} to={menuItems[0].to}> {menuItems[0].prefix} @@ -219,24 +222,22 @@ class Header extends Component { flowing hoverable inverted - trigger={( - <Menu.Item - onClick={this.handleClose} - position='right' - > - <Icon name='bars' size='large' /> + trigger={ + <Menu.Item onClick={this.handleClose} position="right"> + <Icon name="bars" size="large" /> </Menu.Item> - )} - position='top center' + } + position="top center" open={this.state.isOpen} onOpen={this.handleOpen} - on='click' - size='huge' + on="click" + size="huge" > - <Menu vertical inverted secondary size='large'> - {menuItems.map((item, i) => ((this.props.user.permission >= item.permissionLevel - || item.permissionLevel === 0) && i > 0 - ? ( + <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={Math.random()} @@ -246,18 +247,36 @@ class Header extends Component { {item.prefix} {item.text} </Menu.Item> - ) - : null - ))} + ) : 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> diff --git a/src/components/Main.js b/src/components/Main.js index 0b66f61..0853fb9 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -1,35 +1,33 @@ -import React from 'react'; -import { - Switch, Route, Redirect, withRouter, -} from 'react-router-dom'; +import { Redirect, Route, Switch, withRouter } from 'react-router-dom'; +import ApplicantProfile from './pages/ApplicantProfile'; +import Applications from './pages/Applications'; +import EventDetail from './pages/EventDetail'; +import Groups from './pages/Groups'; import Home from './pages/Home'; +import Homework from './pages/Homework'; import Mentors from './pages/Mentors'; -import Schedule from './pages/Schedule'; +import News from './pages/News'; import NotFound from './pages/NotFound'; import Profile from './pages/Profile'; +import React from 'react'; +import Schedule from './pages/Schedule'; import Statistics from './pages/Statistics'; -import Groups from './pages/Groups'; -import News from './pages/News'; -import Homework from './pages/Homework'; -import Applications from './pages/Applications'; -import EventDetail from './pages/EventDetail'; -import ApplicantProfile from './pages/ApplicantProfile'; const Main = () => ( <Switch> - <Redirect exact from='/' to='/home' /> - <Route exact path='/home' component={Home} /> - <Route path='/news' component={News} /> - <Route path='/mentors' component={Mentors} /> - <Route path='/schedule' component={Schedule} /> - <Route path='/profile' component={withRouter(Profile)} /> - <Route path='/statistics' component={Statistics} /> - <Route path='/groups' component={Groups} /> - <Route path='/homework' component={Homework} /> - <Route path='/events/:id' component={EventDetail} /> - <Route path='/applications' component={Applications} /> - <Route path='/applicant/:id' component={ApplicantProfile} /> + <Redirect exact from="/" to="/home" /> + <Route exact path="/home" component={Home} /> + <Route path="/news" component={News} /> + <Route path="/mentors" component={Mentors} /> + <Route path="/schedule" component={Schedule} /> + <Route path="/profile" component={withRouter(Profile)} /> + <Route path="/statistics" component={Statistics} /> + <Route path="/groups" component={Groups} /> + <Route path="/homework" component={Homework} /> + <Route path="/events/:id" component={EventDetail} /> + <Route path="/applications" component={Applications} /> + <Route path="/applicant/:id" component={ApplicantProfile} /> <Route component={NotFound} /> </Switch> ); diff --git a/src/components/extra/GroupCard.js b/src/components/extra/GroupCard.js index 4cc2b11..88b972a 100644 --- a/src/components/extra/GroupCard.js +++ b/src/components/extra/GroupCard.js @@ -1,16 +1,19 @@ +import { Divider, Header, Segment } from 'semantic-ui-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' }}> + <Header as="h3" style={{ fontSize: '1.2em' }}> {this.props.label} </Header> </Divider> - <div className='paragraph' dangerouslySetInnerHTML={{ __html: this.props.value }} /> + <div + className="paragraph" + dangerouslySetInnerHTML={{ __html: this.props.value }} + /> </Segment> ); } diff --git a/src/components/forms/AddEventForm.js b/src/components/forms/AddEventForm.js index 79ce80a..1cdc9f0 100644 --- a/src/components/forms/AddEventForm.js +++ b/src/components/forms/AddEventForm.js @@ -1,11 +1,10 @@ +import { Button, Form, Icon, Input, Modal } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Modal, Button, Form, Input, Icon, -} from 'semantic-ui-react'; -import { connect } from 'react-redux'; +import { addEvent, eventDate, writeEvent } from '../../actions/statistics'; + import { DateTimeInput } from 'semantic-ui-calendar-react'; -import { writeEvent, eventDate, addEvent } from '../../actions/statistics'; import { clearWrite } from '../../actions/news'; +import { connect } from 'react-redux'; class AddEventForm extends Component { constructor(props) { @@ -16,7 +15,6 @@ 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 }) => { @@ -24,21 +22,23 @@ class AddEventForm extends Component { this.setState({ [name]: value }); } this.props.eventDate(name, value); - } + }; render() { const { name, description } = this.props.newEvent; return ( <Modal open={this.state.showModal} - trigger={( + trigger={ <Button - size='big' - onClick={() => { this.setState({ showModal: true }); }} + size="big" + onClick={() => { + this.setState({ showModal: true }); + }} > -Alkalom hozzĂĄadĂĄsa + Alkalom hozzĂĄadĂĄsa </Button> - )} + } > <Modal.Header>Ăj alkalom:</Modal.Header> <Modal.Content @@ -49,29 +49,29 @@ Alkalom hozzĂĄadĂĄsa <Form> <Form.Field control={Input} - label='NĂŠv' - name='name' + label="NĂŠv" + name="name" onChange={(e) => this.props.writeEvent(e)} value={name} style={{ marginBottom: '20px', }} - placeholder='Title' + placeholder="Title" /> <Form.TextArea - name='description' - label='LeĂrĂĄs:' - placeholder='RĂśvid leĂrĂĄs' + name="description" + label="LeĂrĂĄs:" + placeholder="RĂśvid leĂrĂĄs" value={description} onChange={(e) => this.props.writeEvent(e)} /> <DateTimeInput - name='date' - label='DĂĄtum:' - dateFormat='YYYY-MM-DD' - placeholder='Date' + name="date" + label="DĂĄtum:" + dateFormat="YYYY-MM-DD" + placeholder="Date" value={this.state.date} - iconPosition='left' + iconPosition="left" onChange={this.handleChange} /> </Form> @@ -79,26 +79,24 @@ Alkalom hozzĂĄadĂĄsa <Modal.Actions> <Button inverted - color='red' + color="red" onClick={() => { this.setState({ showModal: false }); this.props.clearWrite(); }} > - <Icon name='remove' /> + <Icon name="remove" /> Cancel </Button> <Button inverted - color='green' + color="green" onClick={() => { this.props.addEvent(this.props.newEvent); this.setState({ showModal: false, date: '' }); }} > - <Icon name='checkmark' /> - {' '} -Add + <Icon name="checkmark" /> Add </Button> </Modal.Actions> </Modal> @@ -109,5 +107,8 @@ Add const mapStateToProps = ({ events: { newEvent } }) => ({ newEvent }); export default connect(mapStateToProps, { - writeEvent, addEvent, eventDate, clearWrite, + writeEvent, + addEvent, + eventDate, + clearWrite, })(AddEventForm); diff --git a/src/components/forms/AddNewsForm.js b/src/components/forms/AddNewsForm.js index 4de1fb7..31388f2 100644 --- a/src/components/forms/AddNewsForm.js +++ b/src/components/forms/AddNewsForm.js @@ -1,10 +1,8 @@ +import { Button, Form, Icon, Input, Modal, TextArea } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Modal, Button, Form, Input, TextArea, Icon, -} from 'semantic-ui-react'; -import { connect } from 'react-redux'; +import { clearWrite, postNews, writeNews } from '../../actions/news'; -import { postNews, writeNews, clearWrite } from '../../actions/news'; +import { connect } from 'react-redux'; class AddNewsForm extends Component { constructor(props) { @@ -20,57 +18,59 @@ class AddNewsForm extends Component { return ( <Modal open={this.state.showModal} - trigger={( + trigger={ <Button - size='big' - onClick={() => { this.setState({ showModal: true }); }} + 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> <Form> <Form.Field control={Input} - label='Title' - name='title' + label="Title" + name="title" onChange={(e) => this.props.writeNews(e)} value={title} - placeholder='Title' + placeholder="Title" /> <Form.Field control={TextArea} - label='Text' - name='text' + label="Text" + name="text" onChange={(e) => this.props.writeNews(e)} value={text} - placeholder='Tell us what you want...' + placeholder="Tell us what you want..." /> </Form> </Modal.Content> <Modal.Actions> <Button inverted - color='red' - onClick={() => { this.setState({ showModal: false }); }} + color="red" + onClick={() => { + this.setState({ showModal: false }); + }} > - <Icon name='remove' /> + <Icon name="remove" /> Cancel </Button> <Button inverted - color='green' + color="green" onClick={() => { 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> @@ -80,4 +80,6 @@ Add const mapStateToProps = ({ newNews, user }) => ({ newNews, user }); -export default connect(mapStateToProps, { postNews, writeNews, clearWrite })(AddNewsForm); +export default connect(mapStateToProps, { postNews, writeNews, clearWrite })( + AddNewsForm +); diff --git a/src/components/forms/AddSolutionForm.js b/src/components/forms/AddSolutionForm.js index 8ab475f..9a241a2 100644 --- a/src/components/forms/AddSolutionForm.js +++ b/src/components/forms/AddSolutionForm.js @@ -26,7 +26,6 @@ import './Forms.css'; import ConfirmModal from './ConfirmModal'; import { customMessage } from '../pages/Homework'; - const allowedFileTypes = [ 'image/jpeg', 'image/png', @@ -46,16 +45,16 @@ class AddSolutionForm extends Component { } render() { - const { - name, description, file, - } = this.props.newSolution; + const { name, description, file } = this.props.newSolution; const task = this.props.taskid; - const thisTaskSolution = this.props.homeworks.solutions - .filter((solution) => solution.task === task); - const thisTaskDocument = this.props.homeworks.documents - .filter((document) => document.solution === thisTaskSolution[0]?.id); + const thisTaskSolution = this.props.homeworks.solutions.filter( + (solution) => solution.task === task + ); + const thisTaskDocument = this.props.homeworks.documents.filter( + (document) => document.solution === thisTaskSolution[0]?.id + ); const lastName = thisTaskDocument[0]?.name; const lastDesc = thisTaskDocument[0]?.description; @@ -72,197 +71,229 @@ class AddSolutionForm extends Component { open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={( + trigger={ <button - type='button' - id='task' + type="button" + id="task" onClick={() => { this.setState({ showModal: true }); }} > - <Icon name='external' /> + <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>))} + <Header as="h5">Feladat leĂrĂĄsa:</Header> + {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' download>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' download>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...' + {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" download> + 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" download> + 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> - <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> - )} + </Form.Field> + </Form> + )} </Modal.Content> <Modal.Actions> <Button inverted - color='red' + color="red" onClick={() => { this.setState({ showModal: false }); this.props.clearWrite(); }} > - <Icon name='remove' /> - {' '} -MĂŠgse + <Icon name="remove" /> MĂŠgse </Button> - {this.props.multiple - ? ( - <ConfirmModal - button={( - <Button - disabled={ - !name || !description - || (!file ? false : !allowedFileTypes.includes(file.type) - || file.size > (maxFileSize) * (1024 ** 2)) + {this.props.multiple ? ( + <ConfirmModal + button={ + <Button + disabled={ + !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} + </Button> + } + text="beadod az Ăşj megoldĂĄst, ami felĂźlĂrja az elĹzĹt" + onAccept={() => { + this.setState({ + loading: true, + }); + this.props + .addSolution({ + task, + accepted, + corrected, + note, + name, + description, + file, + }) + .then( + () => { + this.setState({ + loading: false, + showModal: false, + }); + this.props.clearWrite(); + }, + () => { + this.setState({ + loading: false, + }); + alert('Sikertelen feltĂśltĂŠs!'); } - inverted - color='green' - > - <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, - }); - this.props.addSolution({ - task, accepted, corrected, note, name, description, file, - }).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)) - } - onClick={() => { - this.props.addSolution({ - task, accepted, corrected, note, name, description, file, - }); - this.setState({ showModal: false }); - this.props.clearWrite(); - }} - > - <Icon name='checkmark' /> - {' '} -BeadĂĄs - </Button> - )} + ); + }} + /> + ) : ( + <Button + inverted + color="green" + disabled={ + !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.setState({ showModal: false }); + this.props.clearWrite(); + }} + > + <Icon name="checkmark" /> BeadĂĄs + </Button> + )} </Modal.Actions> </Modal> ); } } -const mapStateToProps = ({ newSolution, homeworks, user }) => ({ newSolution, homeworks, user }); +const mapStateToProps = ({ newSolution, homeworks, user }) => ({ + newSolution, + homeworks, + user, +}); export default connect(mapStateToProps, { addSolution, diff --git a/src/components/forms/AddTaskForm.js b/src/components/forms/AddTaskForm.js index c8729b0..f56f4ef 100644 --- a/src/components/forms/AddTaskForm.js +++ b/src/components/forms/AddTaskForm.js @@ -1,14 +1,23 @@ -import React, { Component } from 'react'; import { - Modal, Button, Form, Input, TextArea, Icon, + Button, + Form, + Icon, + Input, + Modal, + TextArea, } from 'semantic-ui-react'; -import { connect } from 'react-redux'; -import { DateTimeInput } from 'semantic-ui-calendar-react'; -import moment from 'moment'; +import React, { Component } from 'react'; import { - addTask, writeTask, writeTaskDeadline, clearWrite, + addTask, + clearWrite, + writeTask, + writeTaskDeadline, } from '../../actions/homework'; +import { DateTimeInput } from 'semantic-ui-calendar-react'; +import { connect } from 'react-redux'; +import moment from 'moment'; + class AddTaskForm extends Component { constructor(props) { super(props); diff --git a/src/components/forms/ConfirmModal.js b/src/components/forms/ConfirmModal.js index 0fbbaac..027e3f3 100644 --- a/src/components/forms/ConfirmModal.js +++ b/src/components/forms/ConfirmModal.js @@ -1,7 +1,5 @@ +import { Button, Header, Icon, Modal } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Button, Header, Icon, Modal, -} from 'semantic-ui-react'; class ConfirmModal extends Component { constructor(props) { @@ -11,56 +9,45 @@ class ConfirmModal extends Component { }; } - close = () => this.setState({ showModal: false }) + 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 c9f8321..f07b60a 100644 --- a/src/components/forms/CorrectSolutionForm.js +++ b/src/components/forms/CorrectSolutionForm.js @@ -1,19 +1,26 @@ -import React, { Component } from 'react'; import { - Modal, Button, Icon, Checkbox, Form, TextArea, Header, + Button, + Checkbox, + Form, + Header, + Icon, + Modal, + TextArea, } from 'semantic-ui-react'; -import { connect } from 'react-redux'; +import React, { Component } from 'react'; import { - correctSolution, - writeSolution, check, - setchecktrue, clearWrite, - getSolutions, + correctSolution, getDocuments, + getSolutions, selectSolution, + setchecktrue, + writeSolution, } from '../../actions/homework'; +import { connect } from 'react-redux'; + class CorrectSolutionForm extends Component { constructor(props) { super(props); @@ -23,11 +30,10 @@ class CorrectSolutionForm extends Component { } render() { - const { - studentFullName, studentId, taskTitle, taskSolutions, - } = this.props; - const taskSolutionsProfile = taskSolutions - .filter((solution) => solution.created_by === studentId); + const { studentFullName, studentId, taskTitle, taskSolutions } = this.props; + 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) @@ -39,17 +45,13 @@ class CorrectSolutionForm extends Component { } else { fileLink = null; } - const { - corrected, - accepted, - note, - } = this.props.correction; + const { corrected, accepted, note } = this.props.correction; return ( <Modal open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={( + trigger={ <Button inverted color={this.props.color} @@ -61,108 +63,98 @@ 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>} - <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>} - <Header as='h5'>A beadott dokumentum:</Header> - {fileLink - ? <a href={fileLink} rel='noreferrer noopener' target>FĂĄjl letĂśltĂŠse</a> - : <p>Nincs fĂĄjl.</p>} - <Header as='h5'>KijavĂtĂĄs ĂĄllapotĂĄnak vĂĄltoztatĂĄsa:</Header> + <Header as="h5">A megoldĂĄs cĂme:</Header> + {relevantDocument && relevantDocument.description ? ( + <p>{relevantDocument.name}</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> + )} + <Header as="h5">A beadott dokumentum:</Header> + {fileLink ? ( + <a href={fileLink} rel="noreferrer noopener" target> + FĂĄjl letĂśltĂŠse + </a> + ) : ( + <p>Nincs fĂĄjl.</p> + )} + <Header as="h5">KijavĂtĂĄs ĂĄllapotĂĄnak vĂĄltoztatĂĄsa:</Header> <Button - color='orange' + color="orange" inverted={corrected} onClick={() => this.props.check('corrected')} > - <Checkbox - label='Nincs kijavĂtva' - checked={!corrected} - /> + <Checkbox label="Nincs kijavĂtva" checked={!corrected} /> </Button> - <Header as='h5'>ElfogadĂĄs/elutasĂtĂĄs:</Header> + <Header as="h5">ElfogadĂĄs/elutasĂtĂĄs:</Header> <Button - color='green' + color="green" inverted={!accepted} onClick={() => { this.props.check('accepted'); this.props.setchecktrue('corrected'); }} > - <Checkbox - label='ElfogadhatĂł' - checked={accepted} - /> + <Checkbox label="ElfogadhatĂł" checked={accepted} /> </Button> <Button - color='red' + color="red" inverted={accepted} onClick={() => this.props.check('accepted')} > - <Checkbox - label='Nem elfogadhatĂł' - checked={!accepted} - /> + <Checkbox label="Nem elfogadhatĂł" checked={!accepted} /> </Button> - <Header as='h5'>A feladat megoldĂĄsĂĄnak szĂśveges ĂŠrtĂŠkelĂŠse:</Header> + <Header as="h5">A feladat megoldĂĄsĂĄnak szĂśveges ĂŠrtĂŠkelĂŠse:</Header> <Form> <Form.Field control={TextArea} - name='note' + name="note" onChange={(e) => this.props.writeSolution(e)} value={note} - placeholder='Ărhatsz megjegyzĂŠst a megoldĂĄsra...' + placeholder="Ărhatsz megjegyzĂŠst a megoldĂĄsra..." /> </Form> </Modal.Content> <Modal.Actions> <Button inverted - color='red' + color="red" onClick={() => { this.setState({ showModal: false }); this.props.clearWrite(); }} > - <Icon name='remove' /> - {' '} -MĂŠgse + <Icon name="remove" /> MĂŠgse </Button> <Button inverted - color='green' + color="green" onClick={() => { this.props.correctSolution( relevantSolution.id, corrected, accepted, - note, + note ); this.setState({ showModal: false }); this.props.clearWrite(); }} > - <Icon name='checkmark' /> - {' '} -BeadĂĄs + <Icon name="checkmark" /> BeadĂĄs </Button> </Modal.Actions> </Modal> @@ -170,7 +162,11 @@ BeadĂĄs } } -const mapStateToProps = ({ homeworks, correction, user }) => ({ homeworks, correction, user }); +const mapStateToProps = ({ homeworks, correction, user }) => ({ + homeworks, + correction, + user, +}); export default connect(mapStateToProps, { correctSolution, diff --git a/src/components/forms/EditNewsForm.js b/src/components/forms/EditNewsForm.js index 9d6035c..05b013a 100644 --- a/src/components/forms/EditNewsForm.js +++ b/src/components/forms/EditNewsForm.js @@ -1,12 +1,10 @@ +import { Button, Form, Icon, Input, Modal, TextArea } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Modal, Button, Form, Input, TextArea, Icon, -} from 'semantic-ui-react'; +import { clearWrite, editNews, writeNews } from '../../actions/news'; + import { connect } from 'react-redux'; import moment from 'moment'; -import { writeNews, editNews, clearWrite } from '../../actions/news'; - class EditNewsForm extends Component { constructor(props) { super(props); @@ -17,88 +15,83 @@ class EditNewsForm extends Component { render() { const { - id, title, text, author, last_update_by, created_at, updated_at, + 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 }); }} - size='mini' + onClick={() => { + this.setState({ showModal: true }); + }} + size="mini" > 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} + <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' + label="Title" + name="title" onChange={(e) => this.props.writeNews(e)} value={title} - placeholder='Title' + placeholder="Title" /> <Form.Field control={TextArea} - label='Text' - name='text' + label="Text" + name="text" onChange={(e) => this.props.writeNews(e)} value={text} - placeholder='Tell us what you want...' + placeholder="Tell us what you want..." /> </Form> </Modal.Content> <Modal.Actions> <Button inverted - color='red' - onClick={() => { this.setState({ showModal: false }); }} + color="red" + onClick={() => { + this.setState({ showModal: false }); + }} > - <Icon name='remove' /> - {' '} -Cancel + <Icon name="remove" /> Cancel </Button> <Button inverted - color='green' + color="green" onClick={() => { this.props.editNews({ - id, title, text, updated_by, + id, + title, + text, + updated_by, }); this.setState({ showModal: false }); this.props.clearWrite(); }} > - <Icon name='checkmark' /> - {' '} -Edit + <Icon name="checkmark" /> Edit </Button> </Modal.Actions> </Modal> @@ -109,5 +102,7 @@ Edit const mapStateToProps = ({ user, selectedNews }) => ({ user, selectedNews }); export default connect(mapStateToProps, { - editNews, writeNews, clearWrite, + editNews, + writeNews, + clearWrite, })(EditNewsForm); diff --git a/src/components/forms/EditTaskForm.js b/src/components/forms/EditTaskForm.js index 04f684c..2da54c6 100644 --- a/src/components/forms/EditTaskForm.js +++ b/src/components/forms/EditTaskForm.js @@ -1,13 +1,15 @@ +import { Button, Form, Icon, Input, Modal, TextArea } from 'semantic-ui-react'; import React, { Component } from 'react'; import { - Modal, Button, Form, Input, TextArea, Icon, -} from 'semantic-ui-react'; -import { connect } from 'react-redux'; + clearWrite, + editTask, + writeTask, + writeTaskDeadline, +} from '../../actions/homework'; + import { DateTimeInput } from 'semantic-ui-calendar-react'; +import { connect } from 'react-redux'; import moment from 'moment'; -import { - writeTask, writeTaskDeadline, editTask, clearWrite, -} from '../../actions/homework'; class EditTaskForm extends Component { constructor(props) { @@ -18,63 +20,52 @@ class EditTaskForm extends Component { } render() { - const { - id, - title, - text, - deadline, - bits, - } = this.props.selectedTask; + const { id, title, text, deadline, bits } = this.props.selectedTask; return ( <Modal open={this.state.showModal} onOpen={this.props.onClick} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={( + trigger={ <Button inverted style={{ marginRight: '2em' }} - color='orange' - onClick={() => { this.setState({ showModal: true }); }} + 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' + label="CĂm:" + name="title" onChange={(e) => this.props.writeTask(e)} value={title} - placeholder='Add meg a feladat cĂmĂŠt.' + placeholder="Add meg a feladat cĂmĂŠt." /> <Form.Field control={TextArea} - label='LeĂrĂĄs:' - name='text' + label="LeĂrĂĄs:" + name="text" onChange={(e) => this.props.writeTask(e)} value={text} - placeholder='Add meg a feladat leĂrĂĄsĂĄt...' + placeholder="Add meg a feladat leĂrĂĄsĂĄt..." /> <Form.Field control={DateTimeInput} - label='BeadĂĄsi hatĂĄridĹ (a jelenlegi idĹnĂŠl kĂŠsĹbbi idĹpont):' - name='deadline' - placeholder='BeadĂĄsi hatĂĄridĹ' - iconPosition='left' - dateTimeFormat='YYYY-MM-DDTHH:mm' + label="BeadĂĄsi hatĂĄridĹ (a jelenlegi idĹnĂŠl kĂŠsĹbbi idĹpont):" + name="deadline" + placeholder="BeadĂĄsi hatĂĄridĹ" + iconPosition="left" + dateTimeFormat="YYYY-MM-DDTHH:mm" onChange={(e, { name, value }) => { this.props.writeTaskDeadline({ name, value }); }} @@ -82,36 +73,35 @@ nevĹą feladat mĂłdosĂtĂĄsa: /> <Form.Field control={Input} - type='number' - label='Bitek szĂĄma:' - name='bits' + type="number" + label="Bitek szĂĄma:" + name="bits" onChange={(e) => this.props.writeTask(e)} value={bits} - placeholder='Add meg a feladatĂŠrt kaphatĂł bitek szĂĄmĂĄt ...' + placeholder="Add meg a feladatĂŠrt kaphatĂł bitek szĂĄmĂĄt ..." /> </Form> </Modal.Content> <Modal.Actions> <Button inverted - color='red' + color="red" onClick={() => { this.setState({ showModal: false }); this.props.clearWrite(); }} > - <Icon name='remove' /> - {' '} -MĂŠgse + <Icon name="remove" /> MĂŠgse </Button> <Button inverted - color='green' + 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({ @@ -125,9 +115,7 @@ MĂŠgse 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/Forms.css b/src/components/forms/Forms.css index a878909..7cd9fdd 100644 --- a/src/components/forms/Forms.css +++ b/src/components/forms/Forms.css @@ -1,4 +1,5 @@ -#task, #tasknote{ +#task, +#tasknote { border: none; background-color: inherit; color: teal; @@ -8,7 +9,8 @@ color: black; } -#task:hover, #tasknote:hover { +#task:hover, +#tasknote:hover { color: red; cursor: pointer; } diff --git a/src/components/forms/HiddenForm.js b/src/components/forms/HiddenForm.js index 200c34e..63311a0 100644 --- a/src/components/forms/HiddenForm.js +++ b/src/components/forms/HiddenForm.js @@ -1,15 +1,16 @@ 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> + <div style={{ marginBottom: 0, fontWeight: this.props.fontWeight }}> + {this.props.label} + </div> <Segment style={{ marginTop: 0 }}> - <div> - {this.props.value} - </div> + <div>{this.props.value}</div> </Segment> </div> ); diff --git a/src/components/forms/InfoModal.js b/src/components/forms/InfoModal.js index e3d23d8..8ef3f29 100644 --- a/src/components/forms/InfoModal.js +++ b/src/components/forms/InfoModal.js @@ -1,7 +1,5 @@ +import { Button, Header, Icon, Modal } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Button, Header, Icon, Modal, -} from 'semantic-ui-react'; class InfoModal extends Component { constructor(props) { @@ -11,41 +9,37 @@ class InfoModal extends Component { }; } - close = () => this.setState({ showModal: false }) + 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 9d766c5..ad7cc50 100644 --- a/src/components/forms/SolutionDetailsForm.js +++ b/src/components/forms/SolutionDetailsForm.js @@ -1,15 +1,12 @@ +import './Forms.css'; + +import { Button, Divider, Header, Icon, Modal } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Modal, Button, Header, Icon, Divider, -} from 'semantic-ui-react'; -import { connect } from 'react-redux'; +import { getDocuments, getSolutions } from '../../actions/homework'; + import CorrectSolutionForm from './CorrectSolutionForm'; +import { connect } from 'react-redux'; import { customMessage } from '../pages/Homework'; -import './Forms.css'; -import { - getSolutions, - getDocuments, -} from '../../actions/homework'; class SolutionDetailsForm extends Component { constructor(props) { @@ -20,8 +17,9 @@ 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 = []; @@ -29,15 +27,20 @@ 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) { noSubmitStudents.push(profile); - } else if (profileSolutions[profileSolutions.length - 1].corrected === false) { + } else if ( + profileSolutions[profileSolutions.length - 1].corrected === false + ) { waitForCorrectionStudents.push(profile); - } else if (profileSolutions[profileSolutions.length - 1].accepted === false) { + } else if ( + profileSolutions[profileSolutions.length - 1].accepted === false + ) { noAcceptStudents.push(profile); } else { acceptedStudents.push(profile); @@ -52,95 +55,105 @@ class SolutionDetailsForm extends Component { open={this.state.showModal} closeOnDimmerClick onClose={() => this.setState({ showModal: false })} - trigger={( + trigger={ <button - type='button' - id='task' + type="button" + id="task" onClick={() => { this.setState({ showModal: true }); this.props.getSolutions(); this.props.getDocuments(); }} > - <Icon name='external' /> + <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>))} + <Header as="h3">A feladat leĂrĂĄsa:</Header> + {this.props.taskdesc.split('\n').map((s) => ( + <p key={Math.random()}>{s}</p> + ))} <Divider /> - <Header as='h3'>Nem ĂŠrkezett mĂŠg megoldĂĄs:</Header> + <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> - ))} + <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> + <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) => ( - <CorrectSolutionForm - key={Math.random()} - color='orange' - studentName={student.nick} - studentFullName={student.full_name} - studentId={student.id} - taskTitle={this.props.tasktitle} - taskSolutions={taskSolutions} - /> - ))} + <CorrectSolutionForm + key={Math.random()} + color="orange" + studentName={student.nick} + studentFullName={student.full_name} + studentId={student.id} + 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> + <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) => ( - <CorrectSolutionForm - key={Math.random()} - color='red' - studentName={student.nick} - studentFullName={student.full_name} - studentId={student.id} - taskTitle={this.props.tasktitle} - taskSolutions={taskSolutions} - /> - ))} + <CorrectSolutionForm + key={Math.random()} + color="red" + studentName={student.nick} + studentFullName={student.full_name} + studentId={student.id} + taskTitle={this.props.tasktitle} + taskSolutions={taskSolutions} + /> + ))} <Divider /> - <Header as='h3'>Elfogadva (A nĂŠvre kattintva mĂłdosĂthatĂł a javĂtĂĄs):</Header> + <Header as="h3"> + Elfogadva (A nĂŠvre kattintva mĂłdosĂthatĂł a javĂtĂĄs): + </Header> {acceptedStudents.length === 0 ? customMessage(noStudentText) : acceptedStudents.map((student) => ( - <CorrectSolutionForm - key={Math.random()} - color='green' - studentName={student.nick} - studentFullName={student.full_name} - studentId={student.id} - taskTitle={this.props.tasktitle} - taskSolutions={taskSolutions} - /> - ))} + <CorrectSolutionForm + key={Math.random()} + color="green" + studentName={student.nick} + studentFullName={student.full_name} + studentId={student.id} + taskTitle={this.props.tasktitle} + taskSolutions={taskSolutions} + /> + ))} </Modal.Content> <Modal.Actions> <Button inverted - color='green' + color="green" onClick={() => { this.setState({ showModal: false }); }} > - <Icon name='checkmark' /> - {' '} -KĂŠsz + <Icon name="checkmark" /> KĂŠsz </Button> </Modal.Actions> </Modal> @@ -151,5 +164,6 @@ KĂŠsz const mapStateToProps = ({ homeworks, user }) => ({ homeworks, user }); export default connect(mapStateToProps, { - getSolutions, getDocuments, + getSolutions, + getDocuments, })(SolutionDetailsForm); diff --git a/src/components/pages/ApplicantProfile.js b/src/components/pages/ApplicantProfile.js index 0c7ec84..92684b8 100644 --- a/src/components/pages/ApplicantProfile.js +++ b/src/components/pages/ApplicantProfile.js @@ -1,10 +1,9 @@ +import { Button, Container, Header, Item, Label } from 'semantic-ui-react'; import React, { Component } from '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'; +import { connect } from 'react-redux'; const groupTypes = { HAT: { @@ -36,18 +35,24 @@ class ApplicantProfile extends Component { render() { const { - id, signed, role, full_name, - nick, motivation_about, motivation_exercise, - motivation_profession, groups, + 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' }}> - <Header as='h2'>{full_name}</Header> + <Container textAlign="center" style={{ paddingBottom: '2em' }}> + <Header as="h2">{full_name}</Header> <Item.Meta>{nick}</Item.Meta> - <Header as='h2'> + <Header as="h2"> {groups?.map((group) => ( <Label color={groupTypes[group].color}> {groupTypes[group].name} @@ -56,81 +61,83 @@ class ApplicantProfile extends Component { </Header> </Container> <Item.Description> - <Container textAlign='justified' style={{ padding: '1em' }}> - <Header as='h3'>MagamrĂłl, eddigi tevĂŠkenysĂŠgem:</Header> + <Container textAlign="justified" style={{ padding: '1em' }}> + <Header as="h3">MagamrĂłl, eddigi tevĂŠkenysĂŠgem:</Header> <p> - {motivation_about - ?.split ('\n').map ((item, i) => <div key={i}>{item}</div>)} + {motivation_about?.split('\n').map((item, i) => ( + <div key={i}>{item}</div> + ))} </p> - <Header as='h3'>Szakmai motivĂĄciĂł:</Header> + <Header as="h3">Szakmai motivĂĄciĂł:</Header> <p> - {motivation_profession - ?.split ('\n').map ((item, i) => <div key={i}>{item}</div>)} + {motivation_profession?.split('\n').map((item, i) => ( + <div key={i}>{item}</div> + ))} </p> - <Header as='h3'>Feladatok megoldĂĄsa:</Header> + <Header as="h3">Feladatok megoldĂĄsa:</Header> <p> - {motivation_exercise - ?.split ('\n').map ((item, i) => <div key={i}>{item}</div>)} + {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>} + <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> + )} </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> ); } } -const mapStateToProps = ({ trainees: { selectedProfile } }) => ({ selectedProfile }); +const mapStateToProps = ({ trainees: { selectedProfile } }) => ({ + selectedProfile, +}); -export default connect(mapStateToProps, { getSelectedProfile, setStatus })(ApplicantProfile); +export default connect(mapStateToProps, { getSelectedProfile, setStatus })( + ApplicantProfile +); diff --git a/src/components/pages/Applications.js b/src/components/pages/Applications.js index 6a372ba..50a5954 100644 --- a/src/components/pages/Applications.js +++ b/src/components/pages/Applications.js @@ -1,11 +1,10 @@ +import { Button, Container, Label, Table } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; -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'; +import { Link } from 'react-router-dom'; +import { connect } from 'react-redux'; const role = [ { @@ -41,98 +40,81 @@ class Applications extends Component { } renderApplicants(format) { - 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'> - <Link to={`applicant/${profile.id}`}> - {profile.full_name} - </Link> + 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"> + <Link to={`applicant/${profile.id}`}>{profile.full_name}</Link> + </Table.Cell> + {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> - { 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 - )); + )} + </Table.Row> + ) : null + ); } renderNotApplicants(format) { - return this.props.profiles.map((profile) => ( - profile.signed === false && profile.role !== 'Staff' - ? ( - <Table.Row key={profile.id}> - <Table.Cell textAlign='center'> - <Link to={`applicant/${profile.id}`}> - {profile.full_name} - </Link> + return this.props.profiles.map((profile) => + 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 : ( + <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> - { 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 - )); + )} + </Table.Row> + ) : null + ); } renderTable(format) { return ( - <Table color='blue' unstackable celled selectable compact> + <Table color="blue" unstackable celled selectable compact> <Table.Header> <Table.Row> - <Table.HeaderCell textAlign='center'> + <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) => 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} - + {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> @@ -144,33 +126,27 @@ fĹ ); } - render() { return ( <Container - textAlign='center' + 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> ); } } -const mapStateToProps = ({ trainees: { profiles }, user }) => ({ profiles, user }); +const mapStateToProps = ({ trainees: { profiles }, user }) => ({ + profiles, + user, +}); -export default connect(mapStateToProps, { getProfiles, setStatus })(Applications); +export default connect(mapStateToProps, { getProfiles, setStatus })( + Applications +); diff --git a/src/components/pages/EventDetail.js b/src/components/pages/EventDetail.js index eb215cf..a81ade0 100644 --- a/src/components/pages/EventDetail.js +++ b/src/components/pages/EventDetail.js @@ -1,25 +1,31 @@ -import React, { Component } from 'react'; import { - Container, - Item, Button, Comment, + Container, + Divider, Form, Header, - Table, + Item, Segment, - Divider, + Table, } from 'semantic-ui-react'; -import { connect } from 'react-redux'; -import moment from 'moment'; -import { - getEventById, getTrainees, visitorChange, submitVisitors, -} from '../../actions/statistics'; +import React, { Component } from 'react'; import { - getNotesByEvent, writeNote, clearWrite, postEventNote, + clearWrite, + getNotesByEvent, + postEventNote, + writeNote, } from '../../actions/notes'; -import TraineeTableRow from './EventDetailTableRow'; +import { + getEventById, + getTrainees, + submitVisitors, + visitorChange, +} from '../../actions/statistics'; +import TraineeTableRow from './EventDetailTableRow'; +import { connect } from 'react-redux'; +import moment from 'moment'; class EventDetail extends Component { constructor(props) { @@ -35,24 +41,21 @@ class EventDetail extends Component { this.props.getNotesByEvent(this.props.match.params.id); } - renderTrainees() { const event = this.props.selectedEvent; return this.props.trainees?.map((item) => { - 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 + 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; }); } @@ -62,15 +65,15 @@ class EventDetail extends Component { <Segment> <Item> <Divider style={{ fontSize: '2em' }} horizontal> - <Header as='h1'> + <Header as="h1"> {name} <Item.Header style={{ fontSize: '0.6em' }}> {moment(date).format('LL')} </Item.Header> </Header> </Divider> - <Container textAlign='justified'> - <Item.Header as='h3'>LeĂrĂĄs</Item.Header> + <Container textAlign="justified"> + <Item.Header as="h3">LeĂrĂĄs</Item.Header> <Item.Content>{description}</Item.Content> </Container> </Item> @@ -90,9 +93,7 @@ class EventDetail extends Component { <Comment.Metadata> {moment(note.created_at).format('LL')} </Comment.Metadata> - <Comment.Text> - {note.note} - </Comment.Text> + <Comment.Text>{note.note}</Comment.Text> </Comment.Content> </Comment> </Segment> @@ -107,48 +108,41 @@ class EventDetail extends Component { const note = this.props.actualNote; return ( <Container style={{ paddingTop: '1em', paddingBottom: '7em' }}> - <Container textAlign='center'> - { this.props.selectedEvent && this.props.trainees + <Container textAlign="center"> + {this.props.selectedEvent && this.props.trainees ? this.renderEvent() : ''} </Container> <Table celled unstackable> <Table.Header> - <Table.Row textAlign='center'> + <Table.Row textAlign="center"> <Table.HeaderCell>NĂŠv</Table.HeaderCell> <Table.HeaderCell>Jelen volt</Table.HeaderCell> <Table.HeaderCell>MegjegyzĂŠsek</Table.HeaderCell> </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() - : ''} + <Header dividing>MegjegyzĂŠsek</Header> + {this.props.eventNotes ? this.renderComments() : ''} <Form reply> <Form.TextArea value={note.note} @@ -162,9 +156,9 @@ KĂŠsz }); this.props.clearWrite(); }} - content='MegjegyzĂŠs hozzĂĄadĂĄsa' - labelPosition='left' - icon='edit' + content="MegjegyzĂŠs hozzĂĄadĂĄsa" + labelPosition="left" + icon="edit" primary /> </Form> @@ -179,7 +173,10 @@ const mapStateToProps = ({ events: { selectedEvent }, trainees: { trainees }, }) => ({ - eventNotes, selectedEvent, trainees, actualNote, + eventNotes, + selectedEvent, + trainees, + actualNote, }); export default connect(mapStateToProps, { diff --git a/src/components/pages/EventDetailTableRow.js b/src/components/pages/EventDetailTableRow.js index b81b6be..815a280 100644 --- a/src/components/pages/EventDetailTableRow.js +++ b/src/components/pages/EventDetailTableRow.js @@ -1,17 +1,18 @@ -import React, { Component } from 'react'; import { + Button, Comment, - Table, + Dropdown, + Form, + Grid, Icon, Popup, - Grid, - Button, - Form, - Dropdown, + Table, } from 'semantic-ui-react'; +import React, { Component } from 'react'; +import { clearWrite, postEventNote, writeNote } from '../../actions/notes'; +import { submitVisitors, visitorChange } from '../../actions/statistics'; + import { connect } from 'react-redux'; -import { visitorChange, submitVisitors } from '../../actions/statistics'; -import { writeNote, clearWrite, postEventNote } from '../../actions/notes'; const visitStates = [ { @@ -38,9 +39,11 @@ class TraineeTableRow extends Component { } // Hides and shows the Add and More popup - triggerAdd = () => this.setState({ ...this.state, showAddPopup: !this.state.showAddPopup }) + triggerAdd = () => + this.setState({ ...this.state, showAddPopup: !this.state.showAddPopup }); - triggerMore = () => this.setState({ ...this.state, showMorePopup: !this.state.showMorePopup }) + triggerMore = () => + this.setState({ ...this.state, showMorePopup: !this.state.showMorePopup }); render() { const note = this.props.actualNote; @@ -50,111 +53,92 @@ class TraineeTableRow extends Component { let visitorStatusIcon; let visitorStatusDropdown; if (isVisitor) { - visitorStatusIcon = <Icon color='green' name='checkmark' />; + visitorStatusIcon = <Icon color="green" name="checkmark" />; visitorStatusDropdown = 'Visitor'; } else if (isAbsent) { - visitorStatusIcon = <Icon color='orange' name='minus' />; + visitorStatusIcon = <Icon color="orange" name="minus" />; visitorStatusDropdown = 'Absent'; } else { - visitorStatusIcon = <Icon color='red' name='cancel' />; + visitorStatusIcon = <Icon color="red" name="cancel" />; visitorStatusDropdown = 'No'; } return ( <Table.Row> - <Table.Cell textAlign='center'> - {trainee.full_name} - </Table.Cell> + <Table.Cell textAlign="center">{trainee.full_name}</Table.Cell> {/* Show and change Visitors status */} - {!this.props.edit - ? ( - <Table.Cell textAlign='center'> - { - visitorStatusIcon - } - </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> - )} + {!this.props.edit ? ( + <Table.Cell textAlign="center">{visitorStatusIcon}</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> + <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} + </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} + /> + } + content={notes.map((oneNote) => ( <Comment.Content> <Comment.Author> - <b> - {notes[0].created_by_name} -: - </b> + <b>{oneNote.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.Text>{oneNote.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} /> - } - content={notes.map((oneNote) => ( - <Comment.Content> - <Comment.Author> - <b> - {oneNote.created_by_name} - : - </b> - </Comment.Author> - <Comment.Text> - {oneNote.note} - </Comment.Text> - </Comment.Content> - ))} - /> - ) - : null} + ))} + /> + ) : null} <Popup basic - trigger={ - <Button icon='plus' onClick={this.triggerAdd} /> - } + trigger={<Button icon="plus" onClick={this.triggerAdd} />} open={this.state.showAddPopup} - content={( + content={ <Form reply> <Form.TextArea value={note.note} @@ -171,12 +155,12 @@ class TraineeTableRow extends Component { }); this.props.clearWrite(); }} - content='MegjegyzĂŠs hozzĂĄadĂĄsa' - labelPosition='left' - icon='edit' + content="MegjegyzĂŠs hozzĂĄadĂĄsa" + labelPosition="left" + icon="edit" /> </Form> - )} + } /> </Grid.Column> </Grid.Row> @@ -188,11 +172,10 @@ class TraineeTableRow extends Component { } 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 f11b673..11df399 100644 --- a/src/components/pages/Events.js +++ b/src/components/pages/Events.js @@ -1,10 +1,11 @@ +import { Button, Container, Table } from 'semantic-ui-react'; import React, { Component } from 'react'; -import moment from 'moment'; +import { deleteEvent, getStaffEvents } from '../../actions/statistics'; + +import AddEventForm from '../forms/AddEventForm'; import { Link } from 'react-router-dom'; -import { Container, Table, Button } from 'semantic-ui-react'; import { connect } from 'react-redux'; -import { getStaffEvents, deleteEvent } from '../../actions/statistics'; -import AddEventForm from '../forms/AddEventForm'; +import moment from 'moment'; class Events extends Component { UNSAFE_componentWillMount() { @@ -14,25 +15,21 @@ class Events extends Component { renderEvents() { 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 textAlign="center"> + <Link to={`events/${event.id}`}>{event.name}</Link> </Table.Cell> - <Table.Cell textAlign='center'> + <Table.Cell textAlign="center"> {moment(event.date).format('LL')} </Table.Cell> - <Table.Cell textAlign='center'> - {event.visitor_number} - </Table.Cell> - <Table.Cell textAlign='center'> + <Table.Cell textAlign="center">{event.visitor_number}</Table.Cell> + <Table.Cell textAlign="center"> <Button onClick={() => this.props.deleteEvent(event)} - color='red' + color="red" compact - size='small' + size="small" > - TĂśrlĂŠs + TĂśrlĂŠs </Button> </Table.Cell> </Table.Row> @@ -41,26 +38,32 @@ class Events extends Component { render() { return ( - <Container textAlign='center'> + <Container textAlign="center"> <div style={{ overflowX: 'scroll' }}> <Table - color='blue' + color="blue" unstackable celled selectable compact - size='small' + size="small" > <Table.Header> <Table.Row> - <Table.HeaderCell textAlign='center'>Alkalom neve</Table.HeaderCell> - <Table.HeaderCell textAlign='center'>DĂĄtum</Table.HeaderCell> - <Table.HeaderCell textAlign='center'>Jelen voltak</Table.HeaderCell> + <Table.HeaderCell textAlign="center"> + Alkalom neve + </Table.HeaderCell> + <Table.HeaderCell textAlign="center">DĂĄtum</Table.HeaderCell> + <Table.HeaderCell textAlign="center"> + Jelen voltak + </Table.HeaderCell> <Table.HeaderCell /> </Table.Row> </Table.Header> <Table.Body> - {this.props.events ? this.renderEvents() : 'Nincs mĂŠg alkalom beĂrva'} + {this.props.events + ? this.renderEvents() + : 'Nincs mĂŠg alkalom beĂrva'} </Table.Body> </Table> </div> @@ -73,4 +76,6 @@ class Events extends Component { const mapStateToProps = ({ events: { events }, user }) => ({ events, user }); -export default connect(mapStateToProps, { getStaffEvents, deleteEvent })(Events); +export default connect(mapStateToProps, { getStaffEvents, deleteEvent })( + Events +); diff --git a/src/components/pages/Groups.js b/src/components/pages/Groups.js index fadf91b..a4915e0 100644 --- a/src/components/pages/Groups.js +++ b/src/components/pages/Groups.js @@ -1,11 +1,11 @@ -import React, { Component } from 'react'; -import { Container, Header, Segment } from 'semantic-ui-react'; import './Groups.css'; -import { connect } from 'react-redux'; -import GroupCard from '../extra/GroupCard'; -import { getGroups } from '../../actions/groups'; +import { Container, Header, Segment } from 'semantic-ui-react'; +import React, { Component } from 'react'; +import GroupCard from '../extra/GroupCard'; +import { connect } from 'react-redux'; +import { getGroups } from '../../actions/groups'; class Groups extends Component { UNSAFE_componentWillMount() { @@ -15,11 +15,11 @@ class Groups extends Component { render() { return ( <div> - <Segment inverted textAlign='center' vertical> + <Segment inverted textAlign="center" vertical> <Container> <Header - as='h1' - content='KĂśreink' + as="h1" + content="KĂśreink" inverted style={{ fontSize: '3em', @@ -33,10 +33,16 @@ class Groups extends Component { <Segment style={{ padding: '1em 0em 5em' }} vertical> <Container text> - { this.props.groups + {this.props.groups // eslint-disable-next-line arrow-body-style .map((item) => { - return <GroupCard key={item.id} label={item.name} value={item.description} />; + return ( + <GroupCard + key={item.id} + label={item.name} + value={item.description} + /> + ); })} </Container> </Segment> diff --git a/src/components/pages/Home.css b/src/components/pages/Home.css index 0b51da8..62be225 100644 --- a/src/components/pages/Home.css +++ b/src/components/pages/Home.css @@ -9,5 +9,3 @@ text-shadow: black 0px 0px 10px, black 0px 0px 6px; -webkit-text-fill-color: white; } - - diff --git a/src/components/pages/Home.js b/src/components/pages/Home.js index 598c1a1..bf103a1 100644 --- a/src/components/pages/Home.js +++ b/src/components/pages/Home.js @@ -1,20 +1,22 @@ -/* eslint-disable react/jsx-props-no-spreading */ -import React, { Component } from 'react'; +import './Home.css'; + import { Button, Container, + Divider, Header, Icon, - Segment, Image, - Divider, Responsive, + Segment, } from 'semantic-ui-react'; -import { connect } from 'react-redux'; -import Slider from 'react-slick'; -import { Link } from 'react-router-dom'; -import './Home.css'; +/* eslint-disable react/jsx-props-no-spreading */ +import React, { Component } from 'react'; + import KSZKbiglogo from '../images/kszk_with_shadow.png'; +import { Link } from 'react-router-dom'; +import Slider from 'react-slick'; +import { connect } from 'react-redux'; import { getImages } from '../../actions/home'; const settings = { @@ -28,7 +30,7 @@ const settings = { slidesToScroll: 1, centerMode: true, lazyLoad: true, - initialSlide: Math.floor((Math.random() * 32) + 1), + initialSlide: Math.floor(Math.random() * 32 + 1), }; class Home extends Component { @@ -41,19 +43,17 @@ class Home extends Component { return ( <div> <Slider {...settings}> - { - this.props.images.map((image) => ( - <div key={image}> - <img src={image.image} width={imageWidth} alt='' /> - </div> - )) - } + {this.props.images.map((image) => ( + <div key={image}> + <img src={image.image} width={imageWidth} alt="" /> + </div> + ))} </Slider> - <div className='car-text-kszk'> - <Segment textAlign='center' vertical> + <div className="car-text-kszk"> + <Segment textAlign="center" vertical> <Header - as='h1' - content='ĂdvĂśzlĂźnk a' + as="h1" + content="ĂdvĂśzlĂźnk a" inverted style={{ fontSize: '3vw', @@ -62,8 +62,8 @@ class Home extends Component { }} /> <Header - as='h1' - content='KollĂŠgiumi SzĂĄmĂtĂĄstechnikai KĂśr' + as="h1" + content="KollĂŠgiumi SzĂĄmĂtĂĄstechnikai KĂśr" inverted style={{ fontSize: '3.5vw', @@ -73,8 +73,8 @@ class Home extends Component { }} /> <Header - as='h1' - content='ĂşjonckĂŠpzĂŠsĂŠnek weboldalĂĄn!' + as="h1" + content="ĂşjonckĂŠpzĂŠsĂŠnek weboldalĂĄn!" inverted style={{ fontSize: '3vw', @@ -84,13 +84,13 @@ class Home extends Component { }} /> <Image - verticalAlign='middle' + verticalAlign="middle" src={KSZKbiglogo} style={{ marginTop: '1vw', width: '17%' }} /> <Header - as='h1' - content='Szeretettel vĂĄrunk a KSZKĂŠpzĂŠsre!' + as="h1" + content="Szeretettel vĂĄrunk a KSZKĂŠpzĂŠsre!" inverted style={{ fontSize: '3vw', @@ -100,66 +100,61 @@ 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', - }} - > - 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', - }} - > - BejelentkezĂŠs - <Icon name='right arrow' /> - </Button> - ) - } + {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', + }} + > + BejelentkezĂŠs + <Icon name="right arrow" /> + </Button> + )} </Container> </Segment> </div> </div> ); - } if (view === 1) { + } + if (view === 1) { return ( <div> <Slider {...settings}> - { - this.props.images.map((image) => ( - <div key={image}> - <img src={image.image} width={imageWidth} alt='' /> - </div> - )) - } + {this.props.images.map((image) => ( + <div key={image}> + <img src={image.image} width={imageWidth} alt="" /> + </div> + ))} </Slider> - <div className='car-text-kszk'> - <Segment textAlign='center' vertical> + <div className="car-text-kszk"> + <Segment textAlign="center" vertical> <Header - as='h1' - content='ĂdvĂśzlĂźnk a' + as="h1" + content="ĂdvĂśzlĂźnk a" inverted style={{ fontSize: '5vw', @@ -168,8 +163,8 @@ class Home extends Component { }} /> <Header - as='h1' - content='KollĂŠgiumi SzĂĄmĂtĂĄstechnikai KĂśr' + as="h1" + content="KollĂŠgiumi SzĂĄmĂtĂĄstechnikai KĂśr" inverted style={{ fontSize: '6vw', @@ -179,8 +174,8 @@ class Home extends Component { }} /> <Header - as='h1' - content='ĂşjonckĂŠpzĂŠsĂŠnek weboldalĂĄn!' + as="h1" + content="ĂşjonckĂŠpzĂŠsĂŠnek weboldalĂĄn!" inverted style={{ fontSize: '5vw', @@ -190,14 +185,14 @@ class Home extends Component { }} /> <Image - className='kszklogo' - verticalAlign='middle' + className="kszklogo" + verticalAlign="middle" src={KSZKbiglogo} style={{ marginTop: '1vw', width: '20%' }} /> <Header - as='h1' - content='Szeretettel vĂĄrunk a KSZKĂŠpzĂŠsre!' + as="h1" + content="Szeretettel vĂĄrunk a KSZKĂŠpzĂŠsre!" inverted style={{ fontSize: '5vw', @@ -207,44 +202,40 @@ 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', - }} - > - 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', - }} - > - BejelentkezĂŠs - <Icon name='right arrow' /> - </Button> - ) - } + {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', + }} + > + BejelentkezĂŠs + <Icon name="right arrow" /> + </Button> + )} </Container> </Segment> </div> @@ -259,70 +250,67 @@ class Home extends Component { return ( <Segment style={{ padding: '8em 0em', fontFamily: 'Arial' }} vertical> <Container text> - <Header as='h3' style={{ fontSize: '2em', fontFamily: 'Arial' }}> + <Header as="h3" style={{ fontSize: '2em', fontFamily: 'Arial' }}> Kik is vagyunk mi? </Header> <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 - 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. + 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 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' /> + <Button as={Link} size="large" to="/groups"> + 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' }}> + <Divider as="h4" className="header" style={{ margin: '3em 0em' }} /> + <Header as="h3" style={{ fontSize: '2em', fontFamily: 'Arial' }}> LehetĹsĂŠgek </Header> <p style={{ fontSize: '1.33em', fontFamily: 'Arial' }}> A KSZK a lehetĹsĂŠgek tĂĄrhĂĄza, a hely ahol Te â leendĹ mĂŠrnĂśk â minden terĂźleten kiprĂłbĂĄlhatod, tovĂĄbbkĂŠpezheted magad. NĂĄlunk - kibontakoztathatod kreativitĂĄsod, tapasztalatot, mĂŠrnĂśki - szemlĂŠletet szerezhetsz, mikĂśzben az Ăşn. soft skill-jeidet is - fejlesztheted. Ha szĂĄmodra a szakma hivatĂĄs, ha szeretsz Ăşj - dolgokat alkotni vagy csak jĂł tĂĄrsasĂĄgra vĂĄgysz, a legjobb helyre - kerĂźltĂŠl. A reszort kĂśrei a szakma egy-egy meghatĂĄrozĂł terĂźletĂŠvel - foglalkoznak a fejlesztĂŠs ĂŠs ĂźzemeltetĂŠs terĂźletĂŠn. + kibontakoztathatod kreativitĂĄsod, tapasztalatot, mĂŠrnĂśki szemlĂŠletet + szerezhetsz, mikĂśzben az Ăşn. soft skill-jeidet is fejlesztheted. Ha + szĂĄmodra a szakma hivatĂĄs, ha szeretsz Ăşj dolgokat alkotni vagy csak + jĂł tĂĄrsasĂĄgra vĂĄgysz, a legjobb helyre kerĂźltĂŠl. A reszort kĂśrei a + szakma egy-egy meghatĂĄrozĂł terĂźletĂŠvel foglalkoznak a fejlesztĂŠs ĂŠs + ĂźzemeltetĂŠs terĂźletĂŠn. </p> - <Divider as='h4' className='header' style={{ margin: '3em 0em' }} /> - <Header as='h3' style={{ fontSize: '2em', fontFamily: 'Arial' }}> + <Divider as="h4" className="header" style={{ margin: '3em 0em' }} /> + <Header as="h3" style={{ fontSize: '2em', fontFamily: 'Arial' }}> 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 + 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. + 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' }} /> - <Segment inverted color='red' tertiary> - <Header as='h3' style={{ fontSize: '2em', fontFamily: 'Arial' }}> + <Divider as="h4" className="header" style={{ margin: '3em 0em' }} /> + <Segment inverted color="red" tertiary> + <Header as="h3" style={{ fontSize: '2em', fontFamily: 'Arial' }}> KorlĂĄtos fĂŠrĹhely </Header> <p style={{ fontSize: '1.33em', fontFamily: 'Arial' }}> - ĂltalĂĄnossĂĄgban elmondhatĂł, hogy a KSZK tagjai rengeteg dologgal foglalkoznak - a hĂŠtkĂśznapjaik sorĂĄn, hogy minden informatikai rendszer Ăşgy mĹąkĂśdjĂśn - a kollĂŠgiumban, ahogy kell. Ăgy van ez velĂźnk kĂŠpzĹkkel is, emiatt - hetente csak egy kĂŠpzĂŠsalkalmat tudunk tartani. Mivel az oktatĂłterem - fĂŠrĹhelyĂŠben korlĂĄtozott, ezĂŠrt a kĂŠpzĂŠsre maximum 35 embert tudunk befogadni. + ĂltalĂĄnossĂĄgban elmondhatĂł, hogy a KSZK tagjai rengeteg dologgal + foglalkoznak a hĂŠtkĂśznapjaik sorĂĄn, hogy minden informatikai + rendszer Ăşgy mĹąkĂśdjĂśn a kollĂŠgiumban, ahogy kell. Ăgy van ez + velĂźnk kĂŠpzĹkkel is, emiatt hetente csak egy kĂŠpzĂŠsalkalmat tudunk + tartani. Mivel az oktatĂłterem fĂŠrĹhelyĂŠben korlĂĄtozott, ezĂŠrt a + kĂŠpzĂŠsre maximum 35 embert tudunk befogadni. </p> <p style={{ fontSize: '1.33em', fontFamily: 'Arial' }}> - Sajnos elĹfordulhat olyan eset, hogy valaki mĂĄr nem fĂŠr be a kĂŠpzĂŠsre, - ezĂŠrt kĂŠrĂźnk titeket, hogy ennek tudatĂĄban jelentkezzetek majd. - Ilyen esetben remĂŠljĂźk ez nem szegi kedveteket ĂŠs jĂśvĹre Ăşjra prĂłbĂĄlkoztok majd! + Sajnos elĹfordulhat olyan eset, hogy valaki mĂĄr nem fĂŠr be a + kĂŠpzĂŠsre, ezĂŠrt kĂŠrĂźnk titeket, hogy ennek tudatĂĄban + jelentkezzetek majd. Ilyen esetben remĂŠljĂźk ez nem szegi + kedveteket ĂŠs jĂśvĹre Ăşjra prĂłbĂĄlkoztok majd! </p> </Segment> </Container> @@ -334,17 +322,15 @@ class Home extends Component { return ( <div> <Responsive minWidth={600}> - <div className='car-image-kszk'> + <div className="car-image-kszk"> <div /> - { this.renderSlider(0, '120%') } + {this.renderSlider(0, '120%')} </div> - { this.renderText() } + {this.renderText()} </Responsive> <Responsive maxWidth={600}> - <div className='car-image-kszk'> - { this.renderSlider(1, '200%') } - </div> - { this.renderText() } + <div className="car-image-kszk">{this.renderSlider(1, '200%')}</div> + {this.renderText()} </Responsive> </div> ); @@ -352,7 +338,8 @@ 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 e3de25e..1a0a3d8 100644 --- a/src/components/pages/Homework.js +++ b/src/components/pages/Homework.js @@ -1,32 +1,33 @@ -/* eslint-disable no-nested-ternary */ -import React, { Component } from 'react'; import { + Button, Container, Header, - Segment, - Table, Icon, - Message, - Button, Label, + Message, + Segment, + Table, } from 'semantic-ui-react'; -import { connect } from 'react-redux'; -import moment from 'moment'; +/* eslint-disable no-nested-ternary */ +import React, { Component } from 'react'; import { - getTasks, - getSolutions, - getDocuments, addTask, - setSelectedTask, deleteTask, + getDocuments, getProfiles, + getSolutions, + getTasks, + setSelectedTask, } from '../../actions/homework'; -import AddTaskForm from '../forms/AddTaskForm'; + import AddSolutionForm from '../forms/AddSolutionForm'; -import SolutionDetailsForm from '../forms/SolutionDetailsForm'; +import AddTaskForm from '../forms/AddTaskForm'; +import ConfirmModal from '../forms/ConfirmModal'; import EditTaskForm from '../forms/EditTaskForm'; import InfoModal from '../forms/InfoModal'; -import ConfirmModal from '../forms/ConfirmModal'; +import SolutionDetailsForm from '../forms/SolutionDetailsForm'; +import { connect } from 'react-redux'; +import moment from 'moment'; // Display type for the Table Semantic UI component // {icon} {text} - Displayed for the student for each Task @@ -80,8 +81,9 @@ class Homework extends Component { // Returns a table style for the given task getTaskDisplayStyle(task) { - const taskSolution = this.props.homeworks.solutions - .filter((solution) => solution.task === task.id); + const taskSolution = this.props.homeworks.solutions.filter( + (solution) => solution.task === task.id + ); if (taskSolution.length === 0) { if (moment().isBefore(task.deadline)) { @@ -106,8 +108,9 @@ class Homework extends Component { // given parameters separates the active/inactive tasks and normal/staff users renderTaskList(active, staff) { const { user, homeworks } = this.props; - const profileSolutions = homeworks.solutions - .filter((solution) => solution.created_by === user.id); + const profileSolutions = homeworks.solutions.filter( + (solution) => solution.created_by === user.id + ); // Normal user if (!staff) { @@ -118,14 +121,14 @@ class Homework extends Component { <Table.Row key={task.id} warning={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.warning - } + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.warning + } positive={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive - } + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive + } negative={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative - } + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative + } > {/* Form component */} <Table.Cell> @@ -143,47 +146,53 @@ class Homework extends Component { </Table.Cell> <Table.Cell> - <Label color={ + <Label + color={ displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive ? 'green' - : moment().isAfter(task.deadline) ? 'red' - : displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative ? 'red' : null -} + : moment().isAfter(task.deadline) + ? 'red' + : displayTypes[this.getTaskDisplayStyle(task)].rowstyle + .negative + ? 'red' + : null + } > - {task.bits} - {' '} -bit + {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 - ? ( - <div> - <InfoModal - 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} - onAccept={() => {}} - /> - </div> - ) - : ''} + {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 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 + } + onAccept={() => {}} + /> + </div> + ) : ( + '' + )} </Table.Cell> </Table.Row> )); @@ -192,14 +201,8 @@ bit // Staff const deleteButton = ( - <Button - inverted - style={{ marginRight: '2em' }} - color='red' - > - <Icon name='x' /> - {' '} -TĂśrlĂŠs + <Button inverted style={{ marginRight: '2em' }} color="red"> + <Icon name="x" /> TĂśrlĂŠs </Button> ); @@ -209,14 +212,14 @@ TĂśrlĂŠs <Table.Row key={task.id} warning={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.warning - } + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.warning + } positive={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive - } + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.positive + } negative={ - displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative - } + displayTypes[this.getTaskDisplayStyle(task)].rowstyle.negative + } > {/* Form */} <Table.Cell> @@ -232,18 +235,14 @@ TĂśrlĂŠs </Table.Cell> {/* Bits */} <Table.Cell> - <Label color={null}> - {task.bits} - {' '} -bit - </Label> + <Label color={null}>{task.bits} bit</Label> </Table.Cell> {/* Admin buttons */} <Table.Cell> <EditTaskForm onClick={() => this.props.setSelectedTask(task)} /> <ConfirmModal button={deleteButton} - text='tĂśrlĂśd a kivĂĄlaszott feladatot a mĂĄr beadott megoldĂĄsokkal egyĂźtt' + text="tĂśrlĂśd a kivĂĄlaszott feladatot a mĂĄr beadott megoldĂĄsokkal egyĂźtt" onAccept={() => this.props.deleteTask(task)} /> </Table.Cell> @@ -267,17 +266,16 @@ bit <Table.Header> <Table.Row> <Table.HeaderCell> - <Icon circular name='home' /> + <Icon circular name="home" /> Feladat megnevezĂŠse / beadĂĄsa </Table.HeaderCell> <Table.HeaderCell> - <Icon circular name='calendar' /> + <Icon circular name="calendar" /> BeadĂĄsi hatĂĄridĹ </Table.HeaderCell> - <Table.HeaderCell width={2}> - </Table.HeaderCell> + <Table.HeaderCell width={2}></Table.HeaderCell> <Table.HeaderCell> - <Icon circular name='tasks' /> + <Icon circular name="tasks" /> Ăllapot </Table.HeaderCell> </Table.Row> @@ -291,17 +289,16 @@ bit <Table.Header> <Table.Row> <Table.HeaderCell> - <Icon circular name='home' /> + <Icon circular name="home" /> Feladat megnevezĂŠse / BeadĂĄsok ĂĄllapota </Table.HeaderCell> <Table.HeaderCell> - <Icon circular name='calendar' /> + <Icon circular name="calendar" /> BeadĂĄsi hatĂĄridĹ </Table.HeaderCell> - <Table.HeaderCell width={2}> - </Table.HeaderCell> + <Table.HeaderCell width={2}></Table.HeaderCell> <Table.HeaderCell> - <Icon circular name='edit' /> + <Icon circular name="edit" /> MĂłdosĂtĂĄs / TĂśrlĂŠs </Table.HeaderCell> </Table.Row> @@ -323,15 +320,18 @@ bit 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; } if (!active) { if (staff) { - headerText = 'LejĂĄrt hatĂĄridejĹą feladatok kijavĂtĂĄsa, mĂłdosĂtĂĄsa vagy tĂśrlĂŠse'; + headerText = + 'LejĂĄrt hatĂĄridejĹą feladatok kijavĂtĂĄsa, mĂłdosĂtĂĄsa vagy tĂśrlĂŠse'; } else { headerText = 'LejĂĄrt hatĂĄridejĹą feladatok'; } @@ -343,11 +343,9 @@ bit <Segment style={{ padding: '0 0 2em 0' }} vertical basic> <Container> <Header - as='h1' + as="h1" dividing - content={ - headerText - } + content={headerText} style={{ fontSize: '2em', fontWeight: 'normal', @@ -355,36 +353,30 @@ bit marginTop: '0.5em', }} /> - {noTask - ? customMessage(noTaskHeaderText, noTaskText, marginBottom, false) - : ( - <div> - {this.renderHomeworksTable(active, staff)} - </div> - )} - {!active && !staff - ? ( - <Header - as='h3' - content={( - <div> - Jelenlegi bitjeid szĂĄma: - <Label color='green' size='large'> - {this.props.user.bits} - {' '} -bit - </Label> - </div> - )} - style={{ - fontWeight: 'normal', - marginTop: '0.5em', - marginBottom: '1em', - }} - textAlign='right' - /> - ) - : null} + {noTask ? ( + customMessage(noTaskHeaderText, noTaskText, marginBottom, false) + ) : ( + <div>{this.renderHomeworksTable(active, staff)}</div> + )} + {!active && !staff ? ( + <Header + as="h3" + content={ + <div> + Jelenlegi bitjeid szĂĄma: + <Label color="green" size="large"> + {this.props.user.bits} bit + </Label> + </div> + } + style={{ + fontWeight: 'normal', + marginTop: '0.5em', + marginBottom: '1em', + }} + textAlign="right" + /> + ) : null} </Container> </Segment> ); @@ -400,15 +392,16 @@ bit {this.renderHomeworks(false, false)} </div> ); - } if (user.role === 'Staff') { + } + if (user.role === 'Staff') { return ( <div style={{ paddingBottom: '2em' }}> <Segment style={{ padding: '0 0 2em 0' }} vertical basic> <Container> <Header dividing - as='h1' - content='Ăj hĂĄzi feladat lĂŠtrehozĂĄsa' + as="h1" + content="Ăj hĂĄzi feladat lĂŠtrehozĂĄsa" style={{ fontSize: '2em', fontWeight: 'normal', @@ -430,17 +423,18 @@ bit } } -const mapStateToProps = ({ selectedTask, homeworks, user }) => ({ selectedTask, homeworks, user }); +const mapStateToProps = ({ selectedTask, homeworks, user }) => ({ + selectedTask, + homeworks, + user, +}); -export default connect( - mapStateToProps, - { - getTasks, - setSelectedTask, - getSolutions, - getDocuments, - addTask, - deleteTask, - getProfiles, - }, -)(Homework); +export default connect(mapStateToProps, { + getTasks, + setSelectedTask, + getSolutions, + getDocuments, + addTask, + deleteTask, + getProfiles, +})(Homework); diff --git a/src/components/pages/LeaderBoard.js b/src/components/pages/LeaderBoard.js index 9ae0762..d4211db 100644 --- a/src/components/pages/LeaderBoard.js +++ b/src/components/pages/LeaderBoard.js @@ -1,5 +1,6 @@ -import React, { Component } from 'react'; import { Container, Table } from 'semantic-ui-react'; +import React, { Component } from 'react'; + import { connect } from 'react-redux'; import { getTrainees } from '../../actions/statistics'; @@ -10,59 +11,49 @@ class LeaderBoard extends Component { // Every event rendered renderTraineeBits() { - 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' - ? ( + 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} - </Table.Cell> - <Table.Cell textAlign='center'> - {trainee.events_visited} - </Table.Cell> - <Table.Cell textAlign='center'> + <Table.Cell textAlign="center">{trainee.full_name}</Table.Cell> + <Table.Cell textAlign="center">{trainee.events_visited}</Table.Cell> + <Table.Cell textAlign="center"> {Number(trainee.homework_bits)} </Table.Cell> - <Table.Cell textAlign='center'> + <Table.Cell textAlign="center"> {Number(trainee.homework_bits) + trainee.events_visited} </Table.Cell> </Table.Row> - ) - : null - )); + ) : null + ); } render() { return ( - <Container textAlign='center' style={{ overflowX: 'scroll' }}> - <Table color='blue' unstackable celled selectable compact> + <Container textAlign="center" style={{ overflowX: 'scroll' }}> + <Table color="blue" unstackable celled selectable compact> <Table.Header> <Table.Row> - <Table.HeaderCell textAlign='center'> - KĂŠpzĹdĹk - </Table.HeaderCell> - <Table.HeaderCell textAlign='center'> - JelenlĂŠt - </Table.HeaderCell> - <Table.HeaderCell textAlign='center'> - Bitek - </Table.HeaderCell> - <Table.HeaderCell textAlign='center'> - Szumma - </Table.HeaderCell> + <Table.HeaderCell textAlign="center">KĂŠpzĹdĹk</Table.HeaderCell> + <Table.HeaderCell textAlign="center">JelenlĂŠt</Table.HeaderCell> + <Table.HeaderCell textAlign="center">Bitek</Table.HeaderCell> + <Table.HeaderCell textAlign="center">Szumma</Table.HeaderCell> </Table.Row> </Table.Header> <Table.Body> - {this.props.trainees - ? this.renderTraineeBits() - : ( - <Table.Row> - <Table.Cell> - Nincsenek kĂŠpzĹdĹk - </Table.Cell> - </Table.Row> - )} + {this.props.trainees ? ( + this.renderTraineeBits() + ) : ( + <Table.Row> + <Table.Cell>Nincsenek kĂŠpzĹdĹk</Table.Cell> + </Table.Row> + )} </Table.Body> </Table> </Container> @@ -70,6 +61,9 @@ class LeaderBoard extends Component { } } -const mapStateToProps = ({ trainees: { trainees }, user }) => ({ trainees, user }); +const mapStateToProps = ({ trainees: { trainees }, user }) => ({ + trainees, + user, +}); export default connect(mapStateToProps, { getTrainees })(LeaderBoard); diff --git a/src/components/pages/Mentors.js b/src/components/pages/Mentors.js index bc17ae4..8803e4f 100644 --- a/src/components/pages/Mentors.js +++ b/src/components/pages/Mentors.js @@ -1,7 +1,16 @@ -import React, { Component } from 'react'; import { - Container, Segment, Item, Header, Card, Label, Icon, Responsive, Image, + Card, + Container, + Header, + Icon, + Image, + Item, + Label, + Responsive, + Segment, } from 'semantic-ui-react'; +import React, { Component } from 'react'; + import { connect } from 'react-redux'; import { getMentors } from '../../actions/mentors'; @@ -16,8 +25,9 @@ class Mentors extends Component { <Card.Content style={{ padding: '0' }}> <Item.Group> <Item> - {index % 2 === 0 - ? <Item.Image size='medium' src={item.image} /> : null} + {index % 2 === 0 ? ( + <Item.Image size="medium" src={item.image} /> + ) : null} <Item.Content style={{ padding: '1rem' }}> <Item.Header>{item.name}</Item.Header> <Item.Description> @@ -25,13 +35,14 @@ class Mentors extends Component { </Item.Description> <Item.Extra> <Label> - <Icon name='mail' /> + <Icon name="mail" /> {item.email} </Label> </Item.Extra> </Item.Content> - {index % 2 === 1 - ? <Item.Image size='medium' src={item.image} /> : null} + {index % 2 === 1 ? ( + <Item.Image size="medium" src={item.image} /> + ) : null} </Item> </Item.Group> </Card.Content> @@ -45,13 +56,11 @@ class Mentors extends Component { <Image src={item.image} wrapped ui={false} /> <Card.Content> <Card.Header>{item.name}</Card.Header> - <Card.Description> - {item.text} - </Card.Description> + <Card.Description>{item.text}</Card.Description> </Card.Content> <Card.Content extra> <Label> - <Icon name='mail' /> + <Icon name="mail" /> {item.email} </Label> </Card.Content> @@ -62,11 +71,11 @@ class Mentors extends Component { render() { return ( <div> - <Segment inverted textAlign='center' vertical> + <Segment inverted textAlign="center" vertical> <Container> <Header - as='h1' - content='Mentorok' + as="h1" + content="Mentorok" inverted style={{ fontSize: '3em', diff --git a/src/components/pages/News.css b/src/components/pages/News.css index 9a6297b..f2e0511 100644 --- a/src/components/pages/News.css +++ b/src/components/pages/News.css @@ -1,13 +1,13 @@ .news-extra { - color: grey; - font-size: 0.75em; - font-style: italic; - font-family: fantasy; - text-align: justify; + color: grey; + font-size: 0.75em; + font-style: italic; + font-family: fantasy; + text-align: justify; } .news-text { - font-size: 1.15em; - font-family: Arial, Helvetica, sans-serif; - text-align: justify; + font-size: 1.15em; + font-family: Arial, Helvetica, sans-serif; + text-align: justify; } diff --git a/src/components/pages/News.js b/src/components/pages/News.js index 0283887..a550e8d 100644 --- a/src/components/pages/News.js +++ b/src/components/pages/News.js @@ -1,18 +1,14 @@ +import './News.css'; + +import { Button, Container, Grid, Item, Segment } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Container, Segment, Item, Button, Grid, -} from 'semantic-ui-react'; -import { connect } from 'react-redux'; -import moment from 'moment'; +import { deleteNews, getNews, setSelectedNews } from '../../actions/news'; import AddNewsForm from '../forms/AddNewsForm'; -import EditNewsForm from '../forms/EditNewsForm'; - import ConfirmModal from '../forms/ConfirmModal'; - -import { getNews, deleteNews, setSelectedNews } from '../../actions/news'; - -import './News.css'; +import EditNewsForm from '../forms/EditNewsForm'; +import { connect } from 'react-redux'; +import moment from 'moment'; class News extends Component { UNSAFE_componentWillMount() { @@ -23,46 +19,38 @@ class News extends Component { return this.props.news.map((item) => ( <Item key={item.id}> <Item.Content> - <Container text textAlign='left'> - <Item.Header - style={{ fontSize: '2em', width: '100%' }} - > + <Container text textAlign="left"> + <Item.Header style={{ fontSize: '2em', width: '100%' }}> <Grid> <Grid.Column - floated='left' + floated="left" width={this.props.user.role === 'Staff' ? 12 : 16} > {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' - > - TĂśrlĂŠs - </Button> - )} - onAccept={() => this.props.deleteNews(item)} - /> - </Grid.Column> - ) - : null } + {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> + ) : null} </Grid> </Item.Header> <Item.Meta style={{ fontSize: '0.75em', fontStyle: 'italic' }}> -KĂśzzĂŠtĂŠve: + KĂśzzĂŠtĂŠve: {moment(item.created_at).format('LLLL')} </Item.Meta> - <Item.Description className='news-text' style={{ fontSize: '1em' }}> + <Item.Description className="news-text" style={{ fontSize: '1em' }}> {this.renderMultiLine(item.text)} </Item.Description> </Container> @@ -74,20 +62,16 @@ KĂśzzĂŠtĂŠve: renderMultiLine = (text) => { const strings = text.split('\n'); return strings.map((string) => <p key={Math.random()}>{string}</p>); - } + }; render() { return ( <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} - <Item.Group divided> - {this.renderNews()} - </Item.Group> + <Container text textAlign="center"> + {this.props.user.role === 'Staff' ? <AddNewsForm /> : null} + <Item.Group divided>{this.renderNews()}</Item.Group> </Container> </Segment> </div> @@ -95,7 +79,10 @@ KĂśzzĂŠtĂŠve: } } - const mapStateToProps = ({ news, user }) => ({ news, user }); -export default connect(mapStateToProps, { getNews, deleteNews, setSelectedNews })(News); +export default connect(mapStateToProps, { + getNews, + deleteNews, + setSelectedNews, +})(News); diff --git a/src/components/pages/NotFound.js b/src/components/pages/NotFound.js index b8432a9..95fff8e 100644 --- a/src/components/pages/NotFound.js +++ b/src/components/pages/NotFound.js @@ -1,17 +1,15 @@ +import { Button, Container, Header, Icon, Segment } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Button, Container, Header, Icon, Segment, -} from 'semantic-ui-react'; export default class NotFound extends Component { render() { return ( <div> - <Segment inverted textAlign='center' vertical> + <Segment inverted textAlign="center" vertical> <Container> <Header - as='h1' - content='404 - A keresett oldal nem talĂĄlhatĂł!' + as="h1" + content="404 - A keresett oldal nem talĂĄlhatĂł!" inverted style={{ fontSize: '3em', @@ -21,9 +19,9 @@ export default class NotFound extends Component { }} /> <Button - href='/' + href="/" primary - size='huge' + size="huge" style={{ fontSize: '2em', marginTop: '1em', @@ -31,7 +29,7 @@ export default class NotFound extends Component { }} > Vissza a FĹoldalra - <Icon name='right arrow' /> + <Icon name="right arrow" /> </Button> </Container> </Segment> diff --git a/src/components/pages/Presence.js b/src/components/pages/Presence.js index 1f67b2d..dfc3785 100644 --- a/src/components/pages/Presence.js +++ b/src/components/pages/Presence.js @@ -1,7 +1,8 @@ +import { Container, Icon, Table } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { Container, Table, Icon } from 'semantic-ui-react'; +import { getStaffEvents, getTrainees } from '../../actions/statistics'; + import { connect } from 'react-redux'; -import { getTrainees, getStaffEvents } from '../../actions/statistics'; class Presence extends Component { UNSAFE_componentWillMount() { @@ -11,70 +12,61 @@ class Presence extends Component { // Every event with visit status in table cells renderVisitedStatus(trainee) { - return (this.props.events.map((event) => { + return this.props.events.map((event) => { if (event.visitors.includes(trainee.id)) { return ( - <Table.Cell textAlign='center' key={Math.random()}> - <Icon color='green' name='checkmark' /> + <Table.Cell textAlign="center" key={Math.random()}> + <Icon color="green" name="checkmark" /> </Table.Cell> ); } return ( - <Table.Cell textAlign='center' key={Math.random()}> - <Icon color='red' name='cancel' /> + <Table.Cell textAlign="center" key={Math.random()}> + <Icon color="red" name="cancel" /> </Table.Cell> ); - })); + }); } // Every event rendered renderTraineesWithEvents() { - 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 - )); + 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) => ( - <Table.HeaderCell textAlign='center' key={event.id}> + 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' }}> - <Table color='blue' unstackable celled selectable compact> + <Container textAlign="center" style={{ overflowX: 'scroll' }}> + <Table color="blue" unstackable celled selectable compact> <Table.Header> <Table.Row> - <Table.HeaderCell textAlign='center'> - KĂŠpzĹdĹk - </Table.HeaderCell> - { this.renderTableHeaderEvents() } + <Table.HeaderCell textAlign="center">KĂŠpzĹdĹk</Table.HeaderCell> + {this.renderTableHeaderEvents()} </Table.Row> </Table.Header> <Table.Body> - - {this.props.trainees - ? this.renderTraineesWithEvents() - : ( - <Table.Row> - <Table.Cell> - Nincsenek kĂŠpzĹdĹk - </Table.Cell> - </Table.Row> - )} + {this.props.trainees ? ( + this.renderTraineesWithEvents() + ) : ( + <Table.Row> + <Table.Cell>Nincsenek kĂŠpzĹdĹk</Table.Cell> + </Table.Row> + )} </Table.Body> </Table> </Container> @@ -82,8 +74,12 @@ 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); +export default connect(mapStateToProps, { getTrainees, getStaffEvents })( + Presence +); diff --git a/src/components/pages/Profile.js b/src/components/pages/Profile.js index d987aa8..443ecc8 100644 --- a/src/components/pages/Profile.js +++ b/src/components/pages/Profile.js @@ -1,11 +1,10 @@ +import { Container, Divider, Dropdown, Form, Segment } from 'semantic-ui-react'; import React, { Component } from 'react'; -import { - Container, Form, Dropdown, Divider, Segment, -} from 'semantic-ui-react'; +import { groupChange, submitRegistration, textChange } from '../../actions'; + +import HiddenForm from '../forms/HiddenForm'; import { connect } from 'react-redux'; -import { textChange, submitRegistration, groupChange } from '../../actions'; import { getDeadline } from '../../actions/auth'; -import HiddenForm from '../forms/HiddenForm'; const options = [ { key: 'DT', text: 'DevTeam', value: 'DT' }, @@ -25,8 +24,15 @@ class Profile extends Component { render() { const { - nick, groups, motivationAbout, motivationProfession, - motivationExercise, signed, id, deadline, messageBefore, + nick, + groups, + motivationAbout, + motivationProfession, + motivationExercise, + signed, + id, + deadline, + messageBefore, messageAfter, } = this.props; const endDate = new Date(deadline); @@ -37,200 +43,183 @@ class Profile extends Component { 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. - 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> - 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> - 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. - Ekkor veszed ĂŠszre, hogy az alĂĄbbiakat sem ĂŠred el: - 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 - (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. - 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> - 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> - <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. - Ekkor veszed ĂŠszre, hogy az alĂĄbbiakat sem ĂŠred el: - 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 - (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} - /> - )} + {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> + 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> + 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. Ekkor veszed + ĂŠszre, hogy az alĂĄbbiakat sem ĂŠred el: 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 + (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. 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> + 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> + <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. Ekkor veszed + ĂŠszre, hogy az alĂĄbbiakat sem ĂŠred el: 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 + (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} + /> + )} <Divider horizontal>ĂrdekelĹdĂŠs</Divider> <Dropdown fluid multiple selection - placeholder='DevTeam, ...' + placeholder="DevTeam, ..." onChange={(_, v) => this.props.groupChange(v.value)} options={options} defaultValue={groups} @@ -238,22 +227,24 @@ AlĂĄbb talĂĄlsz nĂŠhĂĄny elgondolkodtatĂł kĂŠrdĂŠst, megoldandĂł feladatot. /> <br /> <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 }, - })} + 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 }, + }) + } checked={signed} readOnly={!canEdit} style={!canEdit ? { marginBottom: '5em' } : null} /> - {canEdit - ? ( - <Form.Button - primary - style={{ marginBottom: '5em' }} - disabled={!signed} - onClick={() => this.props.submitRegistration({ + {canEdit ? ( + <Form.Button + primary + style={{ marginBottom: '5em' }} + disabled={!signed} + onClick={() => + this.props.submitRegistration({ nick, motivationAbout, motivationProfession, @@ -261,12 +252,14 @@ AlĂĄbb talĂĄlsz nĂŠhĂĄny elgondolkodtatĂł kĂŠrdĂŠst, megoldandĂł feladatot. signed, groups, id, - })} - > - MentĂŠs - </Form.Button> - ) - : '' } + }) + } + > + MentĂŠs + </Form.Button> + ) : ( + '' + )} </Form> </Container> ); @@ -275,8 +268,15 @@ AlĂĄbb talĂĄlsz nĂŠhĂĄny elgondolkodtatĂł kĂŠrdĂŠst, megoldandĂł feladatot. const mapStateToProps = ({ user: { - nick, groups, motivationAbout, motivationProfession, - motivationExercise, signed, id, deadline, messageBefore, + nick, + groups, + motivationAbout, + motivationProfession, + motivationExercise, + signed, + id, + deadline, + messageBefore, messageAfter, }, }) => ({ @@ -293,5 +293,8 @@ const mapStateToProps = ({ }); export default connect(mapStateToProps, { - textChange, submitRegistration, groupChange, getDeadline, + textChange, + submitRegistration, + groupChange, + getDeadline, })(Profile); diff --git a/src/components/pages/Schedule.js b/src/components/pages/Schedule.js index 1ba7d60..d4dda56 100644 --- a/src/components/pages/Schedule.js +++ b/src/components/pages/Schedule.js @@ -1,15 +1,22 @@ -import React, { Component } from 'react'; +import 'moment/locale/hu'; + import { - Container, Accordion, Icon, Grid, Header, Segment, + Accordion, + Container, + Grid, + Header, + Icon, + Segment, } from 'semantic-ui-react'; +import React, { Component } from 'react'; + import { connect } from 'react-redux'; -import moment from 'moment'; -import 'moment/locale/hu'; import { getStudentEvents } from '../../actions/statistics'; +import moment from 'moment'; class Schedule extends Component { // eslint-disable-next-line react/state-in-constructor - state = { activeIndex: 0 } + state = { activeIndex: 0 }; UNSAFE_componentWillMount() { this.props.getStudentEvents(); @@ -21,7 +28,7 @@ class Schedule extends Component { const newIndex = activeIndex === index ? -1 : index; this.setState({ activeIndex: newIndex }); - } + }; render() { const { activeIndex } = this.state; @@ -36,19 +43,18 @@ class Schedule extends Component { > <h2> <Grid> - <Grid.Column floated='left' width={5} textAlign='left'> - <Icon name='calendar alternate outline' color='blue' /> - {' '} + <Grid.Column floated="left" width={5} textAlign="left"> + <Icon name="calendar alternate outline" color="blue" />{' '} {event.name} </Grid.Column> - <Grid.Column floated='right' width={8} textAlign='right'> + <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' }}> + <Segment textAlign="left" style={{ overflowWrap: 'break-word' }}> {event.description} </Segment> </Accordion.Content> @@ -57,10 +63,10 @@ class Schedule extends Component { return ( <div> - <Container textAlign='center'> + <Container textAlign="center"> <Header - as='h1' - content='KĂŠpzĂŠs alkalmak' + as="h1" + content="KĂŠpzĂŠs alkalmak" style={{ fontSize: '2em', fontWeight: 'bold', @@ -72,8 +78,8 @@ class Schedule extends Component { {panels} </Accordion> <Header - as='h1' - content='TĂĄbor' + as="h1" + content="TĂĄbor" style={{ fontSize: '2em', fontWeight: 'bold', @@ -87,7 +93,6 @@ class Schedule extends Component { } } - const mapStateToProps = ({ events: { events }, user }) => ({ events, user }); export default connect(mapStateToProps, { getStudentEvents })(Schedule); diff --git a/src/components/pages/Statistics.js b/src/components/pages/Statistics.js index 57c8fa8..c7552b8 100644 --- a/src/components/pages/Statistics.js +++ b/src/components/pages/Statistics.js @@ -1,54 +1,50 @@ -import React, { Component } from 'react'; import { Container, Menu } from 'semantic-ui-react'; +import React, { Component } from 'react'; + import Events from './Events'; -import Presence from './Presence'; import LeaderBoard from './LeaderBoard'; +import Presence from './Presence'; export default class Statistics extends Component { // eslint-disable-next-line react/state-in-constructor - state = { activeItem: 'events' } + state = { activeItem: 'events' }; - handleItemClick = (e, { name }) => this.setState({ activeItem: name }) + handleItemClick = (e, { name }) => this.setState({ activeItem: name }); render() { const { activeItem } = this.state; return ( <div> <Container - textAlign='center' + textAlign="center" style={{ paddingBottom: '5em', paddingTop: '1em' }} > - <Menu - tabular - attached='top' - size='huge' - compact - > + <Menu tabular attached="top" size="huge" compact> <Menu.Item - name='events' + name="events" active={activeItem === 'events'} onClick={this.handleItemClick} > Alkalmak </Menu.Item> <Menu.Item - name='presence' + name="presence" active={activeItem === 'presence'} onClick={this.handleItemClick} > JelenlĂŠt </Menu.Item> <Menu.Item - name='leaderboard' + name="leaderboard" active={activeItem === 'leaderboard'} onClick={this.handleItemClick} > Ranglista </Menu.Item> </Menu> - { activeItem === 'events' ? <Events /> : '' } - { activeItem === 'presence' ? <Presence /> : '' } - { activeItem === 'leaderboard' ? <LeaderBoard /> : '' } + {activeItem === 'events' ? <Events /> : ''} + {activeItem === 'presence' ? <Presence /> : ''} + {activeItem === 'leaderboard' ? <LeaderBoard /> : ''} </Container> </div> ); diff --git a/src/configureStore.js b/src/configureStore.js index 9579c62..f0e4297 100644 --- a/src/configureStore.js +++ b/src/configureStore.js @@ -1,7 +1,8 @@ -import { createStore, applyMiddleware } from 'redux'; -import thunkMiddleware from 'redux-thunk'; +import { applyMiddleware, createStore } from 'redux'; + // import { createLogger } from 'redux-logger'; import rootReducer from './reducers'; +import thunkMiddleware from 'redux-thunk'; // const loggerMiddleware = createLogger(); @@ -10,8 +11,8 @@ export default function configureStore(preloadedState) { rootReducer, preloadedState, applyMiddleware( - thunkMiddleware, + thunkMiddleware // loggerMiddleware, - ), + ) ); } diff --git a/src/containers/TodoContainer.js b/src/containers/TodoContainer.js index 37420c7..1dd83de 100644 --- a/src/containers/TodoContainer.js +++ b/src/containers/TodoContainer.js @@ -2,11 +2,12 @@ /* eslint-disable import/named */ /* eslint-disable import/extensions */ import React, { Component } from 'react'; -import { connect } from 'react-redux'; + // eslint-disable-next-line import PropTypes from 'prop-types'; import Todo from '../components/Todo'; import { addTodo } from '../actions'; +import { connect } from 'react-redux'; class TodoContainer extends Component { render() { @@ -14,13 +15,11 @@ class TodoContainer extends Component { return ( <div> - { - todos.map((todo) => ( - <Todo onClick={onTodoClick} key={Math.random()}> - {todo.data} - </Todo> - )) - } + {todos.map((todo) => ( + <Todo onClick={onTodoClick} key={Math.random()}> + {todo.data} + </Todo> + ))} </div> ); } diff --git a/src/index.js b/src/index.js index 1f626c7..1667c35 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,16 @@ -import React from 'react'; -import { render } from 'react-dom'; -import { Provider } from 'react-redux'; -import { BrowserRouter as Router } from 'react-router-dom'; import 'slick-carousel/slick/slick.css'; import 'slick-carousel/slick/slick-theme.css'; import 'semantic-ui-css/semantic.min.css'; -import moment from 'moment'; -import configureStore from './configureStore'; -import App from './components/App'; + import * as serviceWorker from './registerServiceWorker'; +import App from './components/App'; +import { Provider } from 'react-redux'; +import React from 'react'; +import { BrowserRouter as Router } from 'react-router-dom'; +import configureStore from './configureStore'; +import moment from 'moment'; +import { render } from 'react-dom'; moment.locale(); @@ -21,7 +22,7 @@ render( <App /> </Router> </Provider>, - document.getElementById('root'), + document.getElementById('root') ); serviceWorker.unregister(); diff --git a/src/reducers/AddNewsReducer.js b/src/reducers/AddNewsReducer.js index 8b228db..dad05b7 100644 --- a/src/reducers/AddNewsReducer.js +++ b/src/reducers/AddNewsReducer.js @@ -1,4 +1,4 @@ -import { WRITE_NEWS, CLEAR_WRITE } from '../actions/types'; +import { CLEAR_WRITE, WRITE_NEWS } from '../actions/types'; const INITIAL_STATE = { title: '', text: '' }; diff --git a/src/reducers/AddSolutionReducer.js b/src/reducers/AddSolutionReducer.js index c95892b..c956bd7 100644 --- a/src/reducers/AddSolutionReducer.js +++ b/src/reducers/AddSolutionReducer.js @@ -1,5 +1,8 @@ import { - WRITE_SOLUTION, WRITE_SOLUTION_FILE, GET_SOLUTIONS, CLEAR_WRITE, + CLEAR_WRITE, + GET_SOLUTIONS, + WRITE_SOLUTION, + WRITE_SOLUTION_FILE, } from '../actions/types'; const INITIAL_STATE = { diff --git a/src/reducers/AddTaskReducer.js b/src/reducers/AddTaskReducer.js index 467af4d..27d3963 100644 --- a/src/reducers/AddTaskReducer.js +++ b/src/reducers/AddTaskReducer.js @@ -1,4 +1,4 @@ -import { WRITE_TASK, WRITE_TASK_DEADLINE, CLEAR_WRITE } from '../actions/types'; +import { CLEAR_WRITE, WRITE_TASK, WRITE_TASK_DEADLINE } from '../actions/types'; const INITIAL_STATE = { title: '', text: '', deadline: '' }; diff --git a/src/reducers/CorrectSolutionReducer.js b/src/reducers/CorrectSolutionReducer.js index 3cba471..c57b712 100644 --- a/src/reducers/CorrectSolutionReducer.js +++ b/src/reducers/CorrectSolutionReducer.js @@ -1,5 +1,9 @@ import { - WRITE_SOLUTION, CHECK, SETCHECKTRUE, CLEAR_WRITE, SELECT_SOLUTION, + CHECK, + CLEAR_WRITE, + SELECT_SOLUTION, + SETCHECKTRUE, + WRITE_SOLUTION, } from '../actions/types'; const INITIAL_STATE = { diff --git a/src/reducers/EditNewsReducer.js b/src/reducers/EditNewsReducer.js index 5a0ead1..7bc9bba 100644 --- a/src/reducers/EditNewsReducer.js +++ b/src/reducers/EditNewsReducer.js @@ -1,6 +1,6 @@ -import { WRITE_NEWS, CLEAR_WRITE, SELECT_NEWS } from '../actions/types'; +import { CLEAR_WRITE, SELECT_NEWS, WRITE_NEWS } from '../actions/types'; -const INITIAL_STATE = { }; +const INITIAL_STATE = {}; export default (state = INITIAL_STATE, action) => { switch (action.type) { diff --git a/src/reducers/EditTaskReducer.js b/src/reducers/EditTaskReducer.js index 4f012f4..fc1dd6b 100644 --- a/src/reducers/EditTaskReducer.js +++ b/src/reducers/EditTaskReducer.js @@ -1,8 +1,11 @@ import { - SELECT_TASK, WRITE_TASK, WRITE_TASK_DEADLINE, CLEAR_WRITE, + CLEAR_WRITE, + SELECT_TASK, + WRITE_TASK, + WRITE_TASK_DEADLINE, } from '../actions/types'; -const INITIAL_STATE = { }; +const INITIAL_STATE = {}; export default (state = INITIAL_STATE, action) => { switch (action.type) { diff --git a/src/reducers/EventReducer.js b/src/reducers/EventReducer.js index e3a16d8..8cf9baf 100644 --- a/src/reducers/EventReducer.js +++ b/src/reducers/EventReducer.js @@ -1,13 +1,13 @@ import { + ABSENT_CHANGE, + ADD_EVENT, + CHANGE_NO, + CLEAR_WRITE, + DELETE_EVENT, GET_EVENTS, GET_EVENT_BY_ID, VISITOR_CHANGE, WRITE_EVENT, - ADD_EVENT, - DELETE_EVENT, - CLEAR_WRITE, - ABSENT_CHANGE, - CHANGE_NO, } from '../actions/types'; const INITIAL_STATE = { events: [], newEvent: {} }; @@ -25,7 +25,10 @@ export default (state = INITIAL_STATE, action) => { } 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 + ); } state.selectedEvent.visitors.push(action.payload); return { @@ -41,8 +44,10 @@ 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 { @@ -55,13 +60,17 @@ 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, @@ -72,7 +81,10 @@ export default (state = INITIAL_STATE, action) => { }, }; case WRITE_EVENT: - return { ...state, newEvent: { ...state.newEvent, [action.target]: action.payload } }; + return { + ...state, + newEvent: { ...state.newEvent, [action.target]: action.payload }, + }; case ADD_EVENT: return { ...state, events: [...state.events, action.payload] }; case DELETE_EVENT: diff --git a/src/reducers/HomeworksReducer.js b/src/reducers/HomeworksReducer.js index 9c5e58e..ab581ed 100644 --- a/src/reducers/HomeworksReducer.js +++ b/src/reducers/HomeworksReducer.js @@ -1,14 +1,14 @@ /* eslint-disable no-case-declarations */ import { - GET_TASKS, - GET_SOLUTIONS, - CORRECT_SOLUTION, + ADD_SOLUTION, ADD_TASK, + CORRECT_SOLUTION, DELETE_TASK, EDIT_TASK, - ADD_SOLUTION, - GET_PROFILES, GET_DOCUMENTS, + GET_PROFILES, + GET_SOLUTIONS, + GET_TASKS, } from '../actions/types'; const INITIAL_STATE = { @@ -19,7 +19,6 @@ const INITIAL_STATE = { documents: [], }; - export default (state = INITIAL_STATE, action) => { switch (action.type) { case GET_TASKS: @@ -27,29 +26,42 @@ 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); + modifiedSolutions.splice( + state.solutions.indexOf(modifiedSolution), + 1, + action.payload + ); return { ...state, solutions: [...modifiedSolutions] }; case ADD_SOLUTION: - return { ...state, solutions: [action.payload, ...state.solutions], id: action.payload.id }; + return { + ...state, + solutions: [action.payload, ...state.solutions], + id: action.payload.id, + }; case ADD_TASK: return { ...state, tasks: [action.payload, ...state.tasks] }; case DELETE_TASK: return { ...state, - tasks: [...state.tasks.slice(0, state.tasks.indexOf(action.payload)), - ...state.tasks.slice(state.tasks.indexOf(action.payload) + 1)], + tasks: [ + ...state.tasks.slice(0, state.tasks.indexOf(action.payload)), + ...state.tasks.slice(state.tasks.indexOf(action.payload) + 1), + ], }; case EDIT_TASK: return { ...state, - tasks: [...state.tasks.map((task) => { - if (task.id !== action.payload.id) { - return task; - } - return action.payload; - }), + tasks: [ + ...state.tasks.map((task) => { + if (task.id !== action.payload.id) { + return task; + } + return action.payload; + }), ], }; case GET_PROFILES: diff --git a/src/reducers/NewsReducer.js b/src/reducers/NewsReducer.js index f59d62f..4c45fcb 100644 --- a/src/reducers/NewsReducer.js +++ b/src/reducers/NewsReducer.js @@ -1,6 +1,4 @@ -import { - GET_NEWS, ADD_NEWS, DELETE_NEWS, EDIT_NEWS, -} from '../actions/types'; +import { ADD_NEWS, DELETE_NEWS, EDIT_NEWS, GET_NEWS } from '../actions/types'; const INITIAL_STATE = []; diff --git a/src/reducers/NoteReducer.js b/src/reducers/NoteReducer.js index 90e4c8d..a7ae9a8 100644 --- a/src/reducers/NoteReducer.js +++ b/src/reducers/NoteReducer.js @@ -1,8 +1,8 @@ import { - GET_NOTES_BY_EVENT, - WRITE_NOTE, ADD_EVENT_NOTE, CLEAR_WRITE, + GET_NOTES_BY_EVENT, + WRITE_NOTE, } from '../actions/types'; const INITIAL_STATE = { eventNotes: [], actualNote: {} }; @@ -12,7 +12,10 @@ export default (state = INITIAL_STATE, action) => { case GET_NOTES_BY_EVENT: return { ...state, eventNotes: action.payload }; case WRITE_NOTE: - return { ...state, actualNote: { ...state.actualNote, note: action.payload } }; + return { + ...state, + actualNote: { ...state.actualNote, note: action.payload }, + }; case ADD_EVENT_NOTE: return { ...state, eventNotes: [...state.eventNotes, action.payload] }; case CLEAR_WRITE: diff --git a/src/reducers/TraineeReducer.js b/src/reducers/TraineeReducer.js index c2f7a9f..8fb8524 100644 --- a/src/reducers/TraineeReducer.js +++ b/src/reducers/TraineeReducer.js @@ -1,5 +1,8 @@ import { - GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE, SET_STATUS, + GET_PROFILES, + GET_SELECTED_PROFILE, + GET_TRAINEES, + SET_STATUS, } from '../actions/types'; const INITIAL_STATE = { profiles: [], selectedProfile: {} }; @@ -13,10 +16,16 @@ 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], + selectedProfile: action.payload, + }; } return { ...state, profiles: [...state.profiles] }; default: diff --git a/src/reducers/UserReducer.js b/src/reducers/UserReducer.js index bcf9492..17b99dc 100644 --- a/src/reducers/UserReducer.js +++ b/src/reducers/UserReducer.js @@ -1,12 +1,11 @@ import { + GET_DEADLINE, GET_USERDATA, - PROFILE_CHANGE, GROUP_CHANGE, - GET_DEADLINE, + PROFILE_CHANGE, } from '../actions/types'; -const INITIAL_STATE = { -}; +const INITIAL_STATE = {}; export default (state = INITIAL_STATE, action) => { switch (action.type) { diff --git a/src/reducers/index.js b/src/reducers/index.js index 773566a..be56f36 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,19 +1,19 @@ -import { combineReducers } from 'redux'; -import UserReducer from './UserReducer'; -import NewsReducer from './NewsReducer'; import AddNewsReducer from './AddNewsReducer'; -import EditNewsReducer from './EditNewsReducer'; -import HomeworksReducer from './HomeworksReducer'; -import AddTaskReducer from './AddTaskReducer'; import AddSolutionReducer from './AddSolutionReducer'; -import EventReducer from './EventReducer'; -import TraineeReducer from './TraineeReducer'; -import NoteReducer from './NoteReducer'; +import AddTaskReducer from './AddTaskReducer'; import CorrectSolutionReducer from './CorrectSolutionReducer'; +import EditNewsReducer from './EditNewsReducer'; import EditTaskReducer from './EditTaskReducer'; +import EventReducer from './EventReducer'; import GroupsReducer from './GroupsReducer'; -import MentorsReducer from './MentorsReducer'; +import HomeworksReducer from './HomeworksReducer'; import ImagesReducer from './ImagesReducer'; +import MentorsReducer from './MentorsReducer'; +import NewsReducer from './NewsReducer'; +import NoteReducer from './NoteReducer'; +import TraineeReducer from './TraineeReducer'; +import UserReducer from './UserReducer'; +import { combineReducers } from 'redux'; const rootReducer = combineReducers({ user: UserReducer, diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index e91fcf1..2617198 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -11,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() { @@ -80,8 +80,8 @@ function checkValidServiceWorker(swUrl) { .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) => { @@ -96,7 +96,7 @@ 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.' ); }); } -- GitLab