diff --git a/packages/components/src/components/send-email-template/send-email-template.tsx b/packages/components/src/components/send-email-template/send-email-template.tsx index c7a299692fb3..82451edc186d 100644 --- a/packages/components/src/components/send-email-template/send-email-template.tsx +++ b/packages/components/src/components/send-email-template/send-email-template.tsx @@ -4,6 +4,7 @@ import { PlatformContext } from '@deriv/shared'; import Icon from '../icon/icon'; import Button from '../button/button'; import Text from '../text'; +import { TPlatformContext } from '../static-url/static-url'; type TSendEmailTemplate = { className?: string; @@ -32,7 +33,7 @@ const SendEmailTemplate = ({ const [is_email_not_received_clicked, setIsEmailNotReceivedClicked] = React.useState(false); const [is_resend_btn_disabled, setIsResendBtnDisabled] = React.useState(false); const [resend_email_btn_text, setResendEmailBtnText] = React.useState(txt_resend); - const { is_appstore } = React.useContext<{ is_pre_appstore: boolean; is_appstore: boolean }>(PlatformContext); + const { is_appstore } = React.useContext(PlatformContext); const timeout_limit = resend_timeout || 60; let resend_interval: number; diff --git a/packages/components/src/components/static-url/index.js b/packages/components/src/components/static-url/index.js deleted file mode 100644 index de3792af5344..000000000000 --- a/packages/components/src/components/static-url/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import StaticUrl from './static-url.jsx'; - -export default StaticUrl; diff --git a/packages/components/src/components/static-url/index.ts b/packages/components/src/components/static-url/index.ts new file mode 100644 index 000000000000..b1ab6e65c7df --- /dev/null +++ b/packages/components/src/components/static-url/index.ts @@ -0,0 +1,3 @@ +import StaticUrl from './static-url'; + +export default StaticUrl; diff --git a/packages/components/src/components/static-url/static-url.jsx b/packages/components/src/components/static-url/static-url.tsx similarity index 57% rename from packages/components/src/components/static-url/static-url.jsx rename to packages/components/src/components/static-url/static-url.tsx index 6dbd744f5b45..1d0d5dcef238 100644 --- a/packages/components/src/components/static-url/static-url.jsx +++ b/packages/components/src/components/static-url/static-url.tsx @@ -2,8 +2,18 @@ import React from 'react'; import { getStaticUrl, PlatformContext, setUrlLanguage } from '@deriv/shared'; import { getLanguage } from '@deriv/translations'; -const StaticUrl = ({ href, is_document, children, ...props }) => { - const { is_appstore } = React.useContext(PlatformContext); +export type TPlatformContext = { + is_appstore?: boolean; + is_pre_appstore?: boolean; +}; + +type TStaticUrl = { + href?: string; + is_document?: boolean; +}; + +const StaticUrl = ({ href, is_document, children, ...props }: React.PropsWithChildren) => { + const { is_appstore } = React.useContext(PlatformContext); const getHref = () => { setUrlLanguage(getLanguage()); return getStaticUrl(href, { is_appstore }, is_document); diff --git a/packages/shared/src/utils/platform/platform-context.tsx b/packages/shared/src/utils/platform/platform-context.tsx index c01a64a92eb9..188a0c33f4e1 100644 --- a/packages/shared/src/utils/platform/platform-context.tsx +++ b/packages/shared/src/utils/platform/platform-context.tsx @@ -1,5 +1,10 @@ import React from 'react'; -export const PlatformContext = React.createContext({} as { is_pre_appstore: boolean; is_appstore: boolean }); +export type TPlatformContext = { + is_appstore?: boolean; + is_pre_appstore?: boolean; +}; + +export const PlatformContext = React.createContext({}); PlatformContext.displayName = 'DerivAppStorePlatformContext';