Skip to content

Commit

Permalink
fix: modified filter features for improved functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mlowegene committed Apr 30, 2024
1 parent dbf8626 commit 7215b0b
Show file tree
Hide file tree
Showing 5 changed files with 446 additions and 417 deletions.
52 changes: 26 additions & 26 deletions src/models/TrustRelationShipFilter.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { getDateText } from "../utils/formatting";
import { getDateText } from '../utils/formatting';

export default class TrustRelationshipsFilter {
// possible query options
state;
type;
requestType;
before;
after;
constructor(options) {
// assign options properties to created instance
Object.assign(this, options);
}
// where object contains the query options
getWhereObj() {
let where = {};
if (this.state) where.state = this.state.toLowerCase();
if (this.type) where.type = this.type.toLowerCase();
if (this.requestType) where.requestType = this.requestType.toLowerCase();
if (this.before) where.before = getDateText(this.before, 'YYYY-MM-DD');
if (this.after) where.after = getDateText(this.after, 'YYYY-MM-DD');
return where;
}
}
// possible query options
state;
type;
request_type;
before;
after;

constructor(options) {
// assign options properties to created instance
Object.assign(this, options);
}

// where object contains the query options
getWhereObj() {
let where = {};

if (this.state) where.state = this.state.toLowerCase();
if (this.type) where.type = this.type.toLowerCase();
if (this.request_type) where.request_type = this.request_type.toLowerCase();
if (this.before) where.before = getDateText(this.before, 'YYYY-MM-DD');
if (this.after) where.after = getDateText(this.after, 'YYYY-MM-DD');

return where;
}
}
2 changes: 1 addition & 1 deletion src/pages/TrustRelationship/TrustRelationship.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('Trust Relationships page', function () {
);
expect(await screen.findByTestId('table-pagination')).toBeInTheDocument();
expect(await screen.findByTestId('trust-relationships-table')).toBeInTheDocument();
expect(await screen.findByTestId('date-range-filter')).toBeInTheDocument();
// expect(await screen.findByTestId('date-range-filter')).toBeInTheDocument();
expect(await screen.findByTestId('state-select-filter')).toBeInTheDocument();
expect(await screen.findByTestId('requestType-select-filter')).toBeInTheDocument();
expect(await screen.findByTestId('type-select-filter')).toBeInTheDocument();
Expand Down
184 changes: 92 additions & 92 deletions src/pages/TrustRelationship/TrustRelationshipTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,100 +33,100 @@ import {
TypeSelectFilter,
RequestTypeSelectFilter,
ResetButton,
DateRangeFilter
// DateRangeFilter
} from './TrustRelationshipsFilters';
import TrustRelationshipSidePanel from './trustRelationshipSidePanel';


const FilterDialog = ({anchorEl,
handleFilterClose,
filter,
setFilter,
statesList,
requestTypeList,
getStatusColor,
typeList,
defaultFilter
}) => {
return (
const FilterDialog = ({
anchorEl,
handleFilterClose,
filter,
setFilter,
statesList,
requestTypeList,
getStatusColor,
typeList,
defaultFilter,
}) => {
return (
<Menu
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleFilterClose}
>
<Grid container direction="column" sx={{ padding: '20px' }}>
<Grid
item
xs={5}
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
}}
>
<StateSelectFilter
filter={filter}
setFilter={setFilter}
statesList={statesList}
getStatusColor={getStatusColor}
/>
<RequestTypeSelectFilter
filter={filter}
setFilter={setFilter}
requestTypeList={requestTypeList}
getStatusColor={getStatusColor}
/>
<TypeSelectFilter
filter={filter}
setFilter={setFilter}
typeList={typeList}
getStatusColor={getStatusColor}
/>
<DateRangeFilter filter={filter} setFilter={setFilter} />
</Grid>
<Grid
item
xs={5}
sx={{
display: 'flex',
justifyContent: 'flex-end',
paddingBottom: '20px',
}}
></Grid>
<Grid
item
xs={2}
sx={{
display: 'flex',
justifyContent: 'space-around',
alignItems: 'center',
margin: '10px auto',
gap: '10px',
}}
>
<ResetButton
close={handleFilterClose}
setFilter={setFilter}
defaultFilter={defaultFilter}
/>
<button
style={{
color: 'black',
border: 'none',
backgroundColor: 'rgba(114, 185, 7, 0.192)',
padding: '8px 20px',
borderRadius: '2rem',
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleFilterClose}
>
<Grid container direction="column" sx={{ padding: '20px' }}>
<Grid
item
xs={5}
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
}}
>
<StateSelectFilter
filter={filter}
setFilter={setFilter}
statesList={statesList}
getStatusColor={getStatusColor}
/>
<RequestTypeSelectFilter
filter={filter}
setFilter={setFilter}
requestTypeList={requestTypeList}
getStatusColor={getStatusColor}
/>
<TypeSelectFilter
filter={filter}
setFilter={setFilter}
typeList={typeList}
getStatusColor={getStatusColor}
/>
{/* <DateRangeFilter filter={filter} setFilter={setFilter} /> */}
</Grid>
<Grid
item
xs={5}
sx={{
display: 'flex',
justifyContent: 'flex-end',
paddingBottom: '20px',
}}
></Grid>
<Grid
item
xs={2}
sx={{
display: 'flex',
justifyContent: 'space-around',
alignItems: 'center',
margin: '10px auto',
gap: '10px',
}}
onClick={handleFilterClose}
>
<h4> Apply</h4>
</button>
<ResetButton
close={handleFilterClose}
setFilter={setFilter}
defaultFilter={defaultFilter}
/>
<button
style={{
color: 'black',
border: 'none',
backgroundColor: 'rgba(114, 185, 7, 0.192)',
padding: '8px 20px',
borderRadius: '2rem',
}}
onClick={handleFilterClose}
>
<h4> Apply</h4>
</button>
</Grid>
</Grid>
</Grid>
</Menu>
)
}
</Menu>
);
};

const TrustRelationshipTableHeader = ({ tableTitle, getStatusColor }) => {
const {
Expand Down Expand Up @@ -199,9 +199,9 @@ const TrustRelationshipTableHeader = ({ tableTitle, getStatusColor }) => {
Filters
<FilterListIcon style={{ color: '#86C232', marginLeft: '8px' }} />
</FilterButton>
<FilterDialog
<FilterDialog
anchorEl={anchorEl}
handleFilterClose={handleFilterClose}
handleFilterClose={handleFilterClose}
filter={filter}
setFilter={setFilter}
statesList={statesList}
Expand Down Expand Up @@ -415,9 +415,9 @@ function TrustRelationshipTable({ tableTitle, tableRows, totalRowCount }) {
case 'created_at':
newSortBy = 'created_at';
break;
case 'updated_at':
newSortBy = 'updated_at';
break;
case 'updated_at':
newSortBy = 'updated_at';
break;
default:
newSortBy = columnName;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/TrustRelationship/TrustRelationshipTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const TestWrapper = (props) => {
expect(
await screen.findByTestId('trust-relationships-table'),
).toBeInTheDocument();
expect(await screen.findByTestId('date-range-filter')).toBeInTheDocument();
// expect(await screen.findByTestId('date-range-filter')).toBeInTheDocument();
expect(
await screen.findByTestId('state-select-filter'),
).toBeInTheDocument();
Expand Down
Loading

0 comments on commit 7215b0b

Please sign in to comment.