Skip to content

Commit

Permalink
fix: reset all states in TimerListAlert and add refresh of timer list…
Browse files Browse the repository at this point in the history
… view
  • Loading branch information
vhu-axelor committed Feb 9, 2024
1 parent 761d5f8 commit 4bae1ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const DraftTimesheetPicker = ({
)} - ${formatDate(item.toDate, I18n.t('Base_DateFormat'))}`;
};

if (!Array.isArray(draftTimesheetList) || draftTimesheetList.length === 0) {
return null;
}

return (
<Picker
style={style}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const TimerListAlert = ({
);
};

const handleCancel = () => {
const resetStates = () => {
setIsAlertVisible(false);
setTimesheet(null);
setFromDate(null);
Expand Down Expand Up @@ -152,7 +152,7 @@ const TimerListAlert = ({
}),
);
}
setIsAlertVisible(false);
resetStates();
navigation.navigate('TimesheetListScreen');
};

Expand All @@ -162,7 +162,7 @@ const TimerListAlert = ({
visible={isAlertVisible}
title={I18n.t('Hr_SelectTimers')}
cancelButtonConfig={{
onPress: handleCancel,
onPress: resetStates,
}}
confirmButtonConfig={{
width: 50,
Expand Down
13 changes: 10 additions & 3 deletions packages/apps/hr/src/features/timesheetSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
fetchTimesheetToValidate as _fetchTimesheetToValidate,
updateTimesheetStatus as _updateTimesheetStatus,
} from '../api/timesheet-api';
import {fetchTimer} from './timerSlice';

export const fetchTimesheet = createAsyncThunk(
'timesheet/fetchTimesheet',
Expand Down Expand Up @@ -93,9 +94,13 @@ export const createTimesheet = createAsyncThunk(
action: 'Hr_SliceAction_CreateTimesheet',
getState,
responseOptions: {isArrayResponse: false},
}).then(() => {
dispatch(fetchTimesheet({userId: data.userId}));
});
})
.then(() => {
dispatch(fetchTimesheet({userId: data.userId}));
})
.then(() => {
dispatch(fetchTimer({userId: data.userId}));
});
},
);

Expand All @@ -108,6 +113,8 @@ export const addTimerTimesheet = createAsyncThunk(
action: 'Hr_SliceAction_AddTimerTimesheet',
getState,
responseOptions: {isArrayResponse: false},
}).then(() => {
dispatch(fetchTimer({userId: data.userId}));
});
},
);
Expand Down

0 comments on commit 4bae1ce

Please sign in to comment.