Skip to content

Commit

Permalink
Fix referralCode for link open modal
Browse files Browse the repository at this point in the history
  • Loading branch information
leonthuongto committed Jan 16, 2025
1 parent 9544480 commit fa17647
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/AccountDetails/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MyKyc } from 'state/kyc/actions'
import { ReactComponent as Edit } from '../../assets/images/edit.svg'
import { ReactComponent as DefaultAvatar } from '../../assets/images/default-avatar.svg'
import styled from 'styled-components'
import { useQueryParams } from 'hooks/useParams'

interface ModalProps {
isModalOpen: boolean
Expand All @@ -21,6 +22,7 @@ interface AvatarProps {
}

const Avatar: React.FC<AvatarProps> = ({ kyc, toggleWalletModal }) => {
const { objectParams } = useQueryParams<{ referralCode: string }>(['referralCode'])
const [modalProps, setModalProps] = useState<ModalProps>({ isModalOpen: false, referralCode: '' })

const closeModal = () => {
Expand All @@ -30,8 +32,8 @@ const Avatar: React.FC<AvatarProps> = ({ kyc, toggleWalletModal }) => {
setModalProps({
isModalOpen: true,
kycType,
referralCode: new URL(window.location.href).href?.split('=')[1]
? `/kyc/${kycType}?referralCode=${new URL(window.location.href).href?.split('=')[1]}`
referralCode: objectParams?.referralCode
? `/kyc/${kycType}?referralCode=${objectParams?.referralCode}`
: `/kyc/${kycType}`,
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/KYC/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { KYC_REWARD, LineRewardAction } from 'constants/lineRewards'
import { apiService as lineRewardApiService } from 'hooks/useLineReward'
import { linePoint } from 'services/apiUrls'
import { useLineReward } from 'providers/LineRewardProvider'
import { useQueryParams } from 'hooks/useParams'

interface DescriptionProps {
description: string | null
Expand Down Expand Up @@ -95,6 +96,7 @@ const Description: FC<DescriptionProps> = ({ description }: DescriptionProps) =>
)

const KYC = () => {
const { objectParams } = useQueryParams<{ referralCode: string }>(['referralCode'])
const { account } = useWeb3React()
const { chainId } = useAccount()
const [cookies] = useCookies(['annoucementsSeen'])
Expand Down Expand Up @@ -161,9 +163,7 @@ const KYC = () => {
setModalProps({
isModalOpen: true,
kycType,
referralCode: new URL(window.location.href).href?.split('=')[1]
? `/kyc/${kycType}?referralCode=${new URL(window.location.href).href?.split('=')[1]}`
: `/kyc/${kycType}`,
referralCode: objectParams?.referralCode ? `/kyc/${kycType}?referralCode=${objectParams?.referralCode}` : `/kyc/${kycType}`,
// Add more props as needed
})
}
Expand Down

0 comments on commit fa17647

Please sign in to comment.