Skip to content

Commit

Permalink
User can like job by swiping card to the right
Browse files Browse the repository at this point in the history
  • Loading branch information
daxapps committed Nov 26, 2017
1 parent 2d5ca9b commit d270fc7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
12 changes: 10 additions & 2 deletions actions/job_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import reverseGeocode from 'latlng-to-zip';
import qs from 'qs';

import {
FETCH_JOBS
FETCH_JOBS,
LIKE_JOB
} from './types';

const JOB_ROOT_URL = 'http://api.indeed.com/ads/apisearch?';
Expand Down Expand Up @@ -32,4 +33,11 @@ export const fetchJobs = (region, callback) => async (dispatch) => {
console.error(e);
}

};
};

export const likeJob = (job) => {
return {
payload: job,
type: LIKE_JOB
};
};
1 change: 1 addition & 0 deletions actions/types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const FACEBOOK_LOGIN_SUCCESS = 'facebook_login_success';
export const FACEBOOK_LOGIN_FAIL = 'facebook_login_fail';
export const FETCH_JOBS = 'fetch_jobs';
export const LIKE_JOB = 'like_job';
3 changes: 2 additions & 1 deletion reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { combineReducers } from "redux";
import auth from "./auth_reducer";
import jobs from "./jobs_reducer";
import likedJobs from "./likes_reducer";

export default combineReducers({
auth, jobs
auth, jobs, likedJobs
});
16 changes: 16 additions & 0 deletions reducers/likes_reducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import _ from 'lodash';
import {
LIKE_JOB
} from '../actions/types';

export default function(state = [], action) {
switch (action.type) {
case LIKE_JOB:
// only return unique jobs
return _.uniqBy([
action.payload, ...state
], 'jobkey');
default:
return state;
}
}

0 comments on commit d270fc7

Please sign in to comment.