Skip to content

Commit

Permalink
feat(nomad-badges): Implementation of Digital Nomad program
Browse files Browse the repository at this point in the history
  • Loading branch information
49659410+tx0c committed Dec 7, 2023
1 parent 939ef08 commit 4791ff4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 43 deletions.
17 changes: 7 additions & 10 deletions src/views/User/UserProfile/AsideUserProfile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dynamic from 'next/dynamic'
import { useContext, useEffect } from 'react'
import { FormattedMessage } from 'react-intl'

import {
OPEN_SHOW_NOMAD_BADGE_DIALOG,
TEST_ID,
Expand Down Expand Up @@ -44,7 +45,10 @@ const DynamicWalletLabel = dynamic(() => import('../WalletLabel'), {
})

export const AsideUserProfile = () => {
const { isInPath, getQuery, deleteQuery } = useRoute()
const {
isInPath,
getQuery, // deleteQuery
} = useRoute()
const viewer = useContext(ViewerContext)

// public user data
Expand Down Expand Up @@ -251,21 +255,14 @@ export const AsideUserProfile = () => {
totalReferredCount={user.status?.totalReferredCount || 0}
shareLink={shareLink}
>
{({ openDialog }) => {
if (showBadges) {
setTimeout(() => {
deleteQuery(URL_USER_PROFILE.OPEN_NOMAD_BADGE_DIALOG.key)
openDialog()
})
}
return (
{({ openDialog }) => (
<BadgeNomadLabel
hasTooltip
nomadBadgeLevel={nomadBadgeLevel}
onClick={openDialog}
/>
)
}}
}
</BadgeNomadDialog>
)}
{hasTraveloggersBadge && <TraveloggersBadge hasTooltip />}
Expand Down
25 changes: 19 additions & 6 deletions src/views/User/UserProfile/BadgeNomadDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import dynamic from 'next/dynamic'

import { Dialog, Spinner, useDialogSwitch } from '~/components'
import { OPEN_SHOW_NOMAD_BADGE_DIALOG } from '~/common/enums'
import {
Dialog,
Spinner,
useDialogSwitch,
useEventListener,
} from '~/components'
import { UserStatus } from '~/gql/graphql'

type BadgeNomadLabelProps = {
Expand Down Expand Up @@ -43,8 +49,15 @@ export const BaseBadgeNomadDialog: React.FC<BadgeNomadDialogProps> = ({
)
}

export const BadgeNomadDialog = (props: BadgeNomadDialogProps) => (
<Dialog.Lazy mounted={<BaseBadgeNomadDialog {...props} />}>
{({ openDialog }) => <>{props.children({ openDialog })}</>}
</Dialog.Lazy>
)
export const BadgeNomadDialog = (props: BadgeNomadDialogProps) => {
const Children = ({ openDialog }: { openDialog: () => void }) => {
useEventListener(OPEN_SHOW_NOMAD_BADGE_DIALOG, openDialog)
return <>{props?.children({ openDialog })}</>
}

return (
<Dialog.Lazy mounted={<BaseBadgeNomadDialog {...props} />}>
{({ openDialog }) => <Children openDialog={openDialog} />}
</Dialog.Lazy>
)
}
1 change: 0 additions & 1 deletion src/views/User/UserProfile/BadgeNomadLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ export const BadgeNomadLabel: React.FC<BadgeNomadLabelProps> = ({
</>
)
}

17 changes: 2 additions & 15 deletions src/views/User/UserProfile/Badges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,10 @@ import { ReactComponent as IconNomad3Badge } from '@/public/static/icons/48px/ba
import { ReactComponent as IconNomad4Badge } from '@/public/static/icons/48px/badge-nomad4-fire.svg'
import { ReactComponent as IconSeedBadge } from '@/public/static/icons/48px/badge-seed.svg'
import { ReactComponent as IconTraveloggersBadge } from '@/public/static/icons/48px/badge-traveloggers.svg'
import { Tooltip, Translate, withIcon } from '~/components'
import { IconArrowAction24 } from '~/components/Icon/IconArrowAction24'
import { IconArrowAction24, Tooltip, Translate, withIcon } from '~/components'
import { UserStatus } from '~/gql/graphql'

import { ReactComponent as IconArchitectBadge } from '@/public/static/icons/48px/badge-architect.svg'
import { ReactComponent as IconCivicLikerBadge } from '@/public/static/icons/48px/badge-civic-liker.svg'
import { ReactComponent as IconGoldenMotorBadge } from '@/public/static/icons/48px/badge-golden-motor.svg'
import { ReactComponent as IconNomad1Badge } from '@/public/static/icons/48px/badge-nomad1-moon.svg'
import { ReactComponent as IconNomad2Badge } from '@/public/static/icons/48px/badge-nomad2-star.svg'
import { ReactComponent as IconNomad3Badge } from '@/public/static/icons/48px/badge-nomad3-light.svg'
import { ReactComponent as IconNomad4Badge } from '@/public/static/icons/48px/badge-nomad4-fire.svg'
import { ReactComponent as IconSeedBadge } from '@/public/static/icons/48px/badge-seed.svg'
import { ReactComponent as IconTraveloggersBadge } from '@/public/static/icons/48px/badge-traveloggers.svg'
import { IconArrowAction, Tooltip, Translate, withIcon } from '~/components'
import { UserStatus } from '~/gql/graphql'

import { BadgeNomadDialog } from '../BadgeNomadLabel'
// import { BadgeNomadDialog } from '../BadgeNomadLabel'
import styles from './styles.module.css'

type badgePros = {
Expand Down
21 changes: 10 additions & 11 deletions src/views/User/UserProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import dynamic from 'next/dynamic'
import { useContext, useEffect } from 'react'
import { FormattedMessage } from 'react-intl'

import { TEST_ID, URL_USER_PROFILE } from '~/common/enums'
import {
OPEN_SHOW_NOMAD_BADGE_DIALOG,
TEST_ID,
URL_USER_PROFILE,
} from '~/common/enums'
import { numAbbr, toPath } from '~/common/utils'
import {
Avatar,
Expand Down Expand Up @@ -39,7 +43,9 @@ const DynamicWalletLabel = dynamic(() => import('./WalletLabel'), {
})

export const UserProfile = () => {
const { getQuery, deleteQuery } = useRoute()
const {
getQuery, // deleteQuery
} = useRoute()
const viewer = useContext(ViewerContext)

// public user data
Expand Down Expand Up @@ -216,14 +222,7 @@ export const UserProfile = () => {
isCivicLiker={isCivicLiker}
shareLink={shareLink}
>
{({ openDialog }) => {
if (showBadges && hasNomadBadge) {
setTimeout(() => {
deleteQuery(URL_USER_PROFILE.OPEN_NOMAD_BADGE_DIALOG.key)
openDialog('nomad')
})
}
return (
{({ openDialog }) => (
<span
className={styles.badges}
onClick={() => openDialog()}
Expand All @@ -239,7 +238,7 @@ export const UserProfile = () => {
/>
</span>
)
}}
}
</BadgesDialog>

{user?.info.ethAddress && (
Expand Down

0 comments on commit 4791ff4

Please sign in to comment.