Skip to content

Commit

Permalink
fix(portals-admin): Stop redirecting when only one result (#17020)
Browse files Browse the repository at this point in the history
causes loop when going back now that we have query in url

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
magnearun and kodiakhq[bot] authored Nov 26, 2024
1 parent 41721f3 commit 050a2eb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ export const CompaniesAction: WrappedActionFn =
throw res.error
}

const companies = res.data?.companyRegistryCompanies?.data

// Redirect to Procurers screen if only one company is found
if (companies?.length === 1) {
return redirect(
replaceParams({
href: ServiceDeskPaths.Company,
params: {
nationalId: companies[0].nationalId,
},
}),
)
}

return {
errors: null,
data: res.data.companyRegistryCompanies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ const Companies = () => {
buttonProps={{
type: 'submit',
disabled: !searchInput,
onClick: (e) => {
e.preventDefault()
onClick: () => {
if (searchInput) {
setSearchParams((params) => {
params.set('q', searchInput)
return params
})
submit(formRef.current)
}
},
}}
Expand Down
16 changes: 0 additions & 16 deletions libs/portals/admin/service-desk/src/screens/Users/Users.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,6 @@ export const UsersAction: WrappedActionFn =
throw res.error
}

const { data: respData, totalCount } = res.data.UserProfileAdminProfiles

if (totalCount === 1) {
return redirect(
replaceParams({
href: ServiceDeskPaths.User,
params: {
nationalId: (await maskString(
respData[0].nationalId,
userInfo.profile.nationalId,
)) as string,
},
}),
)
}

return {
data: res.data.UserProfileAdminProfiles,
errors: null,
Expand Down
4 changes: 1 addition & 3 deletions libs/portals/admin/service-desk/src/screens/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,12 @@ const Users = () => {
buttonProps={{
type: 'submit',
disabled: searchInput.length === 0,
onClick: (e) => {
e.preventDefault()
onClick: () => {
if (searchInput) {
setSearchParams((params) => {
params.set('q', searchInput)
return params
})
submit(formRef.current)
}
},
}}
Expand Down

0 comments on commit 050a2eb

Please sign in to comment.