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 771 additions and 138 deletions
import React, { Component } from 'react';
import { Container, Segment, Form, Dropdown, Divider, Header } from 'semantic-ui-react';
import { connect } from 'react-redux';
import { textChange, submitRegistration, groupChange } from '../../actions';
import { Container, Divider, Dropdown, Form, Segment } from "semantic-ui-react";
import React, { Component } from "react";
import { groupChange, submitRegistration, textChange } from "../../actions";
import HiddenForm from "../forms/HiddenForm";
import { connect } from "react-redux";
import { getDeadline } from "../../actions/auth";
const options = [
{ key: 'DT', text: 'DevTeam', value: 'DT' },
{ key: 'NET', text: 'NeTeam', value: 'NET' },
{ key: 'ST', text: 'SecurITeam', value: 'ST' },
{ key: 'SYS', text: 'SysAdmin', value: 'SYS' },
{ key: 'HAT', text: 'Hallgatói Tudásbázis', value: 'HAT' },
{ key: "DT", text: "DevTeam", value: "DT" },
{ key: "NET", text: "NETeam", value: "NET" },
{ key: "ST", text: "SecurITeam", value: "ST" },
{ key: "SYS", text: "SysAdmin", value: "SYS" },
{ key: "HAT", text: "Hallgatói Tudásbázis", value: "HAT" },
];
class Profile extends Component {
componentWillMount() {
UNSAFE_componentWillMount() {
this.props.getDeadline();
if (!this.props.id) {
this.props.history.push('/home');
this.props.history.push("/home");
}
}
render() {
const {
nick, groups, motivation, signed, id,
nick,
groups,
motivationAbout,
motivationProfession,
motivationExercise,
signed,
id,
deadline,
messageBefore,
messageAfter,
} = this.props;
const endDate = new Date(deadline);
const canEdit = Date.now() < endDate;
return (
<Container
style={{
marginBottom: '0.5em',
marginTop: '0.5em',
marginTop: "1em",
}}
>
<Divider horizontal>
<Header as='h2' content='Profil (Jelentkezés)' />
</Divider>
<Segment textAlign='center'>
<Form>
<Divider horizontal>Becenév</Divider>
{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'
onChange={e => this.props.textChange(e)}
placeholder='Becenév'
name="nick"
label="Becenév"
onChange={(e) => this.props.textChange(e)}
placeholder="Becenév"
value={nick}
/>
<Divider horizontal>Motivációs levél</Divider>
) : (
<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}
/>
)}
<Divider horizontal />
{canEdit ? (
<Form.TextArea
rows={10}
name='motivation'
onChange={e => this.props.textChange(e)}
placeholder='Miért szeretnék jelentkezni...'
value={motivation}
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>Érdekelt Körök</Divider>
<Dropdown
fluid
multiple
selection
placeholder='DevTeam, ...'
onChange={(_, v) => this.props.groupChange(v.value)}
options={options}
defaultValue={groups}
<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>
Kicsit hosszúra nyúlt az előadás és lassan rohannod kell
haza, ezért úgy döntesz, hogy megnézed a menetrendet a
menetrendek.hu weboldalon. Á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, 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/kepzes-media/public/zebra.html">
https://ujonc.kszk.bme.hu/kepzes-media/public/zebra.html
</a>
), de feltűnik, hogy egyenlőségjellel fejeződik be.
Nyomozz, s a végeredményt (amit találtál) írd ide!
</li>
<br />
<li>
A <b>ujonc-gres.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 írd le mit találtál!
</li>
</ul>
</div>
}
value={motivationExercise}
/>
<br />
<Form.Checkbox
name='signed'
label='Szeretnék jelentkezni a KSZK-ba'
onChange={(_, v) =>
this.props.textChange({ target: { name: v.name, value: v.checked } })
) : (
<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>
<br />
<li>
Kicsit hosszúra nyúlt az előadás és lassan rohannod kell
haza, ezért úgy döntesz, hogy megnézed a menetrendet a
menetrendek.hu weboldalon. Á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, 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/kepzes-media/public/zebra.html">
https://ujonc.kszk.bme.hu/kepzes-media/public/zebra.html
</a>
), de feltűnik, hogy egyenlőségjellel fejeződik be.
Nyomozz, s a végeredményt (amit találtál) írd ide!
</li>
<br />
<li>
A <b>ujonc-gres.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>
}
checked={signed}
value={motivationExercise}
/>
)}
<Divider horizontal>Érdeklődés</Divider>
<Dropdown
fluid
multiple
selection
placeholder="DevTeam, ..."
onChange={(_, v) => this.props.groupChange(v.value)}
options={options}
defaultValue={groups}
disabled={!canEdit}
/>
<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 },
})
}
checked={signed}
readOnly={!canEdit}
style={!canEdit ? { marginBottom: "5em" } : null}
/>
{canEdit ? (
<Form.Button
onClick={() => this.props.submitRegistration({
nick, motivation, signed, groups, id,
})}
primary
style={{ marginBottom: "5em" }}
disabled={!signed}
onClick={() =>
this.props.submitRegistration({
nick,
motivationAbout,
motivationProfession,
motivationExercise,
signed,
groups,
id,
})
}
>
Mentés
</Form.Button>
</Form>
</Segment>
) : (
""
)}
</Form>
</Container>
);
}
......@@ -87,14 +273,33 @@ class Profile extends Component {
const mapStateToProps = ({
user: {
nick, groups, motivation, signed, id,
nick,
groups,
motivationAbout,
motivationProfession,
motivationExercise,
signed,
id,
deadline,
messageBefore,
messageAfter,
},
}) => ({
nick,
groups,
motivation,
motivationAbout,
motivationProfession,
motivationExercise,
signed,
id,
deadline,
messageBefore,
messageAfter,
});
export default connect(mapStateToProps, { textChange, submitRegistration, groupChange })(Profile);
export default connect(mapStateToProps, {
textChange,
submitRegistration,
groupChange,
getDeadline,
})(Profile);
import React, { Component } from 'react';
import { Container, Header, Segment } from 'semantic-ui-react';
import "moment/locale/hu";
import {
Accordion,
Container,
Grid,
Header,
Icon,
Segment,
} from "semantic-ui-react";
import React, { Component } from "react";
import { connect } from "react-redux";
import { getStudentEvents } from "../../actions/statistics";
import moment from "moment";
class Schedule extends Component {
// eslint-disable-next-line react/state-in-constructor
state = { activeIndex: 0 };
UNSAFE_componentWillMount() {
this.props.getStudentEvents();
}
handleClick = (e, titleProps) => {
const { index } = titleProps;
const { activeIndex } = this.state;
const newIndex = activeIndex === index ? -1 : index;
this.setState({ activeIndex: newIndex });
};
export default class Schedule extends Component {
render() {
const { activeIndex } = this.state;
const { events } = this.props;
const panels = events
.sort((a, b) => a.date - b.date)
.map((event) => (
<Accordion key={Math.random()}>
<Accordion.Title
active={activeIndex === event.id}
index={event.id}
onClick={this.handleClick}
>
<h2>
<Grid>
<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">
{moment(event.date).locale("hu").format("LLLL")}
</Grid.Column>
</Grid>
</h2>
</Accordion.Title>
<Accordion.Content active={activeIndex === event.id}>
<Segment textAlign="left" style={{ overflowWrap: "break-word" }}>
{event.description}
</Segment>
</Accordion.Content>
</Accordion>
));
return (
<div>
<Segment inverted textAlign='center' vertical>
<Container>
<Header
as='h1'
content='Ütemterv - Hamarosan'
inverted
style={{
fontSize: '3em',
fontWeight: 'normal',
marginBottom: 0,
marginTop: '0.5em',
}}
/>
</Container>
</Segment>
<Container textAlign="center">
<Header
as="h1"
content="Képzés alkalmak"
style={{
fontSize: "2em",
fontWeight: "bold",
marginBottom: "0.5em",
marginTop: "0.5em",
}}
/>
<Accordion fluid styled>
{panels}
</Accordion>
<Header
as="h1"
content="Tábor: április 11-13"
style={{
fontSize: "2em",
fontWeight: "bold",
marginBottom: "0.5em",
marginTop: "1.5em",
}}
/>
</Container>
</div>
);
}
}
const mapStateToProps = ({ events: { events }, user }) => ({ events, user });
export default connect(mapStateToProps, { getStudentEvents })(Schedule);
import { Container, Menu } from 'semantic-ui-react';
import React, { Component } from 'react';
import { Container, Header, Segment } from 'semantic-ui-react';
import Events from './Events';
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' };
handleItemClick = (e, { name }) => this.setState({ activeItem: name });
render() {
const { activeItem } = this.state;
return (
<div>
<Segment inverted textAlign='center' vertical>
<Container>
<Header
as='h1'
content='Statisztikák - Hamarosan'
inverted
style={{
fontSize: '3em',
fontWeight: 'normal',
marginBottom: 0,
marginTop: '0.5em',
}}
/>
</Container>
</Segment>
<Container
textAlign="center"
style={{ paddingBottom: '5em', paddingTop: '1em' }}
>
<Menu tabular attached="top" size="huge" compact>
<Menu.Item
name="events"
active={activeItem === 'events'}
onClick={this.handleItemClick}
>
Alkalmak
</Menu.Item>
<Menu.Item
name="presence"
active={activeItem === 'presence'}
onClick={this.handleItemClick}
>
Jelenlét
</Menu.Item>
<Menu.Item
name="leaderboard"
active={activeItem === 'leaderboard'}
onClick={this.handleItemClick}
>
Ranglista
</Menu.Item>
</Menu>
{activeItem === 'events' ? <Events /> : ''}
{activeItem === 'presence' ? <Presence /> : ''}
{activeItem === 'leaderboard' ? <LeaderBoard /> : ''}
</Container>
</div>
);
}
......
import React, { Component } from 'react';
import { Container, Header, Segment } from 'semantic-ui-react';
export default class Trainers extends Component {
render() {
return (
<div>
<Segment inverted textAlign='center' vertical>
<Container>
<Header
as='h1'
content='Képzők - Hamarosan'
inverted
style={{
fontSize: '3em',
fontWeight: 'normal',
marginBottom: 0,
marginTop: '0.5em',
}}
/>
</Container>
</Segment>
</div>
);
}
}
export const APIKEY = '';
import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { createLogger } from 'redux-logger';
import { applyMiddleware, createStore } from 'redux';
// import { createLogger } from 'redux-logger';
import rootReducer from './reducers';
import thunkMiddleware from 'redux-thunk';
const loggerMiddleware = createLogger();
// const loggerMiddleware = createLogger();
export default function configureStore(preloadedState) {
return createStore(
rootReducer,
preloadedState,
applyMiddleware(
thunkMiddleware,
loggerMiddleware,
),
thunkMiddleware
// loggerMiddleware,
)
);
}
/* eslint-disable import/no-unresolved */
/* eslint-disable import/named */
/* eslint-disable import/extensions */
import React, { Component } from 'react';
import { connect } from 'react-redux';
// eslint-disable-next-line
import PropTypes from 'prop-types';
import Todo from '../components/Todo';
import { addTodo } from '../actions';
import { connect } from 'react-redux';
class TodoContainer extends Component {
render() {
......@@ -11,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>
);
}
......@@ -31,7 +33,7 @@ const mapStateToProps = (state) => {
};
};
const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
onTodoClick: (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-theme.css';
import 'semantic-ui-css/semantic.min.css';
import configureStore from './configureStore';
import * as serviceWorker from './registerServiceWorker';
import App from './components/App';
import registerServiceWorker from './registerServiceWorker';
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();
const store = configureStore();
......@@ -16,7 +22,7 @@ render(
<App />
</Router>
</Provider>,
document.getElementById('root'),
document.getElementById('root')
);
registerServiceWorker();
serviceWorker.unregister();
import { CLEAR_WRITE, WRITE_NEWS } from '../actions/types';
const INITIAL_STATE = { title: '', text: '' };
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case WRITE_NEWS:
return { ...state, [action.target]: action.payload };
case CLEAR_WRITE:
return INITIAL_STATE;
default:
return state;
}
};
import {
CLEAR_WRITE,
GET_SOLUTIONS,
WRITE_SOLUTION,
WRITE_SOLUTION_FILE,
} from '../actions/types';
const INITIAL_STATE = {
task: '',
name: '',
description: '',
file: '',
solutions: [],
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case WRITE_SOLUTION:
return { ...state, [action.target]: action.payload };
case WRITE_SOLUTION_FILE:
return { ...state, [action.target]: action.payload };
case GET_SOLUTIONS:
return { ...state, solutions: action.payload };
case CLEAR_WRITE:
return INITIAL_STATE;
default:
return state;
}
};
import { CLEAR_WRITE, WRITE_TASK, WRITE_TASK_DEADLINE } from '../actions/types';
const INITIAL_STATE = { title: '', text: '', deadline: '' };
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
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 {
CHECK,
CLEAR_WRITE,
SELECT_SOLUTION,
SETCHECKTRUE,
WRITE_SOLUTION,
} from '../actions/types';
const INITIAL_STATE = {
accepted: false,
corrected: false,
note: '',
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case SELECT_SOLUTION:
return {
corrected: action.payload.corrected,
accepted: action.payload.accepted,
note: action.payload.note,
};
case WRITE_SOLUTION:
return { ...state, [action.target]: action.payload };
case CHECK:
return {
...state,
[action.target]: !state[action.target],
};
case SETCHECKTRUE:
return {
...state,
[action.target]: true,
};
case CLEAR_WRITE:
return INITIAL_STATE;
default:
return state;
}
};
import { CLEAR_WRITE, SELECT_NEWS, WRITE_NEWS } from '../actions/types';
const INITIAL_STATE = {};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case SELECT_NEWS:
return action.payload;
case WRITE_NEWS:
return { ...state, [action.target]: action.payload };
case CLEAR_WRITE:
return INITIAL_STATE;
default:
return state;
}
};
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 {
ABSENT_CHANGE,
ADD_EVENT,
CHANGE_NO,
CLEAR_WRITE,
DELETE_EVENT,
GET_EVENTS,
GET_EVENT_BY_ID,
VISITOR_CHANGE,
WRITE_EVENT,
} from '../actions/types';
const INITIAL_STATE = { events: [], newEvent: {} };
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_EVENTS:
return { ...state, events: [...action.payload] };
case GET_EVENT_BY_ID:
return { ...state, selectedEvent: action.payload };
case VISITOR_CHANGE:
if (state.selectedEvent.visitors.includes(action.payload)) {
// Benne van nem kell megváltoztatni
return { ...state };
}
if (state.selectedEvent.absent.indexOf(action.payload) > -1) {
// Ha az absentbe van ki kell venni
state.selectedEvent.absent.splice(
state.selectedEvent.absent.indexOf(action.payload),
1
);
}
state.selectedEvent.visitors.push(action.payload);
return {
...state,
selectedEvent: {
...state.selectedEvent,
visitors: state.selectedEvent.visitors,
absent: state.selectedEvent.absent,
},
};
case ABSENT_CHANGE:
if (state.selectedEvent.absent.includes(action.payload)) {
return { ...state };
}
if (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 {
...state,
selectedEvent: {
...state.selectedEvent,
visitors: state.selectedEvent.visitors,
absent: state.selectedEvent.absent,
},
};
case CHANGE_NO:
if (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
);
}
return {
...state,
selectedEvent: {
...state.selectedEvent,
visitors: state.selectedEvent.visitors,
absent: state.selectedEvent.absent,
},
};
case WRITE_EVENT:
return {
...state,
newEvent: { ...state.newEvent, [action.target]: action.payload },
};
case ADD_EVENT:
return { ...state, events: [...state.events, action.payload] };
case DELETE_EVENT:
state.events.splice(state.events.indexOf(action.payload), 1);
return { ...state, events: [...state.events] };
case CLEAR_WRITE:
return { ...state, newEvent: {} };
default:
return state;
}
};
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;
}
};
/* 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;
}
};