diff --git a/gatsby-ssr.js b/gatsby-ssr.js index 3ece76f9e12..d8f34f3a386 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -3,7 +3,6 @@ import { Partytown } from '@builder.io/partytown/react' import { WrapPagesWithLocaleContext } from './src/components/localization' import './src/components/localization/config' import GlobalProvider from './src/store/global-provider' -import { isFeatureEnabled } from './src/common/utility' export const wrapRootElement = ({ element }) => { return {element} diff --git a/src/common/third-party-flags.ts b/src/common/third-party-flags.ts deleted file mode 100644 index 9b4e85b57ec..00000000000 --- a/src/common/third-party-flags.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { initializeApp } from 'firebase/app' -import { getDatabase, ref, onValue, Database, type DatabaseReference } from 'firebase/database' -import featuresConfig from '../../static/appConfig' - -const thirdPartyFlagsConfig = { - databaseURL: 'https://deriv-static-staging.firebaseio.com', -} - -function getThirdPartyFlags() { - const app = initializeApp(thirdPartyFlagsConfig, 'thirdPartyFlagsConfig') - const db = getDatabase(app) - // console.log('==>', db) - let fetchedData = featuresConfig - const starCountRef = ref(db, 'remote_config/deriv-com') - const flagsData = onValue( - starCountRef, - (snapshot) => { - fetchedData = snapshot.val() - }, - (error) => { - console.log(error) - fetchedData = featuresConfig - }, - ) - return fetchedData -} -// getThirdPartyFlags() -console.log('====>') - -export { getThirdPartyFlags } diff --git a/src/common/utility.ts b/src/common/utility.ts index f083b4666a5..c481fee0e41 100644 --- a/src/common/utility.ts +++ b/src/common/utility.ts @@ -3,7 +3,6 @@ import { navigate } from 'gatsby' import Cookies from 'js-cookie' import extend from 'extend' import language_config from '../../i18n-config' -import featuresConfig from '../../static/appConfig' import { deriv_cookie_domain, deriv_app_languages, @@ -13,7 +12,6 @@ import { domains, eu_domains, } from './constants' -import { getThirdPartyFlags } from './third-party-flags' import { localize } from 'components/localization' import { ProductLinkGenerator } from 'features/components/atoms/link/external' @@ -458,19 +456,3 @@ export const getP2PCookie = () => { const p2p_validity = Cookies.get('is_p2p_disabled') return p2p_validity } - -export const isFeatureEnabled = (featurePath) => { - console.log(' in fucntion ==>', getThirdPartyFlags()) - - const pathParts = featurePath.split('.') - let currentFeature = getThirdPartyFlags() - - for (const part of pathParts) { - if (currentFeature[part] === undefined) { - return false // Feature path does not exist - } - currentFeature = currentFeature[part] - } - - return Boolean(currentFeature) -} diff --git a/src/components/hooks/use-third-party-flags.tsx b/src/components/hooks/use-third-party-flags.tsx index 95cfff68ea4..f202358e2cb 100644 --- a/src/components/hooks/use-third-party-flags.tsx +++ b/src/components/hooks/use-third-party-flags.tsx @@ -39,7 +39,6 @@ const useThirdPartyFlags = (featurePath) => { return // Feature path does not exist } currentFeature = currentFeature[part] - console.log('currentFeature ==>', part, currentFeature) } if (typeof currentFeature === 'object') { setFeature(currentFeature) diff --git a/src/features/components/quill/layout-overlay/index.tsx b/src/features/components/quill/layout-overlay/index.tsx index 13ca7c6f66e..cbf33d08573 100644 --- a/src/features/components/quill/layout-overlay/index.tsx +++ b/src/features/components/quill/layout-overlay/index.tsx @@ -6,7 +6,6 @@ import { wrapper_ltr, wrapper_rtl } from './styles.module.scss' import CfdWarningBanner from './cfd-warning-banner' import { useIsRtl } from 'components/hooks/use-isrtl' import { useFloatingCtaContext } from 'features/contexts/floating-cta/cta.provider' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' import { usePageLoaded } from 'components/hooks/use-page-loaded' diff --git a/src/features/components/templates/footer/deriv-go-banner.tsx b/src/features/components/templates/footer/deriv-go-banner.tsx index f27fc3c5e32..55d9ba0ab40 100644 --- a/src/features/components/templates/footer/deriv-go-banner.tsx +++ b/src/features/components/templates/footer/deriv-go-banner.tsx @@ -8,7 +8,6 @@ import { footer_qr_box } from './styles.module.scss' import derivGoQR from 'images/common/migration/footer/deriv-go-qr.svg' import { Localize, localize } from 'components/localization' import useRegion from 'components/hooks/use-region' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' export const DerivGoBanner = () => { diff --git a/src/features/pages/deriv-ctrader/get-trading/index.tsx b/src/features/pages/deriv-ctrader/get-trading/index.tsx index 3f092f91f65..fef0c259054 100644 --- a/src/features/pages/deriv-ctrader/get-trading/index.tsx +++ b/src/features/pages/deriv-ctrader/get-trading/index.tsx @@ -16,7 +16,6 @@ import { useIsRtl } from 'components/hooks/use-isrtl' import { ctrader_android_url, ctrader_traders_hub_url, ctrader_windows_url } from 'common/constants' import DownloadColumn, { TDownloadColumnItem } from 'components/custom/_multi-width-column-download' import { localize } from 'components/localization' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const ContentWrapper = styled.div<{ is_rtl: boolean }>` diff --git a/src/features/pages/home/index.tsx b/src/features/pages/home/index.tsx index b9af73aa3d0..75b9f749bbd 100644 --- a/src/features/pages/home/index.tsx +++ b/src/features/pages/home/index.tsx @@ -12,7 +12,6 @@ import TrustpilotSection from './trustpilot' import { useOpenLiveChat } from 'components/hooks/use-open-live-chat-redirection' import MainRowNavigation from 'features/components/templates/navigation/main-nav' import MainFooter from 'features/components/templates/footer' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const FastPaymentSection = loadable(() => import('./fast-payment')) const LiveMarketSection = loadable(() => import('./live-pricing-migration')) diff --git a/src/pages/contact_us/index.tsx b/src/pages/contact_us/index.tsx index f6e2c6ccf76..87db0da2c74 100644 --- a/src/pages/contact_us/index.tsx +++ b/src/pages/contact_us/index.tsx @@ -11,7 +11,7 @@ import { Localize, WithIntl } from 'components/localization' import Layout from 'components/layout/layout' import { SEO, SectionContainer, Container } from 'components/containers' import { TGatsbyHead } from 'features/types' -import { isFeatureEnabled } from 'common/utility' +import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const Offices = Loadable(() => import('./_offices')) const Affiliates = Loadable(() => import('./_affiliates')) @@ -43,6 +43,7 @@ const ContactUs = ({ data }: TContactUs) => { /* redirect livechat for en to open live chat popup */ /* set true to allow redirection for other lang also*/ useOpenLiveChat(true) + const isLiveChat = useThirdPartyFlags('chat.live_chat') return ( @@ -58,9 +59,7 @@ const ContactUs = ({ data }: TContactUs) => { - {isFeatureEnabled('chat.live_chat') && ( - - )} + {isLiveChat && } ) } diff --git a/src/pages/deriv-go/_footer-banner.tsx b/src/pages/deriv-go/_footer-banner.tsx index e8d4d081dfc..16195df0493 100644 --- a/src/pages/deriv-go/_footer-banner.tsx +++ b/src/pages/deriv-go/_footer-banner.tsx @@ -20,7 +20,6 @@ import { } from 'common/constants' import DownloadColumn, { TDownloadColumnItem } from 'components/custom/_multi-width-column-download' import { localize } from 'components/localization' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const ContentWrapper = styled.div<{ is_rtl: boolean }>` diff --git a/src/pages/deriv-go/index.tsx b/src/pages/deriv-go/index.tsx index 49fad8345ae..f70d675ee17 100644 --- a/src/pages/deriv-go/index.tsx +++ b/src/pages/deriv-go/index.tsx @@ -12,7 +12,6 @@ import Layout from 'components/layout/layout' import { WithIntl } from 'components/localization' import { ContentType } from 'pages/landing/_types' import { TGatsbyHead } from 'features/types' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const items: ContentType[] = [ diff --git a/src/pages/derivx/_get-derivx.tsx b/src/pages/derivx/_get-derivx.tsx index 940e66c3ab7..0598c9b48f3 100644 --- a/src/pages/derivx/_get-derivx.tsx +++ b/src/pages/derivx/_get-derivx.tsx @@ -22,7 +22,6 @@ import { } from 'common/constants' import DownloadColumn, { TDownloadColumnItem } from 'components/custom/_multi-width-column-download' import { localize } from 'components/localization' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const ContentWrapper = styled.div<{ is_rtl: boolean }>` diff --git a/src/pages/dmt5/_download-app.tsx b/src/pages/dmt5/_download-app.tsx index 3c1cdd0ff03..03a6b9ced29 100644 --- a/src/pages/dmt5/_download-app.tsx +++ b/src/pages/dmt5/_download-app.tsx @@ -29,7 +29,6 @@ import { import DownloadColumn, { TDownloadColumnItem } from 'components/custom/_multi-width-column-download' import { Flex } from 'components/containers' import { Localize, localize } from 'components/localization' -import { isFeatureEnabled } from 'common/utility' import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const ContentWrapper = styled.div<{ is_rtl: boolean }>` diff --git a/src/pages/help-centre/components/_didnt-find-answer.tsx b/src/pages/help-centre/components/_didnt-find-answer.tsx index 21aa3d0de42..5574f405996 100644 --- a/src/pages/help-centre/components/_didnt-find-answer.tsx +++ b/src/pages/help-centre/components/_didnt-find-answer.tsx @@ -8,7 +8,7 @@ import device from 'themes/device' import ContactUsIcon from 'images/svg/help/livechat-red.svg' import WhatsAppSVG from 'images/svg/help/whatsapp.svg' import { whatsapp_url } from 'common/constants' -import { isFeatureEnabled } from 'common/utility' +import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const DidntFindYourAnswerWrapper = styled.div` background: var(--color-black); @@ -80,6 +80,8 @@ const DidntFindYourAnswerBanner = () => { const openChatWindow = () => LC_API.open_chat_window() const openWhatsappUrl = () => window.open(whatsapp_url, '_blank') + const isLiveChat = useThirdPartyFlags('chat.live_chat') + const isWhatsappChat = useThirdPartyFlags('chat.whatsapp_chat') return ( @@ -90,13 +92,13 @@ const DidntFindYourAnswerBanner = () => { {is_livechat_interactive && ( - {isFeatureEnabled('chat.live_chat') && ( + {isLiveChat && ( )} - {isFeatureEnabled('chat.whatsapp_chat') && ( + {isWhatsappChat && ( whatsapp-icon diff --git a/src/pages/help-centre/components/_search-section.tsx b/src/pages/help-centre/components/_search-section.tsx index faddbb1ec59..15060229801 100644 --- a/src/pages/help-centre/components/_search-section.tsx +++ b/src/pages/help-centre/components/_search-section.tsx @@ -8,11 +8,12 @@ import TalkToUs from './_talk-to-us' import { Container } from 'components/containers' import { Header } from 'components/elements' import { Localize, localize } from 'components/localization' -import { isFeatureEnabled, sanitize } from 'common/utility' +import { sanitize } from 'common/utility' import device from 'themes/device' // Icons import SearchIcon from 'images/svg/help/search.svg' import CrossIcon from 'images/svg/help/cross.svg' +import useThirdPartyFlags from 'components/hooks/use-third-party-flags' const Section = styled.section` padding: 8rem 0; @@ -90,6 +91,7 @@ const SearchCrossIcon = styled.img` const SearchSection = () => { const [search_value, setSearchValue] = useState('') const search_input_ref = useRef(null) + const isLiveChat = useThirdPartyFlags('chat.live_chat') useEffect(() => { if (search_input_ref.current) { @@ -171,7 +173,7 @@ const SearchSection = () => { /> )} - {isFeatureEnabled('chat.live_chat') && } + {isLiveChat && } {has_search_value && (