From 7f8a300869aece85cf70ec5f18f2de322f01fac9 Mon Sep 17 00:00:00 2001 From: internxt-yu Date: Fri, 17 Jul 2026 17:15:24 +0200 Subject: [PATCH 1/6] make price dynamic change between euro and usd --- src/assets/lang/en/affiliates.json | 4 ++-- src/assets/types/affiliates.ts | 6 ++++- src/pages/affiliates/index.tsx | 38 ++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/assets/lang/en/affiliates.json b/src/assets/lang/en/affiliates.json index 27da8c009..75d5c6ff0 100644 --- a/src/assets/lang/en/affiliates.json +++ b/src/assets/lang/en/affiliates.json @@ -1,7 +1,7 @@ { "HeroSection": { "label": "Internxt's Affiliate Program", - "title": { "normalText": " per sale", "blueText": "Earn up to $300" }, + "title": { "normalText": " per sale", "blueText": "Earn up to {price}" }, "description": "Join Internxt’s world-class affiliate program and earn money promoting zero-knowledge cloud storage to your audience. Let’s build a safer, fairer, and better internet together.", "signUp": "Sign up now", "logIn": "Affiliate log in" @@ -33,7 +33,7 @@ "title": "Why join Internxt’s Affiliate Program?", "cards": [ { - "title": "Earn up to $300 per sale" + "title": "Earn up to {price} per sale" }, { "title": "Dedicated account managers" diff --git a/src/assets/types/affiliates.ts b/src/assets/types/affiliates.ts index ab2155e43..ea1ff1f66 100644 --- a/src/assets/types/affiliates.ts +++ b/src/assets/types/affiliates.ts @@ -96,6 +96,10 @@ export interface WhatWeDoSection { export interface WhyJoinSection { title: string; - cards: Number1Section[]; + cards: Title[]; cta: string; } + +export interface Title { + title: string; +} diff --git a/src/pages/affiliates/index.tsx b/src/pages/affiliates/index.tsx index 9fcceebf5..84b27eb91 100644 --- a/src/pages/affiliates/index.tsx +++ b/src/pages/affiliates/index.tsx @@ -20,6 +20,8 @@ import Button from '@/components/shared/Button'; import { getImage } from '@/lib/getImage'; import RenderDescription from '@/components/shared/RenderDescription'; import { TextAndImageColumnSection } from '@/components/shared/components/TextAndImageColumnSection'; +import { currencyService } from '@/services/currency.service'; +import { useState, useEffect } from 'react'; interface AffiliatesProps { metatagsDescriptions: MetatagsDescription[]; @@ -136,6 +138,38 @@ const Affiliates = ({ langJson, lang, metatagsDescriptions, navbarLang, footerLa }, ]; + const [currency, setCurrency] = useState("€"); + const [currencyValue, setCurrencyValue] = useState("eur"); + + useEffect(() => { + currencyService.filterCurrencyByCountry().then(({currency, currencyValue}) => { + console.log(currencyValue); + setCurrency(currency); + setCurrencyValue(currencyValue); + }) + .catch(() => { + // NO OP + }) + }, []); + + const getPrice = () => { + if (currencyValue === 'usd') return 300; + return 263; + } + + const price = `${currency}${getPrice()}`; + const HeroSectionText = langJson.HeroSection.title.blueText.replace('{price}', price); + const updatedWhyJoinSectionText = { + ...langJson.WhyJoinSection, + cards: [ + { + ...langJson.WhyJoinSection.cards[0], + title: langJson.WhyJoinSection.cards[0].title.replace('{price}', price) + }, + ...langJson.WhyJoinSection.cards.slice(1) + ] +}; + return ( @@ -148,7 +182,7 @@ const Affiliates = ({ langJson, lang, metatagsDescriptions, navbarLang, footerLa

- {langJson.HeroSection.title.blueText} + {HeroSectionText} {langJson.HeroSection.title.normalText}

{langJson.HeroSection.description}

@@ -206,7 +240,7 @@ const Affiliates = ({ langJson, lang, metatagsDescriptions, navbarLang, footerLa }} /> - + Date: Mon, 20 Jul 2026 09:32:41 +0200 Subject: [PATCH 2/6] refactor for sonarqube warning --- src/pages/affiliates/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/affiliates/index.tsx b/src/pages/affiliates/index.tsx index 84b27eb91..77f565c51 100644 --- a/src/pages/affiliates/index.tsx +++ b/src/pages/affiliates/index.tsx @@ -189,6 +189,7 @@ const Affiliates = ({ langJson, lang, metatagsDescriptions, navbarLang, footerLa

- {HeroSectionText} + {langJson.HeroSection.title.blueText} {langJson.HeroSection.title.normalText}

{langJson.HeroSection.description}

@@ -240,7 +207,7 @@ const Affiliates = ({ langJson, lang, metatagsDescriptions, navbarLang, footerLa }} /> - + Date: Tue, 21 Jul 2026 16:53:49 +0200 Subject: [PATCH 6/6] refectored the repited code --- src/assets/types/affiliates.ts | 8 ++------ src/pages/coupons.tsx | 20 +++----------------- src/pages/index.tsx | 18 +++--------------- src/pages/ppc/index.tsx | 18 +++--------------- src/utils/priceHelper.ts | 14 ++++++++++++++ 5 files changed, 25 insertions(+), 53 deletions(-) create mode 100644 src/utils/priceHelper.ts diff --git a/src/assets/types/affiliates.ts b/src/assets/types/affiliates.ts index ea1ff1f66..a30dc3d8a 100644 --- a/src/assets/types/affiliates.ts +++ b/src/assets/types/affiliates.ts @@ -96,10 +96,6 @@ export interface WhatWeDoSection { export interface WhyJoinSection { title: string; - cards: Title[]; + cards: string[]; cta: string; -} - -export interface Title { - title: string; -} +} \ No newline at end of file diff --git a/src/pages/coupons.tsx b/src/pages/coupons.tsx index aa66287de..36e29846b 100644 --- a/src/pages/coupons.tsx +++ b/src/pages/coupons.tsx @@ -3,7 +3,7 @@ import { FooterText, MetatagsDescription, NavigationBarText } from '@/assets/typ import Footer from '@/components/layout/footers/Footer'; import Layout from '@/components/layout/Layout'; import Navbar from '@/components/layout/navbars/Navbar'; -import { Interval, stripeService } from '@/services/stripe.service'; +import { stripeService } from '@/services/stripe.service'; import { PricingSectionWrapper } from '@/components/shared/pricing/PricingSectionWrapper'; import FAQSection from '@/components/shared/sections/FaqSection'; import usePricing from '@/hooks/usePricing'; @@ -18,7 +18,7 @@ import RedeemCouponsSection from '@/components/coupons/ReedeemCouponSection'; import ReviewsSection from '@/components/home/ReviewsSection'; import Script from 'next/script'; import { sm_breadcrumb_list } from '@/components/utils/schema-markup-generator'; -import { useState, useEffect } from 'react'; +import { getMinimumPrice } from '@/utils/priceHelper'; interface HomeProps { lang: GetServerSidePropsContext['locale']; @@ -72,24 +72,10 @@ const HomePage = ({ metatagsDescriptions, textContent, lang, navbarLang, footerL ); }; - const [minimumPrice, setMinimumPrice] = useState('9.99'); const decimalDiscountForLifetime = lifetimeCoupon?.percentOff && 100 - lifetimeCoupon.percentOff; const decimalDiscount = individualCoupon?.percentOff && 100 - individualCoupon.percentOff; const percentOff = lifetimeCoupon?.percentOff !== undefined ? String(lifetimeCoupon.percentOff) : '0'; - - useEffect(() => { - const price = Number(products?.individuals?.[Interval.Year]?.[0]?.price); - - if(!price) return; - - const calculatedPrice = decimalDiscount - ? (Math.floor(price * (decimalDiscount / 100) * 100) / 100).toFixed(2) - : price.toFixed(2) - - setMinimumPrice(calculatedPrice); - }, [products, decimalDiscount]); - - + const minimumPrice = getMinimumPrice(products, decimalDiscount); return ( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index dcf01f14c..f72286f7e 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -5,7 +5,7 @@ import HeroSection from '@/components/home/HeroSection'; import Footer from '@/components/layout/footers/Footer'; import Layout from '@/components/layout/Layout'; import Navbar from '@/components/layout/navbars/Navbar'; -import { Interval, stripeService } from '@/services/stripe.service'; +import { stripeService } from '@/services/stripe.service'; import { PricingSectionWrapper } from '@/components/shared/pricing/PricingSectionWrapper'; import FAQSection from '@/components/shared/sections/FaqSection'; import usePricing from '@/hooks/usePricing'; @@ -16,7 +16,7 @@ import HorizontalScrollableSection from '@/components/home/HorizontalScrollableS import AwardWinningSection from '@/components/home/AwardWinningPrivacySection'; import OfficialCloudProviderSection from '@/components/home/OfficilaCloudProviderSection'; import ReviewsSection from '@/components/home/ReviewsSection'; -import { useState, useEffect } from 'react'; +import { getMinimumPrice } from '@/utils/priceHelper'; interface HomeProps { lang: GetServerSidePropsContext['locale']; @@ -71,22 +71,10 @@ const HomePage = ({ metatagsDescriptions, textContent, lang, navbarLang, footerL ); }; - const [minimumPrice, setMinimumPrice] = useState('9.99'); const decimalDiscountForLifetime = lifetimeCoupon?.percentOff && 100 - lifetimeCoupon.percentOff; const decimalDiscount = individualCoupon?.percentOff && 100 - individualCoupon.percentOff; const percentOff = lifetimeCoupon?.percentOff !== undefined ? String(lifetimeCoupon.percentOff) : '0'; - - useEffect(() => { - const price = Number(products?.individuals?.[Interval.Year]?.[0]?.price); - - if(!price) return; - - const calculatedPrice = decimalDiscount - ? (Math.floor(price * (decimalDiscount / 100) * 100) / 100).toFixed(2) - : price.toFixed(2) - - setMinimumPrice(calculatedPrice); - }, [products, decimalDiscount]); + const minimumPrice = getMinimumPrice(products, decimalDiscount); return ( diff --git a/src/pages/ppc/index.tsx b/src/pages/ppc/index.tsx index fcb9cb8f1..d385f7436 100644 --- a/src/pages/ppc/index.tsx +++ b/src/pages/ppc/index.tsx @@ -6,7 +6,7 @@ import HeroSection from '@/components/home/HeroSection'; import Footer from '@/components/layout/footers/Footer'; import Layout from '@/components/layout/Layout'; import Navbar from '@/components/layout/navbars/Navbar'; -import { Interval, stripeService } from '@/services/stripe.service'; +import { stripeService } from '@/services/stripe.service'; import { PricingSectionWrapper } from '@/components/shared/pricing/PricingSectionWrapper'; import FAQSection from '@/components/shared/sections/FaqSection'; import usePricing from '@/hooks/usePricing'; @@ -17,7 +17,7 @@ import HorizontalScrollableSection from '@/components/home/HorizontalScrollableS import AwardWinningSection from '@/components/home/AwardWinningPrivacySection'; import OfficialCloudProviderSection from '@/components/home/OfficilaCloudProviderSection'; import ReviewsSection from '@/components/home/ReviewsSection'; -import { useState, useEffect} from 'react'; +import { getMinimumPrice } from '@/utils/priceHelper'; interface HomeProps { lang: GetServerSidePropsContext['locale']; @@ -73,22 +73,10 @@ const HomePage = ({ metatagsDescriptions, textContent, lang, navbarLang, footerL ); }; - - const [minimumPrice, setMinimumPrice] = useState('9.99'); const decimalDiscountForLifetime = lifetimeCoupon?.percentOff && 100 - lifetimeCoupon.percentOff; const decimalDiscount = individualCoupon?.percentOff && 100 - individualCoupon.percentOff; const percentOff = lifetimeCoupon?.percentOff !== undefined ? String(lifetimeCoupon.percentOff) : '0'; - useEffect(() => { - const price = Number(products?.individuals?.[Interval.Year]?.[0]?.price); - - if(!price) return; - - const calculatedPrice = decimalDiscount - ? (Math.floor(price * (decimalDiscount / 100) * 100) / 100).toFixed(2) - : price.toFixed(2) - - setMinimumPrice(calculatedPrice); - }, [products, decimalDiscount]); + const minimumPrice = getMinimumPrice(products, decimalDiscount); return ( { + const price = Number(products?.individuals?.[Interval.Year]?.[0]?.price); + + if (!price) return '9.99'; + + return decimalDiscount + ?(Math.floor(price * (decimalDiscount / 100) * 100) / 100).toFixed(2) + : price.toFixed(2); +} \ No newline at end of file