Skip to content

Commit

Permalink
fix(partnerConfig): add init after checking for selected network
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddaqqa committed Sep 17, 2024
1 parent 7aff61d commit 0923b9e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/helpers/useSmartContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const SmartContractProvider: React.FC<SmartContractProviderProps> = ({ ch
const activeNetwork = useAppSelector(getActiveNetwork)

useEffect(() => {
if (auth) initializeEthers()
if (auth && activeNetwork.name.toLowerCase() === 'columbus') initializeEthers()
}, [activeNetwork, auth])

useEffect(() => {
Expand Down
8 changes: 7 additions & 1 deletion src/layout/PartnersLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SmartContractProvider } from '../helpers/useSmartContract'
import { useAppSelector } from '../hooks/reduxHooks'
import { useIsPartnerQuery } from '../redux/services/partners'
import { getWalletName } from '../redux/slices/app-config'
import { getActiveNetwork } from '../redux/slices/network'
import Links from '../views/settings/Links'

const ClaimProfile = () => {
Expand Down Expand Up @@ -57,8 +58,13 @@ const PartnersLayout = () => {
navigate('/')
}
}, [walletName])
const activeNetwork = useAppSelector(getActiveNetwork)
if (isLoading) return <></>
if (path.includes('partners/messenger-configuration') && !store.state.isAuth) {
if (
path.includes('partners/messenger-configuration') &&
!store.state.isAuth &&
activeNetwork.name.toLowerCase() !== 'columbus'
) {
return <Navigate to="/login" replace />
}
return (
Expand Down
27 changes: 15 additions & 12 deletions src/views/settings/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import store from 'wallet/store'
import { useSmartContract } from '../../helpers/useSmartContract'
import { useAppDispatch, useAppSelector } from '../../hooks/reduxHooks'
import { changeActiveApp } from '../../redux/slices/app-config'
import { getActiveNetwork } from '../../redux/slices/network'

function a11yProps(index: number) {
return {
Expand Down Expand Up @@ -45,7 +46,7 @@ export default function Links({ type = 'else' }: { type?: string }) {
}, [path]) // eslint-disable-line react-hooks/exhaustive-deps
const auth = useAppSelector(state => state.appConfig.isAuth)
const sc = useSmartContract()

const activeNetwork = useAppSelector(getActiveNetwork)
const tabStyle = (index: number, currentValue: number) => ({
'&::after': { display: currentValue === index ? 'block' : 'none' },
color: currentValue === index ? theme.palette.text.primary : 'inherit',
Expand Down Expand Up @@ -94,17 +95,19 @@ export default function Links({ type = 'else' }: { type?: string }) {
key={0}
sx={tabStyle(0, value)}
/>,
auth && store.state.activeWallet?.type !== 'multisig' && (
<Tab
onClick={() => navigate('/partners/messenger-configuration')}
className="tab"
disableRipple
label="My Partners Profile"
{...a11yProps(1)}
key={1}
sx={tabStyle(1, value)}
/>
),
auth &&
store.state.activeWallet?.type !== 'multisig' &&
activeNetwork.name.toLowerCase() === 'columbus' && (
<Tab
onClick={() => navigate('/partners/messenger-configuration')}
className="tab"
disableRipple
label="My Partners Profile"
{...a11yProps(1)}
key={1}
sx={tabStyle(1, value)}
/>
),
]

const partnersSubTabs = [
Expand Down

0 comments on commit 0923b9e

Please sign in to comment.