forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAffiliationFilterSwitch.js
More file actions
34 lines (32 loc) · 1.05 KB
/
AffiliationFilterSwitch.js
File metadata and controls
34 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react'
import { Flex, Switch, Tooltip } from '@chakra-ui/react'
import { bool, func } from 'prop-types'
import { UserIcon } from '../theme/Icons'
import { t } from '@lingui/macro'
import { useUserVar } from '../utilities/userState'
export function AffiliationFilterSwitch({ isAffiliated, setIsAffiliated, resetToFirstPage }) {
const { isLoggedIn } = useUserVar()
if (!isLoggedIn()) return null
return (
<Tooltip label={t`Filter list to affiliated resources only.`} hasArrow>
<Flex align="center" my="2" maxW="5rem" className="filter-affiliated">
<Switch
isFocusable={true}
aria-label="Filter list to affiliated resources only."
mx="2"
defaultChecked={isAffiliated}
onChange={(e) => {
setIsAffiliated(e.target.checked)
resetToFirstPage()
}}
/>
<UserIcon color="gray.900" size="lg" />
</Flex>
</Tooltip>
)
}
AffiliationFilterSwitch.propTypes = {
isAffiliated: bool,
setIsAffiliated: func,
resetToFirstPage: func,
}