mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-10 01:19:53 +01:00
* Setup create-react-app and typescript Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
33 lines
893 B
JavaScript
33 lines
893 B
JavaScript
import api from './api';
|
|
import { dispatchError } from '../util';
|
|
|
|
export const REVIVE_TOGGLE = 'REVIVE_TOGGLE';
|
|
export const RECEIVE_ARCHIVE = 'RECEIVE_ARCHIVE';
|
|
export const ERROR_RECEIVE_ARCHIVE = 'ERROR_RECEIVE_ARCHIVE';
|
|
|
|
const receiveArchive = json => ({
|
|
type: RECEIVE_ARCHIVE,
|
|
value: json.features,
|
|
});
|
|
|
|
const reviveToggle = archiveFeatureToggle => ({
|
|
type: REVIVE_TOGGLE,
|
|
value: archiveFeatureToggle,
|
|
});
|
|
|
|
export function revive(featureToggle) {
|
|
return dispatch =>
|
|
api
|
|
.revive(featureToggle)
|
|
.then(() => dispatch(reviveToggle(featureToggle)))
|
|
.catch(dispatchError(dispatch, ERROR_RECEIVE_ARCHIVE));
|
|
}
|
|
|
|
export function fetchArchive() {
|
|
return dispatch =>
|
|
api
|
|
.fetchAll()
|
|
.then(json => dispatch(receiveArchive(json)))
|
|
.catch(dispatchError(dispatch, ERROR_RECEIVE_ARCHIVE));
|
|
}
|