Skip to content

Commit 939ce2f

Browse files
authored
fix: add org name and cost center normalization when getting active orgs for userWidget (#194)
1 parent cb9ea06 commit 939ce2f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

react/components/UserWidget.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,28 +463,27 @@ const UserWidget: VtexFunctionComponent<UserWidgetProps> = ({
463463

464464
const handleSearchOrganizations = (e: any) => {
465465
const { value }: { value: string } = e.target
466-
let dataList
466+
let dataList;
467467

468468
setSearchTerm(e.target.value)
469469

470470
dataList = userWidgetData?.getActiveOrganizationsByEmail?.sort(
471471
sortOrganizations
472472
)
473-
474473
if (value.trim() !== '') {
475474
dataList =
476475
userWidgetData?.getActiveOrganizationsByEmail
477476
?.filter((organization: any) => {
477+
const organizationName = organization.organizationName?.toLowerCase() || '';
478+
const costCenterName = organization.costCenterName?.toLowerCase() || '';
479+
const searchValue = value.toLowerCase();
480+
478481
return (
479-
organization.organizationName
480-
.toLowerCase()
481-
.includes(value.toLowerCase()) ||
482-
organization.costCenterName
483-
.toLowerCase()
484-
.includes(value.toLowerCase())
485-
)
482+
organizationName.includes(searchValue) ||
483+
costCenterName.includes(searchValue)
484+
);
486485
})
487-
?.slice(0, 15) ?? []
486+
?.slice(0, 15) ?? [];
488487
}
489488

490489
setOrganizationsState({

0 commit comments

Comments
 (0)