From 0af9fb3bc19de8ca9964fedbdcaf8dab0cf16f2d Mon Sep 17 00:00:00 2001 From: Mohammad Hashemi Date: Fri, 21 Jan 2022 01:22:32 +0330 Subject: [PATCH 1/2] convert regulatory page to ts --- ...ent_accordion.js => _document_accordion.tsx} | 8 +++++--- .../regulatory/{_eu-grid.js => _eu-grid.tsx} | 16 +++++++++------- ..._commission.js => _financial_commission.tsx} | 0 .../data/{_kid_data.js => _kid_data.tsx} | 0 src/pages/regulatory/{index.js => index.tsx} | 17 ++++++++++------- src/store/index.tsx | 4 ++++ 6 files changed, 28 insertions(+), 17 deletions(-) rename src/pages/regulatory/{_document_accordion.js => _document_accordion.tsx} (96%) rename src/pages/regulatory/{_eu-grid.js => _eu-grid.tsx} (97%) rename src/pages/regulatory/{_financial_commission.js => _financial_commission.tsx} (100%) rename src/pages/regulatory/data/{_kid_data.js => _kid_data.tsx} (100%) rename src/pages/regulatory/{index.js => index.tsx} (99%) diff --git a/src/pages/regulatory/_document_accordion.js b/src/pages/regulatory/_document_accordion.tsx similarity index 96% rename from src/pages/regulatory/_document_accordion.js rename to src/pages/regulatory/_document_accordion.tsx index f310c86a081..50724f43523 100644 --- a/src/pages/regulatory/_document_accordion.js +++ b/src/pages/regulatory/_document_accordion.tsx @@ -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' @@ -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; @@ -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)', @@ -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) diff --git a/src/pages/regulatory/_eu-grid.js b/src/pages/regulatory/_eu-grid.tsx similarity index 97% rename from src/pages/regulatory/_eu-grid.js rename to src/pages/regulatory/_eu-grid.tsx index fa1a379660f..fb207061d45 100644 --- a/src/pages/regulatory/_eu-grid.js +++ b/src/pages/regulatory/_eu-grid.tsx @@ -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; @@ -61,7 +66,8 @@ const AttachmentIcon = styled(ViewLicense)` } } ` -const GridItem = ({ name, order, url }) => ( + +const GridItem = ({ name, order, url }: GridItemProps) => ( {order} @@ -72,11 +78,7 @@ const GridItem = ({ name, order, url }) => ( ) -GridItem.propTypes = { - name: PropTypes.string, - order: PropTypes.string, - url: PropTypes.string, -} + const EUgrid = () => { return ( diff --git a/src/pages/regulatory/_financial_commission.js b/src/pages/regulatory/_financial_commission.tsx similarity index 100% rename from src/pages/regulatory/_financial_commission.js rename to src/pages/regulatory/_financial_commission.tsx diff --git a/src/pages/regulatory/data/_kid_data.js b/src/pages/regulatory/data/_kid_data.tsx similarity index 100% rename from src/pages/regulatory/data/_kid_data.js rename to src/pages/regulatory/data/_kid_data.tsx diff --git a/src/pages/regulatory/index.js b/src/pages/regulatory/index.tsx similarity index 99% rename from src/pages/regulatory/index.js rename to src/pages/regulatory/index.tsx index 5accd998b54..14c3744ec3a 100644 --- a/src/pages/regulatory/index.js +++ b/src/pages/regulatory/index.tsx @@ -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' @@ -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; @@ -52,7 +59,7 @@ const Mobile = styled(Show.Mobile)` const Desktop = styled(Show.Desktop)` display: flex; ` -const Box = styled.div` +const Box = styled.div` display: flex; flex-direction: column; align-items: center; @@ -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 ( @@ -462,8 +469,4 @@ const Regulatory = (locale) => { ) } -Regulatory.propTypes = { - locale: PropTypes.object, -} - export default WithIntl()(Regulatory) diff --git a/src/store/index.tsx b/src/store/index.tsx index 14305c55595..09cdb6406d0 100644 --- a/src/store/index.tsx +++ b/src/store/index.tsx @@ -8,6 +8,10 @@ type DerivProviderProps = { } export type DerivStoreType = { + is_livechat_interactive: boolean + LC_API: { open_chat_window: () => void } + setFirstLoadOpenLc: (boolean) => void + is_loading_lc: boolean is_eu_country: boolean is_uk_country: boolean is_p2p_allowed_country: boolean From 2858864203a970ef9023d7cd5f69b4fa2c0ead95 Mon Sep 17 00:00:00 2001 From: mohammad-rework <93753441+mohammad-rework@users.noreply.github.com> Date: Fri, 21 Jan 2022 11:41:52 +0330 Subject: [PATCH 2/2] Update src/store/index.tsx Co-authored-by: Sean Ho <72253841+sean-binary@users.noreply.github.com> --- src/store/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/index.tsx b/src/store/index.tsx index 09cdb6406d0..9cf02b90c44 100644 --- a/src/store/index.tsx +++ b/src/store/index.tsx @@ -10,7 +10,7 @@ type DerivProviderProps = { export type DerivStoreType = { is_livechat_interactive: boolean LC_API: { open_chat_window: () => void } - setFirstLoadOpenLc: (boolean) => void + setFirstLoadOpenLc: React.Dispatch> is_loading_lc: boolean is_eu_country: boolean is_uk_country: boolean