From 79963422a76918904b2e5f72488e694b41e18775 Mon Sep 17 00:00:00 2001 From: Alaguraj0361 Date: Mon, 18 Aug 2025 21:27:52 +0530 Subject: [PATCH] home page about section updated --- .../ServiceSectionS2/ServiceSectionS2.js | 22 ++++++++++++++----- components/header2/Header2.js | 2 +- next-i18next.config.js | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/components/ServiceSectionS2/ServiceSectionS2.js b/components/ServiceSectionS2/ServiceSectionS2.js index f1c9f3f..15279cb 100644 --- a/components/ServiceSectionS2/ServiceSectionS2.js +++ b/components/ServiceSectionS2/ServiceSectionS2.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { TabContent, TabPane, Nav, NavItem, NavLink, Row } from "reactstrap"; import classnames from "classnames"; import Link from "next/link"; @@ -10,7 +10,7 @@ const ClickHandler = () => { }; const ServiceSectionS2 = () => { - const { t } = useTranslation("services"); // Assuming your translations are in services.json + const { t, i18n } = useTranslation("services"); // Get campaigns array from the translation JSON const campaigns = t("campaigns", { returnObjects: true }); @@ -18,9 +18,21 @@ const ServiceSectionS2 = () => { // Extract unique categories from the campaigns dynamically const categories = [...new Set(campaigns.map((service) => service.category))]; - // Default active tab is the first category + // Default active tab is the first category, but we will set it dynamically based on the language const [activeTab, setActiveTab] = useState(categories[0]); + // Function to change the active tab based on the selected language + const changeActiveTabOnLanguageChange = () => { + // Set the active tab to the first category whenever the language changes + setActiveTab(categories[0]); + }; + + // Track language changes using the `useEffect` hook + useEffect(() => { + // Whenever the language changes, reset the active tab + changeActiveTabOnLanguageChange(); + }, [i18n.language]); // `i18n.language` triggers the effect when the language changes + const toggle = (tab) => { if (activeTab !== tab) setActiveTab(tab); }; @@ -31,7 +43,7 @@ const ServiceSectionS2 = () => {
{/* Tab Navigation */}