Adds files to git

This commit is contained in:
apane 2019-11-20 13:39:43 -03:00
parent ad3d27e927
commit 13d1de8251
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,9 @@
// @flow
import type { RecordOf } from 'immutable'
export type CookiesProps = {
acceptedNecessary: boolean;
acceptedAnalytics: boolean;
}
export type Cookie = RecordOf<CookiesProps>

View File

@ -0,0 +1,25 @@
// @flow
import { Map } from 'immutable'
import { handleActions, type ActionType } from 'redux-actions'
import type { Cookie } from '~/logic/cookies/store/model/cookie'
import { SET_COOKIES_PERMISSIONS } from '../actions/setCookiesPermissions'
import type { State } from '~/logic/tokens/store/reducer/tokens'
export const COOKIE_REDUCER_ID = 'cookies'
export type CookieReducerState = Map<string, Map<string, Cookie>>
export default handleActions<State, *>(
{
[SET_COOKIES_PERMISSIONS]: (state: State, action: ActionType<Function>): State => {
const { acceptedNecessary, acceptedAnalytics } = action.payload
const newState = state.withMutations((mutableState) => {
mutableState.set('acceptedNecessary', acceptedNecessary)
mutableState.set('acceptedAnalytics', acceptedAnalytics)
})
return newState
},
},
Map(),
)

View File

@ -0,0 +1,6 @@
// @flow
import { type GlobalState } from '~/store'
import { COOKIE_REDUCER_ID } from '~/logic/cookies/store/reducer/cookies'
export const cookiesSelector = (state: GlobalState) => state[COOKIE_REDUCER_ID]