Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 06e071c

Browse files
committed
Fixed (regression): 'Process Payments' button and other related controls are not disabled when processing payments.
1 parent 6de41de commit 06e071c

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/store/actions/workPeriods.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export const toggleWorkingPeriodsVisible = (on = null) => ({
384384
* @param {?boolean} on whether to turn processing-payments state on or off
385385
* @returns {Object}
386386
*/
387-
export const toggleWorkPeriodsProcessingPeyments = (on = null) => ({
387+
export const toggleWorkPeriodsProcessingPayments = (on = null) => ({
388388
type: ACTION_TYPE.WP_TOGGLE_PROCESSING_PAYMENTS,
389389
payload: on,
390390
});

src/store/thunks/workPeriods.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,26 @@ export const updateWorkPeriodWorkingDays =
293293
* @param {function} getState function returning redux store root state
294294
*/
295295
export const processPayments = async (dispatch, getState) => {
296-
dispatch(actions.toggleWorkPeriodsProcessingPeyments(true));
297296
const state = getState();
297+
const isProcessing = selectors.getWorkPeriodsIsProcessingPayments(state);
298+
if (isProcessing) {
299+
return;
300+
}
301+
dispatch(actions.toggleWorkPeriodsProcessingPayments(true));
298302
const isSelectedAll = selectors.getWorkPeriodsIsSelectedAll(state);
299303
const { pageSize, totalCount } = selectors.getWorkPeriodsPagination(state);
300-
if (isSelectedAll && totalCount > pageSize) {
301-
processPaymentsAll(dispatch, getState);
302-
} else {
303-
processPaymentsSpecific(dispatch, getState);
304+
const promise =
305+
isSelectedAll && totalCount > pageSize
306+
? processPaymentsAll(dispatch, getState)
307+
: processPaymentsSpecific(dispatch, getState);
308+
// The promise returned by processPaymentsAll or processPaymentsSpecific
309+
// should never be rejected but adding try-catch block just in case.
310+
try {
311+
await promise;
312+
} catch (error) {
313+
console.error(error);
304314
}
305-
dispatch(actions.toggleWorkPeriodsProcessingPeyments(false));
315+
dispatch(actions.toggleWorkPeriodsProcessingPayments(false));
306316
};
307317

308318
const processPaymentsAll = async (dispatch, getState) => {

0 commit comments

Comments
 (0)