added timeticket redux
This commit is contained in:
51
redux/timetickets/timetickets.reducer.js
Normal file
51
redux/timetickets/timetickets.reducer.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import TimeTicketsActionTypes from "./timetickets.types";
|
||||
|
||||
const INITIAL_STATE = {
|
||||
timeTicket: null,
|
||||
timeTickets: [],
|
||||
timeTicketJobId: null,
|
||||
timeTicketJob: null,
|
||||
uploadTimeTicketInProgress: false,
|
||||
uploadTimeTicketError: null,
|
||||
};
|
||||
|
||||
const timeTicketsReducer = (state = INITIAL_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case TimeTicketsActionTypes.SET_TIME_TICKET:
|
||||
return {
|
||||
...state,
|
||||
timeTicket: action.payload,
|
||||
};
|
||||
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB_ID:
|
||||
return {
|
||||
...state,
|
||||
timeTicketJobId: action.payload,
|
||||
};
|
||||
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB:
|
||||
return {
|
||||
...state,
|
||||
timeTicketJob: action.payload,
|
||||
};
|
||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_START:
|
||||
return {
|
||||
...state,
|
||||
uploadTimeTicketInProgress: true,
|
||||
};
|
||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_SUCCESS:
|
||||
return {
|
||||
...state, //TODO add logic here when successful
|
||||
uploadTimeTicketInProgress: false,
|
||||
uploadTimeTicketError: null,
|
||||
};
|
||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
uploadTimeTicketInProgress: false,
|
||||
uploadTimeTicketError: action.payload,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default timeTicketsReducer;
|
||||
Reference in New Issue
Block a user