Skip to content

Commit

Permalink
Merge pull request #448 from MetaPhase-Consulting/feature/ap-compare
Browse files Browse the repository at this point in the history
Add ability to compare available positions
  • Loading branch information
mjoyce91 authored Oct 2, 2019
2 parents e8c2cbc + 22dd30d commit 8c95825
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/actions/comparisons.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { CancelToken } from 'axios';
import api from '../api';
import { checkFlag } from '../flags';

const getUseAP = () => checkFlag('flags.available_positions');

let cancel;

Expand Down Expand Up @@ -27,12 +30,16 @@ export function comparisonsFetchDataSuccess(comparisons) {
export function comparisonsFetchData(query) {
return (dispatch) => {
if (cancel) { cancel(); }

const useAP = getUseAP();
const url = useAP ? `/fsbid/available_positions/?id=${query}` : `/cycleposition/?has_id=${query}`;

dispatch(comparisonsIsLoading(true));
if (!query) {
dispatch(comparisonsFetchDataSuccess([]));
dispatch(comparisonsIsLoading(false));
} else {
api().get(`/cycleposition/?has_id=${query}`, {
api().get(url, {
cancelToken: new CancelToken((c) => { cancel = c; }),
})
.then((response) => {
Expand Down

0 comments on commit 8c95825

Please sign in to comment.