diff --git a/packages/apps/hr/src/components/templates/DraftTimesheetPicker/DraftTimesheetPicker.tsx b/packages/apps/hr/src/components/templates/DraftTimesheetPicker/DraftTimesheetPicker.tsx index 2182e3f3c6..8e873b4686 100644 --- a/packages/apps/hr/src/components/templates/DraftTimesheetPicker/DraftTimesheetPicker.tsx +++ b/packages/apps/hr/src/components/templates/DraftTimesheetPicker/DraftTimesheetPicker.tsx @@ -60,6 +60,10 @@ const DraftTimesheetPicker = ({ )} - ${formatDate(item.toDate, I18n.t('Base_DateFormat'))}`; }; + if (!Array.isArray(draftTimesheetList) || draftTimesheetList.length === 0) { + return null; + } + return ( { + const resetStates = () => { setIsAlertVisible(false); setTimesheet(null); setFromDate(null); @@ -140,6 +140,7 @@ const TimerListAlert = ({ timesheetId: timesheet?.id, version: timesheet?.version, timerIdList, + userId, }), ); } else { @@ -152,6 +153,7 @@ const TimerListAlert = ({ }), ); } + resetStates(); navigation.navigate('TimesheetListScreen'); }; @@ -161,7 +163,7 @@ const TimerListAlert = ({ visible={isAlertVisible} title={I18n.t('Hr_SelectTimers')} cancelButtonConfig={{ - onPress: handleCancel, + onPress: resetStates, }} confirmButtonConfig={{ width: 50, diff --git a/packages/apps/hr/src/features/timesheetSlice.js b/packages/apps/hr/src/features/timesheetSlice.js index 790d9eb00e..8027727464 100644 --- a/packages/apps/hr/src/features/timesheetSlice.js +++ b/packages/apps/hr/src/features/timesheetSlice.js @@ -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', @@ -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})); + }); }, ); @@ -108,6 +113,8 @@ export const addTimerTimesheet = createAsyncThunk( action: 'Hr_SliceAction_AddTimerTimesheet', getState, responseOptions: {isArrayResponse: false}, + }).then(() => { + dispatch(fetchTimer({userId: data.userId})); }); }, );