Stub out action creators. NEXT: Implement reducers

pull/438/head
Rick Carlino 2017-08-31 08:20:44 -05:00
parent 25c8c43fb5
commit d16217b603
4 changed files with 17 additions and 6 deletions

View File

@ -7,7 +7,6 @@ import { generateUuid } from "../resources/util";
let ID_COUNTER = 0;
// tslint:disable-next-line:max-line-length
export function fakeResource<T extends Name,
U extends TaggedResource["body"]>(kind: T, body: U): Res<T, U> {
return {

View File

@ -8,7 +8,7 @@ import {
import { GetState, ReduxAction } from "../redux/interfaces";
import { API } from "./index";
import axios from "axios";
import { updateOK, updateNO, destroyOK, destroyNO } from "../resources/actions";
import { updateOK, updateNO, destroyOK, destroyNO, GeneralizedError } from "../resources/actions";
import { UnsafeError } from "../interfaces";
import { findByUuid } from "../resources/reducer";
import { generateUuid } from "../resources/util";
@ -112,6 +112,13 @@ export function refresh(resource: TaggedResource) {
};
}
function refreshOK(payload: TaggedResource): ReduxAction<TaggedResource> {
return { type: Actions.REFRESH_RESOURCE_OK, payload };
}
function refreshNO(payload: GeneralizedError): ReduxAction<GeneralizedError> {
return { type: Actions.REFRESH_RESOURCE_NO, payload };
}
function update(uuid: string) {
return function (dispatch: Function, getState: GetState) {

View File

@ -332,6 +332,9 @@ export enum Actions {
SAVE_RESOURCE_START = "SAVE_RESOURCE_START",
RESOURCE_READY = "RESOURCE_READY",
_RESOURCE_NO = "*_RESOURCE_NO",
REFRESH_RESOURCE_START = "REFRESH_RESOURCE_START",
REFRESH_RESOURCE_OK = "REFRESH_RESOURCE_OK",
REFRESH_RESOURCE_NO = "REFRESH_RESOURCE_NO",
// Auth
LOGIN_OK = "LOGIN_OK",

View File

@ -15,13 +15,15 @@ export function destroyOK(payload: TaggedResource) {
return { type: Actions.DESTROY_RESOURCE_OK, payload };
}
export interface GeneralizedError {
err: UnsafeError;
uuid: string;
}
/** Generalized error handler when there are not special error handling
* requirements */
function generalizedError(payload: UnsafeError) {
function generalizedError(payload: GeneralizedError) {
toastErrors(payload);
return {
type: "*_RESOURCE_NO", payload
};
return { type: "*_RESOURCE_NO", payload };
}
export let destroyNO = generalizedError;