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.

Mohammad/ Convert Regulatory page to TS #2543

Merged
3 commits merged into from
Jan 21, 2022
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import styled from 'styled-components'
import kid_data from './data/_kid_data.js'
import kid_data from './data/_kid_data'
import { Text, Accordion, AccordionItem, LinkText } from 'components/elements'
import { Flex } from 'components/containers'
import { localize } from 'components/localization'
Expand All @@ -9,6 +9,8 @@ import PDFIcon from 'images/svg/regulatory/pdf-icon-black.svg'
import XLSXIcon from 'images/svg/regulatory/excel.svg'
import { DerivStore } from 'store'

type DocumentAccordionProps = { locale: { language: string } }

const FlexText = styled(LinkText)`
width: 26%;
display: flex;
Expand Down Expand Up @@ -114,7 +116,7 @@ const RTS27_28 = () => (
</>
)

const DocumentAccordion = (locale) => {
const DocumentAccordion = (locale: DocumentAccordionProps) => {
const content_style = {
background: 'var(--color-white)',
boxShadow: '-2px 6px 15px 0 rgba(195, 195, 195, 0.31)',
Expand All @@ -135,7 +137,7 @@ const DocumentAccordion = (locale) => {
const selected_language = locale.locale.language || 'en'
const supported_languages = ['es', 'it', 'pl', 'pt']

const is_supported_language = (language) => supported_languages.includes(language)
const is_supported_language = (language: string) => supported_languages.includes(language)

const { is_eu_country } = React.useContext(DerivStore)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { CssGrid, CssGridColumn } from 'components/containers'
import { localize, WithIntl, Localize } from 'components/localization'
import { ReactComponent as ViewLicense } from 'images/svg/regulatory/view-license.svg'

type GridItemProps = {
name: string
order: string
url: string
}

const Country = styled.div`
margin-bottom: 2.4rem;
display: grid;
Expand Down Expand Up @@ -61,7 +66,8 @@ const AttachmentIcon = styled(ViewLicense)`
}
}
`
const GridItem = ({ name, order, url }) => (

const GridItem = ({ name, order, url }: GridItemProps) => (
<Country>
<Order>{order}</Order>
<License>
Expand All @@ -72,11 +78,7 @@ const GridItem = ({ name, order, url }) => (
</License>
</Country>
)
GridItem.propTypes = {
name: PropTypes.string,
order: PropTypes.string,
url: PropTypes.string,
}

const EUgrid = () => {
return (
<CssGrid columns="repeat(2, 1fr)" columngap="1rem">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import styled from 'styled-components'
import PropTypes from 'prop-types'
import EUgrid from './_eu-grid'
import DocumentAccordion from './_document_accordion'
import FinancialCommission from './_financial_commission'
Expand Down Expand Up @@ -29,6 +28,14 @@ import MGA from 'images/common/regulatory/mga.png'
import SVG from 'images/svg/regulatory/svg.svg'
import device from 'themes/device.js'

type BoxProps = {
padding?: string
}

type RegulatoryProps = {
language: string
}

const Img = styled.img`
display: flex;
width: 16rem;
Expand All @@ -52,7 +59,7 @@ const Mobile = styled(Show.Mobile)`
const Desktop = styled(Show.Desktop)`
display: flex;
`
const Box = styled.div`
const Box = styled.div<BoxProps>`
display: flex;
flex-direction: column;
align-items: center;
Expand Down Expand Up @@ -94,7 +101,7 @@ const ResponsiveHeader = styled(StyledHeader)`
const Content = styled.div`
display: contents;
`
const Regulatory = (locale) => {
const Regulatory = (locale: RegulatoryProps) => {
const { is_eu_country } = React.useContext(DerivStore)

return (
Expand Down Expand Up @@ -462,8 +469,4 @@ const Regulatory = (locale) => {
)
}

Regulatory.propTypes = {
locale: PropTypes.object,
}

export default WithIntl()(Regulatory)
8 changes: 4 additions & 4 deletions src/store/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ type WebsiteStatusType = {
crypto_config: any
}

type DerivStoreTypes = {
export type DerivStoreType = {
academy_data: AcademyDataType
crypto_config: any
is_eu_country: boolean
is_livechat_interactive: boolean
is_loading_lc: boolean
is_p2p_allowed_country: boolean
is_uk_country: boolean
LC_API: any
setFirstLoadOpenLc: Dispatch<boolean>
LC_API: { open_chat_window: () => void }
setFirstLoadOpenLc: React.Dispatch<React.SetStateAction<boolean>>
setWebsiteStatus: Dispatch<WebsiteStatusType>
user_country: string
website_status_loading: boolean
website_status: WebsiteStatusType
}

export const DerivStore = createContext<DerivStoreTypes>(null)
export const DerivStore = createContext<DerivStoreType>(null)

export const DerivProvider = ({ children }: DerivProviderProps) => {
const [website_status, setWebsiteStatus, website_status_loading] = useWebsiteStatus()
Expand Down