From 6665243ac64f8cff48d192b75779f8166dc1caf6 Mon Sep 17 00:00:00 2001 From: vhu-axelor <146069039+vhu-axelor@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:57:10 +0100 Subject: [PATCH] fix: can't re-open declare form after one declaration (#399) * RM#75193 --- .../DraftTimesheetPicker/DraftTimesheetPicker.tsx | 4 ++++ .../templates/TimerListAlert/TimerListAlert.tsx | 6 ++++-- packages/apps/hr/src/features/timesheetSlice.js | 13 ++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) 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})); }); }, );