userAvatar

This commit is contained in:
okbel
2021-02-04 12:29:20 -03:00
parent 6cacfec8c7
commit 3f30344619
5 changed files with 50 additions and 12 deletions

View File

@@ -8,6 +8,7 @@ export interface State {
displayToast: boolean
modalView: string
toastText: string
userAvatar: string
}
const initialState = {
@@ -17,6 +18,7 @@ const initialState = {
modalView: 'LOGIN_VIEW',
displayToast: false,
toastText: '',
userAvatar: '',
}
type Action =
@@ -52,6 +54,10 @@ type Action =
type: 'SET_MODAL_VIEW'
view: MODAL_VIEWS
}
| {
type: 'SET_USER_AVATAR'
value: string
}
type MODAL_VIEWS = 'SIGNUP_VIEW' | 'LOGIN_VIEW' | 'FORGOT_VIEW'
type ToastText = string
@@ -123,6 +129,12 @@ function uiReducer(state: State, action: Action) {
toastText: action.text,
}
}
case 'SET_USER_AVATAR': {
return {
...state,
userAvatar: action.value,
}
}
}
}
@@ -147,6 +159,9 @@ export const UIProvider: FC = (props) => {
const openToast = () => dispatch({ type: 'OPEN_TOAST' })
const closeToast = () => dispatch({ type: 'CLOSE_TOAST' })
const setUserAvatar = (value: string) =>
dispatch({ type: 'SET_USER_AVATAR', value })
const setModalView = (view: MODAL_VIEWS) =>
dispatch({ type: 'SET_MODAL_VIEW', view })
@@ -164,6 +179,7 @@ export const UIProvider: FC = (props) => {
setModalView,
openToast,
closeToast,
setUserAvatar,
}),
[state]
)