Skip to content

Commit

Permalink
fix: delete the state not used by global
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-liu-smile authored and BrianJiang2021 committed Apr 14, 2023
1 parent 4a42c02 commit 191e530
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 64 deletions.
2 changes: 1 addition & 1 deletion apps/storefront/src/components/B3GlobalTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import {
MsgsProps,
} from '@/shared/global/context/config'
} from '@/shared/dynamicallyVariable/context/config'

import {
B3Tip,
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/components/B3Tip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import {
TipMessagesProps,
MsgsProps,
} from '@/shared/global/context/config'
} from '@/shared/dynamicallyVariable/context/config'

interface B3TipProps extends TipMessagesProps {
handleItemClose: (id: number | string) => void,
Expand Down
12 changes: 0 additions & 12 deletions apps/storefront/src/components/RegisteredCloseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export function RegisteredCloseButton(props: CloseButtonProps) {
state: {
isCheckout,
isCloseGotoBCHome,
isLoginStatusChange,
},
dispatch,
} = useContext(GlobaledContext)

const handleCloseForm = () => {
Expand All @@ -47,16 +45,6 @@ export function RegisteredCloseButton(props: CloseButtonProps) {
isOpen: false,
openUrl: '',
})

if (isLoginStatusChange) {
window.location.reload()
dispatch({
type: 'common',
payload: {
isLoginStatusChange: false,
},
})
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/components/layout/B3LayoutTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {

import {
MsgsProps,
} from '@/shared/global/context/config'
} from '@/shared/dynamicallyVariable/context/config'

const B3LayoutTip = () => {
const {
Expand Down
10 changes: 9 additions & 1 deletion apps/storefront/src/hooks/useSetOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
GlobaledContext,
} from '@/shared/global'

import {
DynamicallyVariableedContext,
} from '@/shared/dynamicallyVariable'

const {
height: defaultHeight,
overflow: defaultOverflow,
Expand All @@ -16,6 +20,10 @@ const useSetOpen = (isOpen: boolean, openUrl?: string, params?: CustomFieldItems
const {
dispatch,
} = useContext(GlobaledContext)

const {
dispatch: dispatchMsg,
} = useContext(DynamicallyVariableedContext)
useEffect(() => {
if (isOpen) {
// The iframe screen is removed
Expand Down Expand Up @@ -45,7 +53,7 @@ const useSetOpen = (isOpen: boolean, openUrl?: string, params?: CustomFieldItems
document.body.style.overflow = defaultOverflow

// close all tips
dispatch({
dispatchMsg({
type: 'common',
payload: {
tipMessage: {
Expand Down
7 changes: 0 additions & 7 deletions apps/storefront/src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,6 @@ export default function Login(props:RegisteredProps) {
} else {
const info = await getCurrentCustomerInfo(dispatch)

dispatch({
type: 'common',
payload: {
isLoginStatusChange: true,
},
})

if (info?.userType === 3 && info?.role === 3) {
navigate('/dashboard')
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface DynamicallyVariableState {
saveText?: string,
saveFn?: () => void,
},
isCloseScrollBar: boolean,
}

export const initState = {
Expand All @@ -47,7 +46,6 @@ export const initState = {
message: '',
cancelText: 'Cancel',
},
isCloseScrollBar: false,
}

export interface DynamicallyVariableAction {
Expand Down
40 changes: 1 addition & 39 deletions apps/storefront/src/shared/global/context/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Dispatch,
ReactElement,
ReactNode,
} from 'react'

Expand All @@ -16,23 +15,6 @@ export interface CustomerInfo {
}

export type AlertTip = 'error' | 'info' | 'success' | 'warning'
export interface MsgsProps {
title?: string,
msg?: string,
jsx?: () => ReactElement,
id: string | number,
type: AlertTip
isClose?: boolean,
vertical?: 'top' | 'bottom'
horizontal?: 'left' | 'right' | 'center'
}
export interface TipMessagesProps{
msgs?: Array<MsgsProps> | [],
autoHideDuration?: number,
vertical?: 'top' | 'bottom'
horizontal?: 'left' | 'right' | 'center'
isClose?: boolean
}
export interface State {
stateCode?: string,
stateName?: string,
Expand Down Expand Up @@ -80,8 +62,6 @@ export interface GlobalState {
isCloseGotoBCHome: boolean,
BcToken: string,
isB2BUser: boolean,
isLogin: boolean,
isLoginStatusChange: boolean,
customerId: number | string,
customer: CustomerInfo,
companyInfo: {
Expand All @@ -97,7 +77,7 @@ export interface GlobalState {
salesRepCompanyId: string,
salesRepCompanyName: string,
B3UserId: number | string,
tipMessage: TipMessagesProps,
// tipMessage: TipMessagesProps,
addressConfig?: {
key: string,
isEnabled: string,
Expand All @@ -118,15 +98,6 @@ export interface GlobalState {
cartQuoteEnabled: boolean,
shoppingListEnabled: boolean,
quoteConfig: CustomFieldItems[],
globalMessageDialog: {
open: boolean,
title: string,
message: string,
cancelText?: string,
cancelFn?: () => void,
saveText?: string,
saveFn?: () => void,
},
currencies: {
channelCurrencies: channelCurrenciesProps,
currencies: currencyProps,
Expand All @@ -140,8 +111,6 @@ export const initState = {
isCloseGotoBCHome: false,
BcToken: B3SStorage.get('BcToken') || '',
isB2BUser: B3SStorage.get('isB2BUser') || false,
isLogin: false,
isLoginStatusChange: false,
customerId: B3SStorage.get('B3CustomerId') || '',
B3UserId: B3SStorage.get('B3UserId') || '',
emailAddress: B3SStorage.get('B3EmailAddress') || '',
Expand All @@ -165,7 +134,6 @@ export const initState = {
},
logo: '',
isCompanyAccount: false,
tipMessage: {},
storeEnabled: false,
storeName: '',
currentChannelId: 1,
Expand All @@ -175,12 +143,6 @@ export const initState = {
cartQuoteEnabled: false,
shoppingListEnabled: false,
quoteConfig: [],
globalMessageDialog: {
open: false,
title: '',
message: '',
cancelText: 'Cancel',
},
currencies: B3SStorage.get('currencies') || {},
openAPPParams: {
quoteBtn: '',
Expand Down

0 comments on commit 191e530

Please sign in to comment.