Skip to content

Commit

Permalink
Merge branch 'master' into feat/list-custom-fields-cost-centers
Browse files Browse the repository at this point in the history
  • Loading branch information
Josmar-jr authored Jul 17, 2024
2 parents 51015d8 + 45de0c9 commit e0d74e4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Changes listing of custom fields from organization to cost center

## [1.32.0] - 2024-07-17

### Fixed

- Adjust search list many organations at change organization modal

## [1.31.11] - 2024-07-05

## [1.31.10] - 2024-07-03
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "b2b-organizations",
"vendor": "vtex",
"version": "1.31.11",
"version": "1.32.0",
"title": "B2B Organizations",
"description": "App to create and manage B2B Organizations and Cost Centers",
"mustUpdateAt": "2022-08-28",
Expand Down
62 changes: 37 additions & 25 deletions react/components/UserWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,27 +321,6 @@ const UserWidget: VtexFunctionComponent<UserWidgetProps> = ({
value: organizationsState.costCenterInput,
}

useEffect(() => {
const dataList = userWidgetData?.getOrganizationsByEmail
?.filter((organization: any) => {
return (
organization.organizationName
.toLowerCase()
.includes(searchTerm.toLowerCase()) ||
organization.costCenterName
.toLowerCase()
.includes(searchTerm.toLowerCase())
)
})
.sort(sortOrganizations)

setOrganizationsState({
...organizationsState,
dataList,
totalDataList: dataList?.length,
})
}, [searchTerm])

useEffect(() => {
if (!userWidgetData?.getOrganizationsByEmail) {
return
Expand Down Expand Up @@ -480,6 +459,37 @@ const UserWidget: VtexFunctionComponent<UserWidgetProps> = ({
)
return null

const handleSearchOrganizations = (e: any) => {
const { value }: { value: string } = e.target
let dataList

setSearchTerm(e.target.value)

dataList = userWidgetData?.getOrganizationsByEmail?.sort(sortOrganizations)

if (value.trim() !== '') {
dataList =
userWidgetData?.getOrganizationsByEmail
?.filter((organization: any) => {
return (
organization.organizationName
.toLowerCase()
.includes(value.toLowerCase()) ||
organization.costCenterName
.toLowerCase()
.includes(value.toLowerCase())
)
})
?.slice(0, 15) ?? []
}

setOrganizationsState({
...organizationsState,
dataList,
totalDataList: dataList?.length,
})
}

return (
<div
className={`${handles.userWidgetContainer} w-100 flex flex-column mv3 bg-base--inverted`}
Expand All @@ -498,13 +508,15 @@ const UserWidget: VtexFunctionComponent<UserWidgetProps> = ({
</h1>
<div className={`${handles.userWidgetModalInput} flex`}>
<Input
onChange={(e: any) => setSearchTerm(e.target.value)}
onChange={handleSearchOrganizations}
value={searchTerm}
placeholder={`${formatMessage(messages.search)}...`}
/>
<Button variation="primary">
{formatMessage(messages.search)}
</Button>
<div className="ml4">
<Button variation="primary">
{formatMessage(messages.search)}
</Button>
</div>
</div>
<div className={`${handles.userWidgetModalTotal} pt4 mb4`}>
{organizationsState?.totalDataList}{' '}
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vtex.b2b-organizations",
"version": "1.31.11",
"version": "1.32.0",
"license": "UNLICENSED",
"scripts": {
"test": "vtex-test-tools test --passWithNoTests"
Expand Down

0 comments on commit e0d74e4

Please sign in to comment.