Skip to content

Commit

Permalink
Merge pull request #972 from singnet/ui-fix
Browse files Browse the repository at this point in the history
[SPT-400] fixed reset organizations filter
  • Loading branch information
MarinaFedy authored Jan 20, 2025
2 parents e325d3f + c9ff24d commit 1a0fd75
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions src/components/AiMarketplace/MainSection/Filter/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { connect } from "react-redux";
import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import Grid from "@mui/material/Grid";

import { useStyles } from "./styles";
Expand All @@ -13,21 +13,19 @@ import {
generateOrganizationsFilterObject,
} from "../../../../utility/constants/Pagination";

const Filter = ({
listView,
total_count,
handleSearchChange,
toggleView,
currentPagination,
showToggler,
filterDataProps,
pagination,
handleFilterChange,
}) => {
const Filter = ({ listView, total_count, handleSearchChange, toggleView, currentPagination, showToggler }) => {
const { filterData, pagination } = useSelector((state) => state.serviceReducer);

const [showSearchInput, toggleSearchInput] = useState(false);
const [searchKeyword, setSearchKeyword] = useState("");
const [activeOrgItem, setActiveOrgItem] = useState("default");

const dispatch = useDispatch();

useEffect(() => {
return () => dispatch(serviceActions.resetFilter({ pagination }));
}, []);

const handleSearch = (event) => {
setSearchKeyword(event.currentTarget.value);
const pagination = {
Expand All @@ -37,7 +35,7 @@ const Filter = ({
handleSearchChange({ ...currentPagination, ...pagination });
};

const enhancedFilterData = filterDataProps.org_id.map((el) => ({
const enhancedFilterData = filterData.org_id.map((el) => ({
value: el.key,
label: el.value,
}));
Expand All @@ -56,7 +54,7 @@ const Filter = ({
const currentActiveFilterData = { [name]: [value] };

const latestPagination = { ...pagination, ...defaultPaginationParameters, q: pagination.q };
handleFilterChange({ pagination: latestPagination, filterObj, currentActiveFilterData });
dispatch(serviceActions.handleFilterChange({ pagination: latestPagination, filterObj, currentActiveFilterData }));
};

const classes = useStyles();
Expand Down Expand Up @@ -96,13 +94,4 @@ const Filter = ({
);
};

const mapStateToProps = (state) => ({
filterDataProps: state.serviceReducer.filterData,
pagination: state.serviceReducer.pagination,
});

const mapDispatchToProps = (dispatch) => ({
handleFilterChange: (args) => dispatch(serviceActions.handleFilterChange(args)),
});

export default connect(mapStateToProps, mapDispatchToProps)(Filter);
export default Filter;

0 comments on commit 1a0fd75

Please sign in to comment.