diff --git a/CHANGELOG.md b/CHANGELOG.md index 296657a2..6b87bddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + +- Adjusts list organization and research screening according to input at autocomplete ## [1.31.8] - 2024-06-05 diff --git a/react/components/UserWidget.tsx b/react/components/UserWidget.tsx index 354eb482..43fc2ab3 100644 --- a/react/components/UserWidget.tsx +++ b/react/components/UserWidget.tsx @@ -108,10 +108,8 @@ const CustomOrganizationOption = (props: any) => { disabled={value.status !== 'active'} >
- {renderOptionHighlightedText()} - {typeof value !== 'string' && ( -
{value.caption}
- )} + {renderOptionHighlightedText()} + {typeof value !== 'string' &&
{value.caption}
}
) @@ -285,6 +283,25 @@ const UserWidget: VtexFunctionComponent = ({ setOrganizationsState({ ...organizationsState, organizationInput: text, + organizationOptions: + userWidgetData?.getOrganizationsByEmail + ?.filter((organization: any) => { + return organization?.organizationName + ?.toLowerCase() + .includes(text?.toLowerCase()) + }) + .map( + (organization: { + orgId: string + organizationName: string + organizationStatus: string + }) => ({ + value: organization.orgId, + label: organization.organizationName, + status: organization.organizationStatus, + }) + ) + .slice(0, 15) ?? [], }) }, placeholder: `${formatMessage(storeMessages.autocompleteSearching)}...`, @@ -354,17 +371,10 @@ const UserWidget: VtexFunctionComponent = ({ organizationInput: userWidgetData?.getOrganizationByIdStorefront?.name, organizationOptions: userWidgetData?.getOrganizationsByEmail .slice(0, 15) - .map( - (organization: { - orgId: string - organizationName: string - organizationStatus: string - }) => ({ - value: organization.orgId, - label: organization.organizationName, - status: organization.organizationStatus, - }) - ), + .map((organization: { orgId: string; organizationName: string }) => ({ + value: organization.orgId, + label: organization.organizationName, + })), currentRoleName: userWidgetData?.getOrganizationsByEmail?.find( (organizations: any) => organizations.costId === currentCostCenter )?.role?.name, @@ -429,10 +439,17 @@ const UserWidget: VtexFunctionComponent = ({ (organization: { orgId: string }) => organization.orgId === itemSelected.value ) - .map((organization: { costId: string; costCenterName: string }) => ({ - value: organization.costId, - label: organization.costCenterName, - })) as [], + .map( + (organization: { + costId: string + costCenterName: string + organizationStatus: string + }) => ({ + value: organization.costId, + label: organization.costCenterName, + status: organization.organizationStatus, + }) + ) as [], }) }, } @@ -604,14 +621,12 @@ const UserWidget: VtexFunctionComponent = ({
- {(!userWidgetData?.checkImpersonation?.email && - organizationsState.organizationOptions.length > 1 && - showDropdown && ( - - )) || ( + {(!userWidgetData?.checkImpersonation?.email && showDropdown && ( + + )) || ( {`${formatMessage(messages.organization)} ${ userWidgetData?.getOrganizationByIdStorefront?.name @@ -625,14 +640,12 @@ const UserWidget: VtexFunctionComponent = ({
- {(!userWidgetData?.checkImpersonation?.email && - organizationsState.organizationOptions.length > 1 && - showDropdown && ( - - )) || ( + {(!userWidgetData?.checkImpersonation?.email && showDropdown && ( + + )) || ( {`${formatMessage(messages.costCenter)} ${ userWidgetData?.getCostCenterByIdStorefront?.name @@ -640,33 +653,31 @@ const UserWidget: VtexFunctionComponent = ({ )}
- {!userWidgetData?.checkImpersonation?.email && - organizationsState.organizationOptions.length > 1 && - showDropdown && ( -
+ + {errorOrganization && ( +
- {formatMessage(messages.setCurrentOrganization)} - - {errorOrganization && ( -
- -
- )} -
- )} + +
+ )} +
+ )}