Finish cookie banner implementation
This commit is contained in:
parent
3af46220fb
commit
6ea47d6990
|
@ -68,24 +68,32 @@ const useStyles = makeStyles({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const acceptCookiesHandler = (newState: CookiesProps) => {
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
// Aca tenes q pasarle el estado nuevo de los dos switches
|
|
||||||
dispatch(saveCookiesToStorage(newState))
|
|
||||||
}
|
|
||||||
|
|
||||||
const CookiesBanner = () => {
|
const CookiesBanner = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const cookiesState: CookiesProps = useSelector(cookiesSelector)
|
const cookiesState: CookiesProps = useSelector(cookiesSelector)
|
||||||
const { acceptedNecessary, acceptedAnalytics } = cookiesState
|
const dispatch = useDispatch()
|
||||||
const showBanner = !acceptedNecessary || !acceptedAnalytics
|
const { acceptedNecessary } = cookiesState
|
||||||
|
const showBanner = acceptedNecessary === false
|
||||||
const [localNecessary, setLocalNecessary] = useState(true)
|
const [localNecessary, setLocalNecessary] = useState(true)
|
||||||
const [localAnalytics, setLocalAnalytics] = useState(false)
|
const [localAnalytics, setLocalAnalytics] = useState(false)
|
||||||
|
|
||||||
|
const acceptCookiesHandler = (newState: CookiesProps) => {
|
||||||
|
dispatch(saveCookiesToStorage(newState))
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeCookiesBannerHandler = () => {
|
||||||
|
const newState = {
|
||||||
|
acceptedNecessary: true,
|
||||||
|
acceptedAnalytics: false,
|
||||||
|
}
|
||||||
|
dispatch(saveCookiesToStorage(newState))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return showBanner ? (
|
return showBanner ? (
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
<IconButton onClick={() => {}} className={classes.close}><Close /></IconButton>
|
<IconButton onClick={() => closeCookiesBannerHandler()} className={classes.close}><Close /></IconButton>
|
||||||
<div className={classes.content}>
|
<div className={classes.content}>
|
||||||
<p className={classes.text}>
|
<p className={classes.text}>
|
||||||
We use cookies to give you the best
|
We use cookies to give you the best
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
import { type GlobalState } from '~/store'
|
import { type GlobalState } from '~/store'
|
||||||
import { COOKIE_REDUCER_ID } from '~/logic/cookies/store/reducer/cookies'
|
import { COOKIE_REDUCER_ID } from '~/logic/cookies/store/reducer/cookies'
|
||||||
|
|
||||||
export const cookiesSelector = (state: GlobalState) => state[COOKIE_REDUCER_ID]
|
export const cookiesSelector = (state: GlobalState) => state[COOKIE_REDUCER_ID].toJS()
|
||||||
|
|
Loading…
Reference in New Issue