Removing Toast

This commit is contained in:
Bel Curcio 2021-06-09 12:22:30 -03:00
parent 7a9ed2ad91
commit a0e8f16c1b
2 changed files with 21 additions and 59 deletions

View File

@ -3,7 +3,7 @@
}
.heading {
@apply text-5xl mb-12;
@apply text-5xl pt-1 pb-2 font-semibold tracking-wide cursor-pointer mb-2;
}
.pageHeading {

View File

@ -5,10 +5,8 @@ export interface State {
displaySidebar: boolean
displayDropdown: boolean
displayModal: boolean
displayToast: boolean
sidebarView: string
modalView: string
toastText: string
userAvatar: string
}
@ -18,8 +16,6 @@ const initialState = {
displayModal: false,
modalView: 'LOGIN_VIEW',
sidebarView: 'CART_VIEW',
displayToast: false,
toastText: '',
userAvatar: '',
}
@ -30,16 +26,6 @@ type Action =
| {
type: 'CLOSE_SIDEBAR'
}
| {
type: 'OPEN_TOAST'
}
| {
type: 'CLOSE_TOAST'
}
| {
type: 'SET_TOAST_TEXT'
text: ToastText
}
| {
type: 'OPEN_DROPDOWN'
}
@ -74,8 +60,6 @@ type MODAL_VIEWS =
type SIDEBAR_VIEWS = 'CART_VIEW' | 'CHECKOUT_VIEW' | 'PAYMENT_METHOD_VIEW'
type ToastText = string
export const UIContext = React.createContext<State | any>(initialState)
UIContext.displayName = 'UIContext'
@ -119,18 +103,6 @@ function uiReducer(state: State, action: Action) {
displayModal: false,
}
}
case 'OPEN_TOAST': {
return {
...state,
displayToast: true,
}
}
case 'CLOSE_TOAST': {
return {
...state,
displayToast: false,
}
}
case 'SET_MODAL_VIEW': {
return {
...state,
@ -143,12 +115,6 @@ function uiReducer(state: State, action: Action) {
sidebarView: action.view,
}
}
case 'SET_TOAST_TEXT': {
return {
...state,
toastText: action.text,
}
}
case 'SET_USER_AVATAR': {
return {
...state,
@ -161,12 +127,14 @@ function uiReducer(state: State, action: Action) {
export const UIProvider: FC = (props) => {
const [state, dispatch] = React.useReducer(uiReducer, initialState)
const openSidebar = useCallback(() => dispatch({ type: 'OPEN_SIDEBAR' }), [
dispatch,
])
const closeSidebar = useCallback(() => dispatch({ type: 'CLOSE_SIDEBAR' }), [
dispatch,
])
const openSidebar = useCallback(
() => dispatch({ type: 'OPEN_SIDEBAR' }),
[dispatch]
)
const closeSidebar = useCallback(
() => dispatch({ type: 'CLOSE_SIDEBAR' }),
[dispatch]
)
const toggleSidebar = useCallback(
() =>
state.displaySidebar
@ -179,27 +147,23 @@ export const UIProvider: FC = (props) => {
[dispatch, state.displaySidebar]
)
const openDropdown = useCallback(() => dispatch({ type: 'OPEN_DROPDOWN' }), [
dispatch,
])
const openDropdown = useCallback(
() => dispatch({ type: 'OPEN_DROPDOWN' }),
[dispatch]
)
const closeDropdown = useCallback(
() => dispatch({ type: 'CLOSE_DROPDOWN' }),
[dispatch]
)
const openModal = useCallback(() => dispatch({ type: 'OPEN_MODAL' }), [
dispatch,
])
const closeModal = useCallback(() => dispatch({ type: 'CLOSE_MODAL' }), [
dispatch,
])
const openToast = useCallback(() => dispatch({ type: 'OPEN_TOAST' }), [
dispatch,
])
const closeToast = useCallback(() => dispatch({ type: 'CLOSE_TOAST' }), [
dispatch,
])
const openModal = useCallback(
() => dispatch({ type: 'OPEN_MODAL' }),
[dispatch]
)
const closeModal = useCallback(
() => dispatch({ type: 'CLOSE_MODAL' }),
[dispatch]
)
const setUserAvatar = useCallback(
(value: string) => dispatch({ type: 'SET_USER_AVATAR', value }),
@ -229,8 +193,6 @@ export const UIProvider: FC = (props) => {
closeModal,
setModalView,
setSidebarView,
openToast,
closeToast,
setUserAvatar,
}),
[state]