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
/* 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 = {
id: 0,
tasks: [],
solutions: [],
profiles: [],
documents: [],
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_TASKS:
return { ...state, tasks: action.payload };
case GET_SOLUTIONS:
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:
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),
],
};
case EDIT_TASK:
return {
...state,
tasks: [
...state.tasks.map((task) => {
if (task.id !== action.payload.id) {
return task;
}
return action.payload;
}),
],
};
case GET_PROFILES:
return { ...state, profiles: action.payload };
case GET_DOCUMENTS:
return { ...state, documents: action.payload };
default:
return state;
}
};
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 { ADD_NEWS, DELETE_NEWS, EDIT_NEWS, GET_NEWS } from '../actions/types';
const INITIAL_STATE = [];
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_NEWS:
return action.payload;
case ADD_NEWS:
return [action.payload, ...state];
case EDIT_NEWS:
const array = state.filter((item) => item.id === action.payload.id);
state.splice(state.indexOf(array.pop()), 1, action.payload);
return [...state];
case DELETE_NEWS:
state.splice(state.indexOf(action.payload), 1);
return [...state];
default:
return state;
}
};
import {
ADD_EVENT_NOTE,
CLEAR_WRITE,
GET_NOTES_BY_EVENT,
WRITE_NOTE,
} from '../actions/types';
const INITIAL_STATE = { eventNotes: [], actualNote: {} };
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_NOTES_BY_EVENT:
return { ...state, eventNotes: action.payload };
case WRITE_NOTE:
return {
...state,
actualNote: { ...state.actualNote, note: action.payload },
};
case ADD_EVENT_NOTE:
return { ...state, eventNotes: [...state.eventNotes, action.payload] };
case CLEAR_WRITE:
return { ...state, actualNote: { note: '' } };
default:
return state;
}
};
import {
GET_PROFILES,
GET_SELECTED_PROFILE,
GET_TRAINEES,
SET_STATUS,
} from '../actions/types';
const INITIAL_STATE = { profiles: [], selectedProfile: {} };
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_TRAINEES:
return { ...state, trainees: [...action.payload] };
case GET_PROFILES:
return { ...state, profiles: [...action.payload] };
case GET_SELECTED_PROFILE:
return { ...state, selectedProfile: action.payload };
case SET_STATUS:
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] };
default:
return state;
}
};
import {
GET_DEADLINE,
GET_USERDATA,
GROUP_CHANGE,
PROFILE_CHANGE,
} from '../actions/types';
const INITIAL_STATE = {};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_USERDATA:
return { ...state, ...action.payload };
case GET_DEADLINE:
return { ...state, ...action.payload };
case PROFILE_CHANGE:
return { ...state, [action.target]: action.payload };
case GROUP_CHANGE:
return { ...state, groups: action.payload };
default:
return state;
}
};
import AddNewsReducer from './AddNewsReducer';
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 GroupsReducer from './GroupsReducer';
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'; import { combineReducers } from 'redux';
import TodoReducer from './TodoReducer';
const rootReducer = combineReducers({ const rootReducer = combineReducers({
todos: TodoReducer, user: UserReducer,
news: NewsReducer,
newNews: AddNewsReducer,
selectedNews: EditNewsReducer,
homeworks: HomeworksReducer,
correction: CorrectSolutionReducer,
newTask: AddTaskReducer,
selectedTask: EditTaskReducer,
newSolution: AddSolutionReducer,
events: EventReducer,
trainees: TraineeReducer,
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();
}); });
} }
......
import { withRouter } from 'react-router-dom';
export const publicRoutes = [
{
path: '/login',
component: Login,
},
{
path: '/register',
component: Register,
},
{
path: '/home',
},
{
path: '/news',
},
{
path: '/',
},
{
component: NotFound,
},
];
export const privateRoutes = [
{
path: '/home',
component: withRouter(Home),
},
{
path: '/store/details',
component: withRouter(Detail),
},
]
const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
app.use(
"/api",
createProxyMiddleware({
target: "http://localhost:8000",
changeOrigin: true,
}),
);
app.use(
"/admin",
createProxyMiddleware({
target: "http://localhost:8000",
changeOrigin: true,
}),
);
app.use(
"/staticfiles",
createProxyMiddleware({
target: "http://localhost:8000",
changeOrigin: true,
}),
);
app.use(
"/mediafiles",
createProxyMiddleware({
target: "http://localhost:8000",
changeOrigin: true,
}),
);
app.use(
"/oidc",
createProxyMiddleware({
target: "http://localhost:8000",
changeOrigin: true,
}),
);
};
Source diff could not be displayed: it is too large. Options to address this: view the blob.