Skip to content

Commit

Permalink
[OSDEV-1152] Quickfix (backmerge): disable claim filter on data fetch (
Browse files Browse the repository at this point in the history
…#301)

Quickfix for https://opensupplyhub.atlassian.net/browse/OSDEV-1152

Disable filters while fetching facility claims.

Backmerge PR

---------

Co-authored-by: Oleksandr Mazur <[email protected]>
  • Loading branch information
VadimKovalenkoSNF and mazursasha1990 authored Jul 25, 2024
1 parent 55de881 commit 3818cf7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/react/src/components/DashboardClaims.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const DashboardClaims = ({
let finalStatuses = statuses;

if (countriesData.length > 0) {
if (!statuses && claimStatuses.length > 0) {
if (!statuses && claimStatuses && claimStatuses.length > 0) {
finalStatuses = map(claimStatuses, 'value');
}
} else if (claimStatuses.length > 0) {
Expand Down Expand Up @@ -167,8 +167,9 @@ const DashboardClaims = ({
<ClaimStatusFilter
countriesData={countriesData}
handleClaimStatusUpdate={onClaimStatusUpdate}
isDisabled={fetching}
/>
<CountryNameFilter />
<CountryNameFilter isDisabled={fetching} />
<Grid item className={classes.numberResults}>
{claimsCount} results
</Grid>
Expand Down
2 changes: 2 additions & 0 deletions src/react/src/components/DashboardClaimsListTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ function DashboardClaimsListTable({
order={order}
orderBy={orderBy}
onRequestSort={handleRequestSort}
fetching={fetching}
loading={loading}
/>
{loading || fetching ? (
<TableBody>
Expand Down
13 changes: 11 additions & 2 deletions src/react/src/components/DashboardClaimsListTableHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { func, string } from 'prop-types';
import { func, string, bool } from 'prop-types';
import TableHead from '@material-ui/core/TableHead';
import TableSortLabel from '@material-ui/core/TableSortLabel';
import TableRow from '@material-ui/core/TableRow';
Expand Down Expand Up @@ -57,7 +57,13 @@ const claimsListHeadCells = [
},
];

function DashboardClaimsListTableHeader({ order, orderBy, onRequestSort }) {
function DashboardClaimsListTableHeader({
order,
orderBy,
onRequestSort,
fetching,
loading,
}) {
const createSortHandler = property => event => {
onRequestSort(event, property);
};
Expand All @@ -74,6 +80,7 @@ function DashboardClaimsListTableHeader({ order, orderBy, onRequestSort }) {
active={orderBy === headCell.id}
direction={orderBy === headCell.id ? order : 'asc'}
onClick={createSortHandler(headCell.id)}
disabled={fetching || loading}
>
{headCell.label}
</TableSortLabel>
Expand All @@ -85,6 +92,8 @@ function DashboardClaimsListTableHeader({ order, orderBy, onRequestSort }) {
}

DashboardClaimsListTableHeader.propTypes = {
loading: bool.isRequired,
fetching: bool.isRequired,
order: string.isRequired,
orderBy: string.isRequired,
onRequestSort: func.isRequired,
Expand Down
5 changes: 4 additions & 1 deletion src/react/src/components/Filters/ClaimStatusFilter.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback } from 'react';
import { func } from 'prop-types';
import { func, bool } from 'prop-types';
import { connect } from 'react-redux';

import StyledSelect from './StyledSelect';
Expand All @@ -14,6 +14,7 @@ import {
const CLAIM_STATUSES = 'CLAIM_STATUSES';

function ClaimStatusFilter({
isDisabled,
claimStatuses,
countriesData,
claimStatusesOptions,
Expand All @@ -36,12 +37,14 @@ function ClaimStatusFilter({
options={claimStatusesOptions.data || []}
value={claimStatuses}
onChange={onChangeClaimStatus}
isDisabled={isDisabled}
/>
</div>
);
}

ClaimStatusFilter.propTypes = {
isDisabled: bool.isRequired,
updateClaimStatus: func.isRequired,
claimStatuses: claimStatusOptionsPropType.isRequired,
claimStatusesOptions: filterOptionsPropType.isRequired,
Expand Down
4 changes: 4 additions & 0 deletions src/react/src/components/Filters/CountryNameFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { countryOptionsPropType } from '../../util/propTypes';
const COUNTRIES = 'COUNTRIES';

function CountryNameFilter({
isDisabled,
countryOptions,
countries,
updateCountry,
Expand All @@ -25,16 +26,19 @@ function CountryNameFilter({
value={countries}
onChange={updateCountry}
disabled={fetching}
isDisabled={isDisabled}
/>
</div>
);
}

CountryNameFilter.defaultProps = {
isDisabled: false,
countryOptions: null,
};

CountryNameFilter.propTypes = {
isDisabled: bool,
countryOptions: countryOptionsPropType,
updateCountry: func.isRequired,
countries: countryOptionsPropType.isRequired,
Expand Down

0 comments on commit 3818cf7

Please sign in to comment.