Skip to content

Commit

Permalink
Bugfix/affiliation filter active when no user (#5107)
Browse files Browse the repository at this point in the history
* use isLoggedIn() to determine starting state for isAffiliated state

* tests
  • Loading branch information
lcampbell2 committed Feb 9, 2024
1 parent 82f5b48 commit f30af73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion frontend/src/domains/DomainsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ import { SearchBox } from '../components/SearchBox'
import { useLazyQuery, useQuery } from '@apollo/client'
import { ExportButton } from '../components/ExportButton'
import { AffiliationFilterSwitch } from '../components/AffiliationFilterSwitch'
import { useUserVar } from '../utilities/userState'

export default function DomainsPage() {
const { isLoggedIn } = useUserVar()
const { data } = useQuery(IS_USER_SUPER_ADMIN)
const toast = useToast()
const [orderDirection, setOrderDirection] = useState('ASC')
const [orderField, setOrderField] = useState('DOMAIN')
const [searchTerm, setSearchTerm] = useState('')
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState('')
const [domainsPerPage, setDomainsPerPage] = useState(10)
const [isAffiliated, setIsAffiliated] = useState(true)
const [isAffiliated, setIsAffiliated] = useState(isLoggedIn())

const [getAllOrgDomainStatuses, { loading: allOrgDomainStatusesLoading, _error, _data }] = useLazyQuery(
GET_ALL_ORGANIZATION_DOMAINS_STATUSES_CSV,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domains/__tests__/DomainsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('<DomainsPage />', () => {
first: 10,
orderBy: { field: 'DOMAIN', direction: 'ASC' },
search: '',
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/organizations/Organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Organizations() {
const { isOpen: inviteRequestIsOpen, onOpen, onClose } = useDisclosure()
const [orgInfo, setOrgInfo] = useState({})
const [isVerified, setIsVerified] = useState(true)
const [isAffiliated, setIsAffiliated] = useState(true)
const [isAffiliated, setIsAffiliated] = useState(isLoggedIn())

const memoizedSetDebouncedSearchTermCallback = useCallback(() => {
setDebouncedSearchTerm(searchTerm)
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/organizations/__tests__/Organizations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down Expand Up @@ -422,7 +422,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down Expand Up @@ -468,7 +468,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down Expand Up @@ -562,7 +562,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
data: {
findMyOrganizations: {
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down Expand Up @@ -652,7 +652,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down Expand Up @@ -698,7 +698,7 @@ describe('<Organisations />', () => {
search: '',
includeSuperAdminOrg: false,
isVerified: true,
isAffiliated: true,
isAffiliated: false,
},
},
result: {
Expand Down

0 comments on commit f30af73

Please sign in to comment.