Skip to content

Commit

Permalink
Feat: ORV2-1500 another update on company search (#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikataot authored Jan 17, 2024
1 parent a40878a commit 04a1696
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
18 changes: 16 additions & 2 deletions frontend/src/features/idir/search/api/idirSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ import {
PaginationOptions
} from "../../../../common/types/common";
import { Permit } from "../../../permits/types/permit";
import { SearchFields } from "../types/types";
import { SEARCH_ENTITIES, SearchEntity, SearchFields } from "../types/types";

const getSearchURLbyEntity = (searchEntity: SearchEntity): string | URL => {
let url = "";
switch(searchEntity) {
case SEARCH_ENTITIES.APPLICATION:
case SEARCH_ENTITIES.PERMIT:
url = `${VEHICLES_URL}/${searchEntity}/ppc/search`;
break;
case SEARCH_ENTITIES.COMPANY:
url = `${VEHICLES_URL}/${searchEntity}/paginated`;
break;
}
return url;
}

/**
* Searches the data with options and value entered by the user.
Expand All @@ -16,7 +30,7 @@ export const getDataBySearch = (
{ searchEntity, searchByFilter, searchValue }: SearchFields,
{ page = 0, take = 10 }: PaginationOptions,
): Promise<PaginatedResponse<Permit>> => {
const searchURL = new URL(`${VEHICLES_URL}/${searchEntity}/ppc/search`);
const searchURL = new URL(getSearchURLbyEntity(searchEntity));
searchURL.searchParams.set("searchColumn", searchByFilter);
searchURL.searchParams.set("searchString", searchValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const CompanySearchResultColumnDef: MRT_ColumnDef<CompanyProfile>[] = [
sortingFn: "alphanumeric",
},
{
accessorKey: "migratedClientHash",
header: "Client Number",
accessorKey: "clientNumber",
header: "onRouteBC Client Number",
enableSorting: true,
sortingFn: "alphanumeric",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ export class CompanyController {
clientNumber,
);

if (!companies?.items?.length) {
throw new DataNotFoundException();
}

return companies;
}

Expand Down

0 comments on commit 04a1696

Please sign in to comment.