- Cleanup

This commit is contained in:
2019-08-06 01:36:08 -04:00
parent 6e71ac688a
commit b8ddc54b99
43 changed files with 361 additions and 170 deletions

View File

@@ -1,7 +1,7 @@
import { SET_ITEM_FILTER } from '../constants/actionTypes.js';
import { SET_AUCTION_FILTER } from '../constants/actionTypes.js';
import { ITEM_FILTERS } from '../constants/constants.js';
export const itemFilter = (state = ITEM_FILTERS.ALL, action) => {
export const auctionFilter = (state = ITEM_FILTERS.ALL, action) => {
switch (action.type) {
case SET_AUCTION_FILTER:
return action.payload;

14
app/reducers/auth.js Normal file
View File

@@ -0,0 +1,14 @@
import { LOGIN_SUCCESS, SET_AUTH, UNSET_AUTH } from '../constants/actionTypes.js';
export const auth = (state = null, action) => {
switch (action.type) {
case LOGIN_SUCCESS:
return action.payload.token;
case SET_AUTH:
return action.payload;
case UNSET_AUTH:
return null;
default:
return state;
}
};

View File

@@ -5,12 +5,11 @@ import { EVENTS_LOADED, GET_EVENTS } from '../constants/actionTypes.js';
export const events = (state = new Map(), action) => {
switch (action.type) {
case EVENTS_LOADED:
return state.merge(
action.payload.toMap().mapEntries((entry) => {
const mapped = action.payload.toMap().mapEntries((entry) => {
const [, event] = entry;
return [`${event.id}`, event];
}),
);
});
return state.merge(mapped);
case GET_EVENTS:
default:
return state;

View File

@@ -5,9 +5,11 @@ import { activeItem } from './activeItem.js';
import { auctionFilter } from './auctionFilter.js';
import { auctions } from './auctions.js';
import { auctionView } from './auctionView.js';
import { auth } from './auth.js';
import { blockUI } from './blockUI.js';
import { events } from './events.js';
import { items } from './items.js';
import { profile } from './profile.js';
const rootReducer = combineReducers({
activeEvent,
@@ -15,9 +17,11 @@ const rootReducer = combineReducers({
auctionFilter,
auctions,
auctionView,
auth,
blockUI,
events,
items,
profile,
});
export default rootReducer;

View File

@@ -1,14 +1,20 @@
import { Map } from 'immutable';
import {
LOGIN_SUCCESS,
SET_PROFILE,
UNSET_PROFILE,
UPDATE_PROFILE,
} from '../constants/actionTypes.js';
export const profile = (state = new Map(), action) => {
switch (action.type) {
case LOGIN_SUCCESS:
return action.payload.user;
case SET_PROFILE:
return action.payload;
case UNSET_PROFILE:
return new Map();
case UPDATE_PROFILE:
return action.payload;
default: