Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

amam/add check for p2p allowed country #1239

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/common/country-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,40 @@ const eu_countries = [
'mt',
]

const p2p_allowed_countries = [
'ng',
'za',
'zw',
'tz',
'gh',
'zm',
'bw',
'na',
'ke',
'aq',
'so',
'pk',
'in',
'bd',
'ik',
'ci',
'ar',
'bo',
'cl',
'co',
'ec',
'gf',
'gy',
'py',
'pe',
'sr',
'uy',
've',
]

export const isEuCountry = (clients_country) => eu_countries.includes(clients_country)

export const isP2PAllowedCountry = (clients_country) =>
p2p_allowed_countries.includes(clients_country)

export const isUK = (clients_country) => clients_country === 'gb'
17 changes: 11 additions & 6 deletions src/pages/payment-methods/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ DisplayAccordianItem.propTypes = {
}

const PaymentMethods = () => {
const { is_p2p_allowed_country } = React.useContext(DerivStore)
return (
<Layout>
<Helmet>
Expand Down Expand Up @@ -229,12 +230,16 @@ const PaymentMethods = () => {
</Text>
</Container>
</SectionContainer>
<Divider height="2px" />
<SectionContainer>
<Container direction="column">
<Dp2p />
</Container>
</SectionContainer>
{is_p2p_allowed_country && (
<>
<Divider height="2px" />
<SectionContainer>
<Container direction="column">
<Dp2p />
</Container>
</SectionContainer>
</>
)}
</Layout>
)
}
Expand Down
6 changes: 4 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { useWebsiteStatus } from 'components/hooks/website-status-hooks'
import { isEuCountry } from 'common/country-base'
import { isEuCountry, isP2PAllowedCountry } from 'common/country-base'

export const DerivStore = React.createContext()

export const DerivProvider = ({ children }) => {
const [website_status] = useWebsiteStatus()
const [is_eu_country, setEuCountry] = useState(false)
const [is_p2p_allowed_country, setP2PAllowedCountry] = useState(false)
const [crypto_config, setCryptoConfig] = useState(null)

useEffect(() => {
if (website_status) {
setEuCountry(isEuCountry(website_status.clients_country))

setP2PAllowedCountry(isP2PAllowedCountry(website_status.clients_country))
if (!crypto_config) {
setCryptoConfig(website_status.crypto_config)
}
Expand All @@ -24,6 +25,7 @@ export const DerivProvider = ({ children }) => {
<DerivStore.Provider
value={{
is_eu_country,
is_p2p_allowed_country,
crypto_config,
}}
>
Expand Down