Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: #277 order entries by start_date desc
  • Loading branch information
enriquezrene committed Jun 1, 2020
commit 2de96a180cae3c7764165924055dc26347c3e097
6 changes: 4 additions & 2 deletions src/app/modules/time-clock/store/entry.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
}

case EntryActionTypes.CREATE_ENTRY_SUCCESS: {
const entryList = [action.payload, ...state.entryList];
entryList.sort((a, b) => new Date(b.start_date).getTime() - new Date(a.start_date).getTime());
return {
...state,
active: action.payload,
entryList: [action.payload, ...state.entryList],
entryList,
isLoading: false,
createError: false,
message: 'You clocked-in successfully',
Expand Down Expand Up @@ -151,9 +153,9 @@ export const entryReducer = (state: EntryState = initialState, action: EntryActi
const entryList = [...state.entryList];
const index = entryList.findIndex((entry) => entry.id === action.payload.id);
entryList[index] = action.payload;
entryList.sort((a, b) => b.start_date.getTime() - a.start_date.getTime());
return {
...state,
entryList,
isLoading: false,
updateError: false,
};
Expand Down