Skip to content

Commit

Permalink
added refresh to list tenants.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Apr 15, 2024
1 parent 128d98b commit d184d12
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/components/utilities/TenantSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import CippTenantOffcanvas from './CippTenantOffcanvas'
import CippfuzzySearch from './CippFuzzySearch'

const TenantSelector = ({ action, showAllTenantSelector = true, NavSelector = false }) => {
const [refreshState, setRefreshState] = React.useState(false)
const currentTenant = useSelector((state) => state.app.currentTenant)
const {
data: tenants = [
Expand All @@ -23,9 +24,10 @@ const TenantSelector = ({ action, showAllTenantSelector = true, NavSelector = fa
},
],
isLoading,
isFetching,
isSuccess,
error,
} = useListTenantsQuery({ showAllTenantSelector })
} = useListTenantsQuery({ showAllTenantSelector, Refresh: refreshState })

const dispatch = useDispatch()
const navigate = useNavigate()
Expand Down Expand Up @@ -90,10 +92,10 @@ const TenantSelector = ({ action, showAllTenantSelector = true, NavSelector = fa
<FontAwesomeIcon icon={faBuilding} />
</CButton>
)}
<div className="flex-grow-1 my-auto mx-2">
<div className="flex-grow-1 my-auto d-flex align-items-center">
<SelectSearch
search
className={'select-search tenantDropdown'}
className="select-search tenantDropdown"
onChange={activated}
filterOptions={CippfuzzySearch}
placeholder={placeholder}
Expand All @@ -104,6 +106,16 @@ const TenantSelector = ({ action, showAllTenantSelector = true, NavSelector = fa
name: `${displayName} (${defaultDomainName})`,
}))}
/>
<CButton
onClick={() =>
//set a random number to force a refresh
setRefreshState(Math.random())
}
variant="ghost"
className="ml-2"
>
<FontAwesomeIcon icon={'refresh'} spin={isFetching} />
</CButton>
</div>
</>
)}
Expand Down

0 comments on commit d184d12

Please sign in to comment.