Skip to content

Commit

Permalink
feat: update dcl dapps (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi authored Jan 30, 2024
1 parent c0e9e71 commit 66f5091
Show file tree
Hide file tree
Showing 8 changed files with 738 additions and 79 deletions.
729 changes: 717 additions & 12 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@sentry/react": "^7.64.0",
"@typechain/ethers-v5": "^10.0.0",
"connected-react-router": "^6.9.1",
"decentraland-dapps": "^16.33.0",
"decentraland-dapps": "^17.6.0",
"decentraland-transactions": "^1.46.0",
"decentraland-ui": "^4.35.3",
"dotenv": "8.2.0",
Expand Down
4 changes: 1 addition & 3 deletions src/components/Navbar/Navbar.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from 'decentraland-dapps/dist/modules/wallet/selectors'
import {
getIsAuthDappEnabled,
getIsNavbarV2Enabled,
} from '../../modules/features/selectors'
import { RootState } from '../../modules/reducer'
import { MapStateProps, MapDispatch, MapDispatchProps } from './Navbar.types'
Expand All @@ -22,8 +21,7 @@ const mapState = (state: RootState): MapStateProps => {
: false,
isConnected: isConnected(state),
pathname: getLocation(state).pathname,
isAuthDappEnabled: !!getIsAuthDappEnabled(state),
isNavbarV2Enabled: getIsNavbarV2Enabled(state),
isAuthDappEnabled: !!getIsAuthDappEnabled(state)
}
}

Expand Down
45 changes: 4 additions & 41 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,23 @@
import React, { useCallback } from 'react'
import {
Navbar as BaseNavbar,
Navbar2 as BaseNavbar2,
UserInformation,
} from 'decentraland-dapps/dist/containers'
import { Navbar as BaseNavbar } from 'decentraland-dapps/dist/containers'

import { locations } from '../../modules/locations'
import { config } from '../../config'
import { Props } from './Navbar.types'
import './Navbar.css'

const Navbar = (props: Props) => {
const {
pathname,
onNavigate,
isConnected,
isAuthDappEnabled,
isNavbarV2Enabled,
} = props

if (isConnected) {
props = {
...props,
rightMenu: <UserInformation />,
}
}
const { pathname, onNavigate, isAuthDappEnabled } = props

const handleOnSignIn = useCallback(() => {
if (isAuthDappEnabled) {
window.location.replace(
`${config.get('AUTH_URL')}/login?redirectTo=${window.location.href}`
)
window.location.replace(`${config.get('AUTH_URL')}/login?redirectTo=${window.location.href}`)
return
}
onNavigate(locations.signIn())
}, [isAuthDappEnabled, onNavigate])

const handleOnClickAccount = useCallback(() => {
onNavigate(locations.settings())
}, [onNavigate])

return isNavbarV2Enabled ? (
<BaseNavbar2
{...props}
isSignIn={pathname === locations.signIn()}
onSignIn={handleOnSignIn}
/>
) : (
<BaseNavbar
{...props}
isFullscreen={props.isFullscreen}
isSignIn={pathname === locations.signIn()}
onSignIn={handleOnSignIn}
onClickAccount={handleOnClickAccount}
/>
)
return <BaseNavbar {...props} isSignIn={pathname === locations.signIn()} onSignIn={handleOnSignIn} />
}

export default React.memo(Navbar)
2 changes: 0 additions & 2 deletions src/components/Navbar/Navbar.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type Props = Partial<NavbarProps> & {
pathname: string
isConnected: boolean
isAuthDappEnabled: boolean
isNavbarV2Enabled: boolean
onNavigate: (path: string) => void
}

Expand All @@ -17,7 +16,6 @@ export type MapStateProps = Pick<
| 'hasActivity'
| 'isConnected'
| 'isAuthDappEnabled'
| 'isNavbarV2Enabled'
>
export type MapDispatchProps = Pick<Props, 'onNavigate'>
export type MapDispatch = Dispatch<CallHistoryMethodAction>
10 changes: 0 additions & 10 deletions src/modules/features/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,3 @@ export const getIsAuthDappEnabled = (state: RootState) => {
return false
}

export const getIsNavbarV2Enabled = (state: RootState) => {
if (hasLoadedInitialFlags(state)) {
return getIsFeatureEnabled(
state,
ApplicationName.DAPPS,
FeatureName.NAVBAR_V2
)
}
return false
}
1 change: 0 additions & 1 deletion src/modules/features/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export enum FeatureName {
AUTH_DAPP = 'auth-dapp',
NAVBAR_V2 = 'navbar2_variant',
}
24 changes: 15 additions & 9 deletions src/modules/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,31 @@ import { locationSaga as localLocationSaga } from './location/sagas'
import { manaSaga } from './mana/sagas'
import { config } from '../config'
import * as translations from '../locales'
import { FiatGateway } from 'decentraland-dapps/dist/modules/gateway/types'

const analyticsSaga = createAnalyticsSaga()

const profileSaga = createProfileSaga({
peerUrl: config.get('PEER_URL')!,
getIdentity: () => undefined,
getIdentity: () => undefined
})

const translationSaga = createTranslationSaga({
translations: translations as any,
translations: translations as any
})

const walletSaga = createWalletSaga({
CHAIN_ID: +(config.get('CHAIN_ID') || 1),
POLL_INTERVAL: 0,
TRANSACTIONS_API_URL,
TRANSACTIONS_API_URL
})

const gatewaySaga = createGatewaySaga({
[NetworkGatewayType.MOON_PAY]: {
apiBaseUrl: config.get('MOON_PAY_API_URL'),
apiKey: config.get('MOON_PAY_API_KEY'),
pollingDelay: +config.get('MOON_PAY_POLLING_DELAY'),
widgetBaseUrl: config.get('MOON_PAY_WIDGET_URL'),
widgetBaseUrl: config.get('MOON_PAY_WIDGET_URL')
},
[NetworkGatewayType.TRANSAK]: {
apiBaseUrl: config.get('TRANSAK_API_URL'),
Expand All @@ -49,9 +50,14 @@ const gatewaySaga = createGatewaySaga({
pollingDelay: +config.get('TRANSAK_POLLING_DELAY'),
pusher: {
appKey: config.get('TRANSAK_PUSHER_APP_KEY'),
appCluster: config.get('TRANSAK_PUSHER_APP_CLUSTER'),
},
appCluster: config.get('TRANSAK_PUSHER_APP_CLUSTER')
}
},
// Wert is not being used in account dapp
[FiatGateway.WERT]: {
marketplaceServerURL: '',
url: ''
}
})

export function* rootSaga() {
Expand All @@ -68,11 +74,11 @@ export function* rootSaga() {
featuresSaga({
polling: {
apps: [ApplicationName.DAPPS],
delay: 60000 /** 60 seconds */,
},
delay: 60000 /** 60 seconds */
}
}),
manaSaga(),
toastSaga(),
gatewaySaga(),
gatewaySaga()
])
}

0 comments on commit 66f5091

Please sign in to comment.