Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kszk/devteam/kszkepzes/old/kszkepzes-frontend
  • kbgergely/kszkepzes-frontend
2 results
Show changes
Showing
with 250 additions and 73 deletions
import { createStore, applyMiddleware } from 'redux'; import { applyMiddleware, createStore } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { createLogger } from 'redux-logger'; // import { createLogger } from 'redux-logger';
import rootReducer from './reducers'; import rootReducer from './reducers';
import thunkMiddleware from 'redux-thunk';
const loggerMiddleware = createLogger(); // const loggerMiddleware = createLogger();
export default function configureStore(preloadedState) { export default function configureStore(preloadedState) {
return createStore( return createStore(
rootReducer, rootReducer,
preloadedState, preloadedState,
applyMiddleware( applyMiddleware(
thunkMiddleware, thunkMiddleware
loggerMiddleware, // loggerMiddleware,
), )
); );
} }
/* eslint-disable import/no-unresolved */
/* eslint-disable import/named */
/* eslint-disable import/extensions */
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux';
// eslint-disable-next-line // eslint-disable-next-line
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Todo from '../components/Todo'; import Todo from '../components/Todo';
import { addTodo } from '../actions'; import { addTodo } from '../actions';
import { connect } from 'react-redux';
class TodoContainer extends Component { class TodoContainer extends Component {
render() { render() {
...@@ -11,13 +15,11 @@ class TodoContainer extends Component { ...@@ -11,13 +15,11 @@ class TodoContainer extends Component {
return ( return (
<div> <div>
{ {todos.map((todo) => (
todos.map(todo => ( <Todo onClick={onTodoClick} key={Math.random()}>
<Todo onClick={onTodoClick} key={Math.random()}> {todo.data}
{todo.data} </Todo>
</Todo> ))}
))
}
</div> </div>
); );
} }
...@@ -31,7 +33,7 @@ const mapStateToProps = (state) => { ...@@ -31,7 +33,7 @@ const mapStateToProps = (state) => {
}; };
}; };
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = (dispatch) => ({
onTodoClick: (data) => { onTodoClick: (data) => {
dispatch(addTodo(data)); dispatch(addTodo(data));
}, },
......
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.css';
import 'slick-carousel/slick/slick-theme.css'; import 'slick-carousel/slick/slick-theme.css';
import 'semantic-ui-css/semantic.min.css'; import 'semantic-ui-css/semantic.min.css';
import moment from 'moment';
import configureStore from './configureStore';
import App from './components/App';
import registerServiceWorker from './registerServiceWorker';
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(); moment.locale();
...@@ -21,7 +22,7 @@ render( ...@@ -21,7 +22,7 @@ render(
<App /> <App />
</Router> </Router>
</Provider>, </Provider>,
document.getElementById('root'), document.getElementById('root')
); );
registerServiceWorker(); serviceWorker.unregister();
import { WRITE_NEWS, CLEAR_WRITE } from '../actions/types'; import { CLEAR_WRITE, WRITE_NEWS } from '../actions/types';
const INITIAL_STATE = { title: '', text: '' }; const INITIAL_STATE = { title: '', text: '' };
......
import { WRITE_SOLUTION, WRITE_SOLUTION_FILE, GET_SOLUTIONS, CLEAR_WRITE } from '../actions/types'; import {
CLEAR_WRITE,
GET_SOLUTIONS,
WRITE_SOLUTION,
WRITE_SOLUTION_FILE,
} from '../actions/types';
const INITIAL_STATE = { const INITIAL_STATE = {
task: '', task: '',
......
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: '' }; const INITIAL_STATE = { title: '', text: '', deadline: '' };
......
import { WRITE_SOLUTION, CHECK } from '../actions/types'; import {
CHECK,
CLEAR_WRITE,
SELECT_SOLUTION,
SETCHECKTRUE,
WRITE_SOLUTION,
} from '../actions/types';
const INITIAL_STATE = { const INITIAL_STATE = {
accepted: false, accepted: false,
corrected: false,
note: '', note: '',
}; };
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
case SELECT_SOLUTION:
return {
corrected: action.payload.corrected,
accepted: action.payload.accepted,
note: action.payload.note,
};
case WRITE_SOLUTION: case WRITE_SOLUTION:
return { ...state, [action.target]: action.payload }; return { ...state, [action.target]: action.payload };
case CHECK: case CHECK:
return { ...state, accepted: !state.accepted }; return {
...state,
[action.target]: !state[action.target],
};
case SETCHECKTRUE:
return {
...state,
[action.target]: true,
};
case CLEAR_WRITE:
return INITIAL_STATE;
default: default:
return state; return state;
} }
......
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) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
......
import {
CLEAR_WRITE,
SELECT_TASK,
WRITE_TASK,
WRITE_TASK_DEADLINE,
} from '../actions/types';
const INITIAL_STATE = {};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case SELECT_TASK:
return action.payload;
case WRITE_TASK:
return { ...state, [action.target]: action.payload };
case WRITE_TASK_DEADLINE:
return { ...state, [action.target]: action.payload };
case CLEAR_WRITE:
return INITIAL_STATE;
default:
return state;
}
};
import { import {
ABSENT_CHANGE,
ADD_EVENT,
CHANGE_NO,
CLEAR_WRITE,
DELETE_EVENT,
GET_EVENTS, GET_EVENTS,
GET_EVENT_BY_ID, GET_EVENT_BY_ID,
VISITOR_CHANGE, VISITOR_CHANGE,
WRITE_EVENT, WRITE_EVENT,
ADD_EVENT,
DELETE_EVENT,
CLEAR_WRITE,
ABSENT_CHANGE,
CHANGE_NO,
} from '../actions/types'; } from '../actions/types';
const INITIAL_STATE = { events: [], newEvent: {} }; const INITIAL_STATE = { events: [], newEvent: {} };
...@@ -21,13 +21,16 @@ export default (state = INITIAL_STATE, action) => { ...@@ -21,13 +21,16 @@ export default (state = INITIAL_STATE, action) => {
case VISITOR_CHANGE: case VISITOR_CHANGE:
if (state.selectedEvent.visitors.includes(action.payload)) { if (state.selectedEvent.visitors.includes(action.payload)) {
// Benne van nem kell megváltoztatni // Benne van nem kell megváltoztatni
return { ...state } return { ...state };
} }
if (state.selectedEvent.absent.indexOf(action.payload) > -1) { if (state.selectedEvent.absent.indexOf(action.payload) > -1) {
// Ha az absentbe van ki kell venni // 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) state.selectedEvent.visitors.push(action.payload);
return { return {
...state, ...state,
selectedEvent: { selectedEvent: {
...@@ -41,7 +44,10 @@ export default (state = INITIAL_STATE, action) => { ...@@ -41,7 +44,10 @@ export default (state = INITIAL_STATE, action) => {
return { ...state }; return { ...state };
} }
if (state.selectedEvent.visitors.indexOf(action.payload) > -1) { 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); state.selectedEvent.absent.push(action.payload);
return { return {
...@@ -54,11 +60,17 @@ export default (state = INITIAL_STATE, action) => { ...@@ -54,11 +60,17 @@ export default (state = INITIAL_STATE, action) => {
}; };
case CHANGE_NO: case CHANGE_NO:
if (state.selectedEvent.visitors.indexOf(action.payload) > -1) { 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) { if (state.selectedEvent.absent.indexOf(action.payload) > -1) {
// Ha az absentbe van ki kell venni // 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 { return {
...state, ...state,
...@@ -69,7 +81,10 @@ export default (state = INITIAL_STATE, action) => { ...@@ -69,7 +81,10 @@ export default (state = INITIAL_STATE, action) => {
}, },
}; };
case WRITE_EVENT: case WRITE_EVENT:
return { ...state, newEvent: { ...state.newEvent, [action.target]: action.payload } }; return {
...state,
newEvent: { ...state.newEvent, [action.target]: action.payload },
};
case ADD_EVENT: case ADD_EVENT:
return { ...state, events: [...state.events, action.payload] }; return { ...state, events: [...state.events, action.payload] };
case DELETE_EVENT: case DELETE_EVENT:
......
import { GET_GROUPS } from '../actions/types';
const INITIAL_STATE = [];
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_GROUPS:
return action.payload;
default:
return state;
}
};
import { GET_TASKS, GET_SOLUTIONS, ADD_TASK, ADD_SOLUTION, GET_PROFILES, GET_DOCUMENTS } from '../actions/types'; /* eslint-disable no-case-declarations */
import {
ADD_SOLUTION,
ADD_TASK,
CORRECT_SOLUTION,
DELETE_TASK,
EDIT_TASK,
GET_DOCUMENTS,
GET_PROFILES,
GET_SOLUTIONS,
GET_TASKS,
} from '../actions/types';
const INITIAL_STATE = { const INITIAL_STATE = {
id: 0, id: 0,
...@@ -8,17 +19,51 @@ const INITIAL_STATE = { ...@@ -8,17 +19,51 @@ const INITIAL_STATE = {
documents: [], documents: [],
}; };
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
case GET_TASKS: case GET_TASKS:
return { ...state, tasks: action.payload }; return { ...state, tasks: action.payload };
case GET_SOLUTIONS: case GET_SOLUTIONS:
return { ...state, solutions: action.payload }; return { ...state, solutions: action.payload };
case CORRECT_SOLUTION:
const modifiedSolution = state.solutions.find(
(sol) => sol.id === action.payload.id
);
const modifiedSolutions = state.solutions.slice();
modifiedSolutions.splice(
state.solutions.indexOf(modifiedSolution),
1,
action.payload
);
return { ...state, solutions: [...modifiedSolutions] };
case ADD_SOLUTION: 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: case ADD_TASK:
return { ...state, tasks: [action.payload, ...state.tasks] }; 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),
],
};
case EDIT_TASK:
return {
...state,
tasks: [
...state.tasks.map((task) => {
if (task.id !== action.payload.id) {
return task;
}
return action.payload;
}),
],
};
case GET_PROFILES: case GET_PROFILES:
return { ...state, profiles: action.payload }; return { ...state, profiles: action.payload };
case GET_DOCUMENTS: case GET_DOCUMENTS:
......
import { GET_IMAGES } from '../actions/types';
const INITIAL_STATE = [];
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_IMAGES:
return action.payload;
default:
return state;
}
};
import { GET_MENTORS } from '../actions/types';
const INITIAL_STATE = [];
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_MENTORS:
return action.payload;
default:
return state;
}
};
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 = []; const INITIAL_STATE = [];
...@@ -9,7 +9,7 @@ export default (state = INITIAL_STATE, action) => { ...@@ -9,7 +9,7 @@ export default (state = INITIAL_STATE, action) => {
case ADD_NEWS: case ADD_NEWS:
return [action.payload, ...state]; return [action.payload, ...state];
case EDIT_NEWS: case EDIT_NEWS:
const array = state.filter(item => item.id === action.payload.id); const array = state.filter((item) => item.id === action.payload.id);
state.splice(state.indexOf(array.pop()), 1, action.payload); state.splice(state.indexOf(array.pop()), 1, action.payload);
return [...state]; return [...state];
case DELETE_NEWS: case DELETE_NEWS:
......
import { import {
GET_NOTES_BY_EVENT,
WRITE_NOTE,
ADD_EVENT_NOTE, ADD_EVENT_NOTE,
CLEAR_WRITE, CLEAR_WRITE,
GET_NOTES_BY_EVENT,
WRITE_NOTE,
} from '../actions/types'; } from '../actions/types';
const INITIAL_STATE = { eventNotes: [], actualNote: {} }; const INITIAL_STATE = { eventNotes: [], actualNote: {} };
...@@ -12,7 +12,10 @@ export default (state = INITIAL_STATE, action) => { ...@@ -12,7 +12,10 @@ export default (state = INITIAL_STATE, action) => {
case GET_NOTES_BY_EVENT: case GET_NOTES_BY_EVENT:
return { ...state, eventNotes: action.payload }; return { ...state, eventNotes: action.payload };
case WRITE_NOTE: case WRITE_NOTE:
return { ...state, actualNote: { ...state.actualNote, note: action.payload } }; return {
...state,
actualNote: { ...state.actualNote, note: action.payload },
};
case ADD_EVENT_NOTE: case ADD_EVENT_NOTE:
return { ...state, eventNotes: [...state.eventNotes, action.payload] }; return { ...state, eventNotes: [...state.eventNotes, action.payload] };
case CLEAR_WRITE: case CLEAR_WRITE:
......
import { GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE, SET_STATUS } from '../actions/types'; import {
GET_PROFILES,
GET_SELECTED_PROFILE,
GET_TRAINEES,
SET_STATUS,
} from '../actions/types';
const INITIAL_STATE = { profiles: [], selectedProfile: {} }; const INITIAL_STATE = { profiles: [], selectedProfile: {} };
...@@ -11,12 +16,18 @@ export default (state = INITIAL_STATE, action) => { ...@@ -11,12 +16,18 @@ export default (state = INITIAL_STATE, action) => {
case GET_SELECTED_PROFILE: case GET_SELECTED_PROFILE:
return { ...state, selectedProfile: action.payload }; return { ...state, selectedProfile: action.payload };
case SET_STATUS: 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); state.profiles.splice(index, 1, action.payload);
if (action.payload.id === state.selectedProfile.id) { 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] } return { ...state, profiles: [...state.profiles] };
default: default:
return state; return state;
} }
......
import { import {
GET_DEADLINE,
GET_USERDATA, GET_USERDATA,
PROFILE_CHANGE,
GROUP_CHANGE, GROUP_CHANGE,
PROFILE_CHANGE,
} from '../actions/types'; } from '../actions/types';
const INITIAL_STATE = { const INITIAL_STATE = {};
};
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
case GET_USERDATA: case GET_USERDATA:
return { ...state, ...action.payload }; return { ...state, ...action.payload };
case GET_DEADLINE:
return { ...state, ...action.payload };
case PROFILE_CHANGE: case PROFILE_CHANGE:
return { ...state, [action.target]: action.payload }; return { ...state, [action.target]: action.payload };
case GROUP_CHANGE: case GROUP_CHANGE:
......
import { combineReducers } from 'redux';
import UserReducer from './UserReducer';
import NewsReducer from './NewsReducer';
import AddNewsReducer from './AddNewsReducer'; import AddNewsReducer from './AddNewsReducer';
import EditNewsReducer from './EditNewsReducer';
import HomeworksReducer from './HomeworksReducer';
import AddTaskReducer from './AddTaskReducer';
import AddSolutionReducer from './AddSolutionReducer'; import AddSolutionReducer from './AddSolutionReducer';
import AddTaskReducer from './AddTaskReducer';
import CorrectSolutionReducer from './CorrectSolutionReducer';
import EditNewsReducer from './EditNewsReducer';
import EditTaskReducer from './EditTaskReducer';
import EventReducer from './EventReducer'; import EventReducer from './EventReducer';
import TraineeReducer from './TraineeReducer'; import GroupsReducer from './GroupsReducer';
import HomeworksReducer from './HomeworksReducer';
import ImagesReducer from './ImagesReducer';
import MentorsReducer from './MentorsReducer';
import NewsReducer from './NewsReducer';
import NoteReducer from './NoteReducer'; import NoteReducer from './NoteReducer';
import CorrectSolutionReducer from './CorrectSolutionReducer'; import TraineeReducer from './TraineeReducer';
import UserReducer from './UserReducer';
import { combineReducers } from 'redux';
const rootReducer = combineReducers({ const rootReducer = combineReducers({
user: UserReducer, user: UserReducer,
...@@ -19,10 +23,14 @@ const rootReducer = combineReducers({ ...@@ -19,10 +23,14 @@ const rootReducer = combineReducers({
homeworks: HomeworksReducer, homeworks: HomeworksReducer,
correction: CorrectSolutionReducer, correction: CorrectSolutionReducer,
newTask: AddTaskReducer, newTask: AddTaskReducer,
selectedTask: EditTaskReducer,
newSolution: AddSolutionReducer, newSolution: AddSolutionReducer,
events: EventReducer, events: EventReducer,
trainees: TraineeReducer, trainees: TraineeReducer,
notes: NoteReducer, notes: NoteReducer,
groups: GroupsReducer,
mentors: MentorsReducer,
images: ImagesReducer,
}); });
export default rootReducer; export default rootReducer;
/* eslint-disable no-param-reassign */
/* eslint-disable no-use-before-define */
// In production, we register a service worker to serve assets from local cache. // In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives // This lets the app load faster on subsequent visits in production, and gives
...@@ -46,7 +48,7 @@ export default function register() { ...@@ -46,7 +48,7 @@ export default function register() {
function registerValidSW(swUrl) { function registerValidSW(swUrl) {
navigator.serviceWorker navigator.serviceWorker
.register(swUrl) .register(swUrl)
.then(registration => { .then((registration) => {
registration.onupdatefound = () => { registration.onupdatefound = () => {
const installingWorker = registration.installing; const installingWorker = registration.installing;
installingWorker.onstatechange = () => { installingWorker.onstatechange = () => {
...@@ -67,7 +69,7 @@ function registerValidSW(swUrl) { ...@@ -67,7 +69,7 @@ function registerValidSW(swUrl) {
}; };
}; };
}) })
.catch(error => { .catch((error) => {
console.error('Error during service worker registration:', error); console.error('Error during service worker registration:', error);
}); });
} }
...@@ -75,14 +77,14 @@ function registerValidSW(swUrl) { ...@@ -75,14 +77,14 @@ function registerValidSW(swUrl) {
function checkValidServiceWorker(swUrl) { function checkValidServiceWorker(swUrl) {
// Check if the service worker can be found. If it can't reload the page. // Check if the service worker can be found. If it can't reload the page.
fetch(swUrl) fetch(swUrl)
.then(response => { .then((response) => {
// Ensure service worker exists, and that we really are getting a JS file. // Ensure service worker exists, and that we really are getting a JS file.
if ( if (
response.status === 404 || response.status === 404 ||
response.headers.get('content-type').indexOf('javascript') === -1 response.headers.get('content-type').indexOf('javascript') === -1
) { ) {
// No service worker found. Probably a different app. Reload the page. // No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => { navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => { registration.unregister().then(() => {
window.location.reload(); window.location.reload();
}); });
...@@ -101,7 +103,7 @@ function checkValidServiceWorker(swUrl) { ...@@ -101,7 +103,7 @@ function checkValidServiceWorker(swUrl) {
export function unregister() { export function unregister() {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => { navigator.serviceWorker.ready.then((registration) => {
registration.unregister(); registration.unregister();
}); });
} }
......