
import {action} from '../foundation/util';

const SET_UNKNOWN = 'SET_UNKNOWN';
const SET_AUTHORIZED = 'SET_AUTHORIZED';
const SET_UNAUTHORIZED = 'SET_UNAUTHORIZED';

export let setUnknown = action(SET_UNKNOWN);
export let setAuthorized = action(SET_AUTHORIZED);
export let setUnauthorized = action(SET_UNAUTHORIZED);

export function reducer(state = 'unknown', action) {
    switch (action.type) {
        case SET_UNKNOWN:
            return 'unknown';

        case SET_AUTHORIZED:
            return true;

        case SET_UNAUTHORIZED:
            return false;

        default:
            return state;
    }
}
