mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
Removing Toast
This commit is contained in:
parent
7a9ed2ad91
commit
a0e8f16c1b
@ -3,7 +3,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
@apply text-5xl mb-12;
|
@apply text-5xl pt-1 pb-2 font-semibold tracking-wide cursor-pointer mb-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pageHeading {
|
.pageHeading {
|
||||||
|
@ -5,10 +5,8 @@ export interface State {
|
|||||||
displaySidebar: boolean
|
displaySidebar: boolean
|
||||||
displayDropdown: boolean
|
displayDropdown: boolean
|
||||||
displayModal: boolean
|
displayModal: boolean
|
||||||
displayToast: boolean
|
|
||||||
sidebarView: string
|
sidebarView: string
|
||||||
modalView: string
|
modalView: string
|
||||||
toastText: string
|
|
||||||
userAvatar: string
|
userAvatar: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,8 +16,6 @@ const initialState = {
|
|||||||
displayModal: false,
|
displayModal: false,
|
||||||
modalView: 'LOGIN_VIEW',
|
modalView: 'LOGIN_VIEW',
|
||||||
sidebarView: 'CART_VIEW',
|
sidebarView: 'CART_VIEW',
|
||||||
displayToast: false,
|
|
||||||
toastText: '',
|
|
||||||
userAvatar: '',
|
userAvatar: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,16 +26,6 @@ type Action =
|
|||||||
| {
|
| {
|
||||||
type: 'CLOSE_SIDEBAR'
|
type: 'CLOSE_SIDEBAR'
|
||||||
}
|
}
|
||||||
| {
|
|
||||||
type: 'OPEN_TOAST'
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'CLOSE_TOAST'
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'SET_TOAST_TEXT'
|
|
||||||
text: ToastText
|
|
||||||
}
|
|
||||||
| {
|
| {
|
||||||
type: 'OPEN_DROPDOWN'
|
type: 'OPEN_DROPDOWN'
|
||||||
}
|
}
|
||||||
@ -74,8 +60,6 @@ type MODAL_VIEWS =
|
|||||||
|
|
||||||
type SIDEBAR_VIEWS = 'CART_VIEW' | 'CHECKOUT_VIEW' | 'PAYMENT_METHOD_VIEW'
|
type SIDEBAR_VIEWS = 'CART_VIEW' | 'CHECKOUT_VIEW' | 'PAYMENT_METHOD_VIEW'
|
||||||
|
|
||||||
type ToastText = string
|
|
||||||
|
|
||||||
export const UIContext = React.createContext<State | any>(initialState)
|
export const UIContext = React.createContext<State | any>(initialState)
|
||||||
|
|
||||||
UIContext.displayName = 'UIContext'
|
UIContext.displayName = 'UIContext'
|
||||||
@ -119,18 +103,6 @@ function uiReducer(state: State, action: Action) {
|
|||||||
displayModal: false,
|
displayModal: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'OPEN_TOAST': {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
displayToast: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 'CLOSE_TOAST': {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
displayToast: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 'SET_MODAL_VIEW': {
|
case 'SET_MODAL_VIEW': {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -143,12 +115,6 @@ function uiReducer(state: State, action: Action) {
|
|||||||
sidebarView: action.view,
|
sidebarView: action.view,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'SET_TOAST_TEXT': {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toastText: action.text,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 'SET_USER_AVATAR': {
|
case 'SET_USER_AVATAR': {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -161,12 +127,14 @@ function uiReducer(state: State, action: Action) {
|
|||||||
export const UIProvider: FC = (props) => {
|
export const UIProvider: FC = (props) => {
|
||||||
const [state, dispatch] = React.useReducer(uiReducer, initialState)
|
const [state, dispatch] = React.useReducer(uiReducer, initialState)
|
||||||
|
|
||||||
const openSidebar = useCallback(() => dispatch({ type: 'OPEN_SIDEBAR' }), [
|
const openSidebar = useCallback(
|
||||||
dispatch,
|
() => dispatch({ type: 'OPEN_SIDEBAR' }),
|
||||||
])
|
[dispatch]
|
||||||
const closeSidebar = useCallback(() => dispatch({ type: 'CLOSE_SIDEBAR' }), [
|
)
|
||||||
dispatch,
|
const closeSidebar = useCallback(
|
||||||
])
|
() => dispatch({ type: 'CLOSE_SIDEBAR' }),
|
||||||
|
[dispatch]
|
||||||
|
)
|
||||||
const toggleSidebar = useCallback(
|
const toggleSidebar = useCallback(
|
||||||
() =>
|
() =>
|
||||||
state.displaySidebar
|
state.displaySidebar
|
||||||
@ -179,27 +147,23 @@ export const UIProvider: FC = (props) => {
|
|||||||
[dispatch, state.displaySidebar]
|
[dispatch, state.displaySidebar]
|
||||||
)
|
)
|
||||||
|
|
||||||
const openDropdown = useCallback(() => dispatch({ type: 'OPEN_DROPDOWN' }), [
|
const openDropdown = useCallback(
|
||||||
dispatch,
|
() => dispatch({ type: 'OPEN_DROPDOWN' }),
|
||||||
])
|
[dispatch]
|
||||||
|
)
|
||||||
const closeDropdown = useCallback(
|
const closeDropdown = useCallback(
|
||||||
() => dispatch({ type: 'CLOSE_DROPDOWN' }),
|
() => dispatch({ type: 'CLOSE_DROPDOWN' }),
|
||||||
[dispatch]
|
[dispatch]
|
||||||
)
|
)
|
||||||
|
|
||||||
const openModal = useCallback(() => dispatch({ type: 'OPEN_MODAL' }), [
|
const openModal = useCallback(
|
||||||
dispatch,
|
() => dispatch({ type: 'OPEN_MODAL' }),
|
||||||
])
|
[dispatch]
|
||||||
const closeModal = useCallback(() => dispatch({ type: 'CLOSE_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 setUserAvatar = useCallback(
|
const setUserAvatar = useCallback(
|
||||||
(value: string) => dispatch({ type: 'SET_USER_AVATAR', value }),
|
(value: string) => dispatch({ type: 'SET_USER_AVATAR', value }),
|
||||||
@ -229,8 +193,6 @@ export const UIProvider: FC = (props) => {
|
|||||||
closeModal,
|
closeModal,
|
||||||
setModalView,
|
setModalView,
|
||||||
setSidebarView,
|
setSidebarView,
|
||||||
openToast,
|
|
||||||
closeToast,
|
|
||||||
setUserAvatar,
|
setUserAvatar,
|
||||||
}),
|
}),
|
||||||
[state]
|
[state]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user