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

Commit 7cfbc12

Browse files
committed
Fixes for popups and pagination.
Fixed: popups caused unwanted scrollbar. Fixed: switching failed payments' toggle didn't reset page number.
1 parent d01eced commit 7cfbc12

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

src/components/Popup/index.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const Popup = ({ children, className, referenceElement }) => {
99
const [arrowElement, setArrowElement] = useState(null);
1010
const { styles, attributes } = usePopper(referenceElement, popperElement, {
1111
placement: "bottom",
12+
strategy: "fixed",
1213
modifiers: [
1314
{ name: "arrow", options: { element: arrowElement, padding: 10 } },
1415
{ name: "offset", options: { offset: [0, 5] } },

src/store/actions/workPeriods.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as ACTION_TYPE from "store/actionTypes/workPeriods";
44
let nextErrorId = 1;
55

66
/**
7-
* Creates an action denoting the start of loading specific challenge page.
7+
* Creates an action denoting the start of loading specific working period page.
88
*
99
* @param {Object} cancelSource object that can be used to cancel network request
1010
* @returns {Object}
@@ -17,14 +17,15 @@ export const loadWorkPeriodsPagePending = (cancelSource) => ({
1717
/**
1818
* Creates an action denoting the saving of fetched working periods' page.
1919
*
20-
* @param {Array} periods array of challenge objects
21-
* @param {number} totalCount total number of periods for current filters' state
22-
* @param {number} pageCount total number of pages
20+
* @param {Object} payload action payload
21+
* @param {Array} payload.periods array of working period objects
22+
* @param {number} payload.totalCount total number of periods for current filters' state
23+
* @param {number} payload.pageCount total number of pages
2324
* @returns {Object}
2425
*/
25-
export const loadWorkPeriodsPageSuccess = (periods, totalCount, pageCount) => ({
26+
export const loadWorkPeriodsPageSuccess = (payload) => ({
2627
type: ACTION_TYPE.WP_LOAD_PAGE_SUCCESS,
27-
payload: { periods, totalCount, pageCount },
28+
payload,
2829
});
2930

3031
/**

src/store/reducers/workPeriods.js

+4
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ const actionHandlers = {
610610
...filters,
611611
onlyFailedPayments: on,
612612
},
613+
pagination: {
614+
...state.pagination,
615+
pageNumber: 1,
616+
},
613617
};
614618
},
615619
[ACTION_TYPE.WP_TOGGLE_PERIOD]: (state, periodId) => {

src/store/thunks/workPeriods.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const loadWorkPeriodsPage = async (dispatch, getState) => {
6464

6565
// For parameter description see:
6666
// https://topcoder-platform.github.io/taas-apis/#/ResourceBookings/get_resourceBookings
67-
const params = {
67+
const [promise, cancelSource] = services.fetchResourceBookings({
6868
fields: API_FIELDS_QUERY,
6969
page: pagination.pageNumber,
7070
perPage: pagination.pageSize,
@@ -75,11 +75,10 @@ export const loadWorkPeriodsPage = async (dispatch, getState) => {
7575
["workPeriods.userHandle"]: userHandle,
7676
["workPeriods.startDate"]: startDate.format(DATE_FORMAT_API),
7777
["workPeriods.paymentStatus"]: paymentStatuses,
78-
};
79-
if (onlyFailedPayments) {
80-
params["workPeriods.payments.status"] = API_CHALLENGE_PAYMENT_STATUS.FAILED;
81-
}
82-
const [promise, cancelSource] = services.fetchResourceBookings(params);
78+
["workPeriods.payments.status"]: onlyFailedPayments
79+
? API_CHALLENGE_PAYMENT_STATUS.FAILED
80+
: null,
81+
});
8382
dispatch(actions.loadWorkPeriodsPagePending(cancelSource));
8483
let totalCount, periods, pageCount;
8584
try {
@@ -95,7 +94,13 @@ export const loadWorkPeriodsPage = async (dispatch, getState) => {
9594
}
9695
return;
9796
}
98-
dispatch(actions.loadWorkPeriodsPageSuccess(periods, totalCount, pageCount));
97+
dispatch(
98+
actions.loadWorkPeriodsPageSuccess({
99+
periods,
100+
totalCount,
101+
pageCount,
102+
})
103+
);
99104
};
100105

101106
/**

src/styles/mixins/_screenSizes.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'variables/screenSizes';
1+
@import "variables/screenSizes";
22

33
// There's no need for phone() mixin for phone and larger screens to exist
44
// because styles for these screens are simply added without media queries.

src/styles/variables/_screenSizes.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ $screen-codes: phone tablet desktop desktop-lg;
22

33
// This map defines minimum screen widths for different devices.
44
$screen-sizes: (
5-
'phone': 320px,
6-
'tablet': 768px,
7-
'desktop': 1280px,
5+
"phone": 320px,
6+
"tablet": 768px,
7+
"desktop": 1280px,
88
);
99

1010
// Media queries' mixins will use minimum screen widths from this map.
@@ -20,7 +20,7 @@ $screen-min-px: ();
2020
$screen-min-px: map-merge(
2121
$screen-min-px,
2222
(
23-
'desktop-lg': 1920px,
23+
"desktop-lg": 1920px,
2424
)
2525
);
2626

0 commit comments

Comments
 (0)