Skip to content

Commit

Permalink
fix: can't re-open declare form after one declaration (#399)
Browse files Browse the repository at this point in the history
* RM#75193
  • Loading branch information
vhu-axelor authored and lme-axelor committed Feb 14, 2024
1 parent fb29bd5 commit 5f39fc6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 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 All @@ -140,6 +140,7 @@ const TimerListAlert = ({
timesheetId: timesheet?.id,
version: timesheet?.version,
timerIdList,
userId,
}),
);
} else {
Expand All @@ -152,6 +153,7 @@ const TimerListAlert = ({
}),
);
}
resetStates();
navigation.navigate('TimesheetListScreen');
};

Expand All @@ -161,7 +163,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 5f39fc6

Please sign in to comment.