Skip to content

Commit

Permalink
Initial setup for filtering by programType
Browse files Browse the repository at this point in the history
  • Loading branch information
mdial89f committed Jul 25, 2023
1 parent 34c7d5d commit 536b9a3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
69 changes: 41 additions & 28 deletions src/services/ui/src/api/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,45 @@ export type SearchData = {

export const getSearchData = async (
selectedState: string,
searchString: string
searchString: string,
programType: string
): Promise<{ hits: SearchData[] }> => {
let query = {};
if (searchString) {
query = {
from: 0,
size: 100,
query: {
bool: {
should: [
{
match: {
_id: {
query: searchString,
boost: 5,
},
},
},
{
match: {
"seatool.STATE_PLAN.ID_NUMBER": {
query: searchString,
fuzziness: "AUTO",
},
const query: any = {
from: 0,
size: 100,
query: {
bool: {
must: [
{
match: {
programType: {
query: programType,
},
},
],
},
],
},
},
};
if (searchString) {
query.query.bool.should = [
{
match: {
_id: {
query: searchString,
boost: 5,
},
},
},
{
match: {
"seatool.STATE_PLAN.ID_NUMBER": {
query: searchString,
fuzziness: "AUTO",
},
},
},
};
];
}
const searchData = await API.post("seatool", `/search/${selectedState}`, {
body: query,
Expand All @@ -53,12 +62,16 @@ export const useSearch = (
options?: UseMutationOptions<
{ hits: SearchData[] },
ReactQueryApiError,
{ selectedState: string; searchString: string }
{ selectedState: string; searchString: string; programType: string }
>
) => {
return useMutation<
{ hits: SearchData[] },
ReactQueryApiError,
{ selectedState: string; searchString: string }
>((props) => getSearchData(props.selectedState, props.searchString), options);
{ selectedState: string; searchString: string; programType: string }
>(
(props) =>
getSearchData(props.selectedState, props.searchString, props.programType),
options
);
};
2 changes: 2 additions & 0 deletions src/services/ui/src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export const Dashboard = () => {
const data = await mutateAsync({
selectedState,
searchString: searchText,
// programType: "WAIVER",
programType: "CHIP OR MEDICAID", // This should be set based on the 'tab' your in
});

setSearchData(data.hits);
Expand Down

0 comments on commit 536b9a3

Please sign in to comment.