Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
feat: removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Fasih Ali Naqvi authored and Muhammad Fasih Ali Naqvi committed Feb 28, 2024
1 parent 887f02a commit b079396
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 67 deletions.
1 change: 0 additions & 1 deletion gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <GlobalProvider>{element}</GlobalProvider>
Expand Down
30 changes: 0 additions & 30 deletions src/common/third-party-flags.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/common/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'

Expand Down Expand Up @@ -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)
}
1 change: 0 additions & 1 deletion src/components/hooks/use-third-party-flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/features/components/quill/layout-overlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
1 change: 0 additions & 1 deletion src/features/pages/deriv-ctrader/get-trading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>`
Expand Down
1 change: 0 additions & 1 deletion src/features/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
7 changes: 3 additions & 4 deletions src/pages/contact_us/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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 (
<Layout>
Expand All @@ -58,9 +59,7 @@ const ContactUs = ({ data }: TContactUs) => {
</SectionContainer>
<ContactWays support_section={support_section} />
<Offices our_offices={our_offices} office_address={office_address} />
{isFeatureEnabled('chat.live_chat') && (
<Affiliates business_partnership={business_partnership} />
)}
{isLiveChat && <Affiliates business_partnership={business_partnership} />}
</Layout>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/deriv-go/_footer-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>`
Expand Down
1 change: 0 additions & 1 deletion src/pages/deriv-go/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
1 change: 0 additions & 1 deletion src/pages/derivx/_get-derivx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>`
Expand Down
1 change: 0 additions & 1 deletion src/pages/dmt5/_download-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>`
Expand Down
8 changes: 5 additions & 3 deletions src/pages/help-centre/components/_didnt-find-answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
<DidntFindYourAnswerWrapper>
Expand All @@ -90,13 +92,13 @@ const DidntFindYourAnswerBanner = () => {

{is_livechat_interactive && (
<ButtonWrapper>
{isFeatureEnabled('chat.live_chat') && (
{isLiveChat && (
<ChatButton secondary onClick={openChatWindow}>
<Localize translate_text="_t_Chat_t_" />
</ChatButton>
)}

{isFeatureEnabled('chat.whatsapp_chat') && (
{isWhatsappChat && (
<WhatsAppButton onClick={openWhatsappUrl}>
<img src={WhatsAppSVG} alt="whatsapp-icon" height="16" width="16" />
<Localize translate_text="_t_WhatsApp_t_" />
Expand Down
6 changes: 4 additions & 2 deletions src/pages/help-centre/components/_search-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -171,7 +173,7 @@ const SearchSection = () => {
/>
)}
</SearchForm>
{isFeatureEnabled('chat.live_chat') && <TalkToUs />}
{isLiveChat && <TalkToUs />}

{has_search_value && (
<SearchResult
Expand Down

0 comments on commit b079396

Please sign in to comment.