main
Last change
on this file since 08f82ec was 28b3398, checked in by 223021 <daniel.ilievski.2@…>, 4 months ago |
Implemented job application functionality, added job advertisement filtering and replaced text areas with editors
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | import {
|
---|
2 | CURRENT_USER,
|
---|
3 | FETCH_APPLICATIONS_BY_JOB_ID,
|
---|
4 | FETCH_APPLICATIONS_BY_JOB_SEEKER_ID,
|
---|
5 | SUBMIT_APPLICATION, UPDATE_APPLICATION_STATUS
|
---|
6 | } from "../actionTypes";
|
---|
7 |
|
---|
8 | const initialState = {
|
---|
9 | applicationsByJobSeeker: [],
|
---|
10 | applicationsByJobAdId: []
|
---|
11 | }
|
---|
12 |
|
---|
13 | let currentUser = JSON.parse(localStorage.getItem(CURRENT_USER))
|
---|
14 |
|
---|
15 | export const ApplicationReducer = (state = initialState, action) => {
|
---|
16 | let applications;
|
---|
17 |
|
---|
18 | switch (action.type) {
|
---|
19 | case SUBMIT_APPLICATION:
|
---|
20 | return {
|
---|
21 | ...state,
|
---|
22 | applicationsByJobSeeker: [...state.applicationsByJobSeeker, action.application]
|
---|
23 | }
|
---|
24 | case UPDATE_APPLICATION_STATUS:
|
---|
25 | return {
|
---|
26 | ...state,
|
---|
27 | applicationsByJobAdId: state.applicationsByJobAdId.map(application =>
|
---|
28 | application.id === action.application.id ?
|
---|
29 | {...application, status: action.application.status} :
|
---|
30 | application
|
---|
31 | )
|
---|
32 | }
|
---|
33 | case FETCH_APPLICATIONS_BY_JOB_ID:
|
---|
34 | return {
|
---|
35 | ...state,
|
---|
36 | applicationsByJobAdId: action.applicationsByJobAdId
|
---|
37 | }
|
---|
38 | case FETCH_APPLICATIONS_BY_JOB_SEEKER_ID:
|
---|
39 | return {
|
---|
40 | ...state,
|
---|
41 | applicationsByJobSeeker: action.applicationsByJobSeeker
|
---|
42 | }
|
---|
43 | default:
|
---|
44 | return {
|
---|
45 | ...state,
|
---|
46 | };
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | export default ApplicationReducer |
---|
Note:
See
TracBrowser
for help on using the repository browser.