Compare commits
No commits in common. "3ca221473eaf41f526525448f8bfbc8ab62d53f6" and "ab1e021f2b8e4e6166831d1949874670f95aaec4" have entirely different histories.
3ca221473e
...
ab1e021f2b
@ -3,22 +3,17 @@ import { TabContent, TabPane, Nav, NavItem, NavLink, Row } from "reactstrap";
|
|||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useTranslation } from "next-i18next";
|
import { TabServices } from "../../utils/constant.utils"; // JSON array
|
||||||
|
import Campaign from "../../api/campaign";
|
||||||
|
|
||||||
const ClickHandler = () => {
|
const ClickHandler = () => {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(10, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Extract unique categories from the JSON dynamically
|
||||||
|
const categories = [...new Set(Campaign.map((service) => service.category))];
|
||||||
|
|
||||||
const ServiceSectionS2 = () => {
|
const ServiceSectionS2 = () => {
|
||||||
const { t } = useTranslation("services"); // Assuming your translations are in services.json
|
|
||||||
|
|
||||||
// Get campaigns array from the translation JSON
|
|
||||||
const campaigns = t("campaigns", { returnObjects: true });
|
|
||||||
|
|
||||||
// Extract unique categories from the campaigns dynamically
|
|
||||||
const categories = [...new Set(campaigns.map((service) => service.category))];
|
|
||||||
|
|
||||||
// Default active tab is the first category
|
|
||||||
const [activeTab, setActiveTab] = useState(categories[0]);
|
const [activeTab, setActiveTab] = useState(categories[0]);
|
||||||
|
|
||||||
const toggle = (tab) => {
|
const toggle = (tab) => {
|
||||||
@ -48,18 +43,15 @@ const ServiceSectionS2 = () => {
|
|||||||
{categories.map((cat, idx) => (
|
{categories.map((cat, idx) => (
|
||||||
<TabPane tabId={cat} key={idx}>
|
<TabPane tabId={cat} key={idx}>
|
||||||
<Row>
|
<Row>
|
||||||
{/* Filter campaigns based on category */}
|
{Campaign.filter((srv) => srv.category === cat).slice(0,3).map(
|
||||||
{campaigns
|
(service, srvIdx) => (
|
||||||
.filter((srv) => srv.category === cat)
|
|
||||||
.slice(0, 3) // Limit to 3 services per category
|
|
||||||
.map((service, srvIdx) => (
|
|
||||||
<div className="col-lg-4 col-md-6 col-12" key={srvIdx}>
|
<div className="col-lg-4 col-md-6 col-12" key={srvIdx}>
|
||||||
<div className="wpo-campaign-single">
|
<div className="wpo-campaign-single">
|
||||||
<div className="wpo-campaign-item">
|
<div className="wpo-campaign-item">
|
||||||
<div className="wpo-campaign-img">
|
<div className="wpo-campaign-img">
|
||||||
<Image
|
<Image
|
||||||
src={service.sImgS} // Service Image
|
src={service.sImgS}
|
||||||
alt={service.sTitle} // Service Title for Alt text
|
alt={service.sTitle}
|
||||||
width={400}
|
width={400}
|
||||||
height={250}
|
height={250}
|
||||||
/>
|
/>
|
||||||
@ -70,25 +62,19 @@ const ServiceSectionS2 = () => {
|
|||||||
<Link
|
<Link
|
||||||
onClick={ClickHandler}
|
onClick={ClickHandler}
|
||||||
href={`/service-single/[slug]`}
|
href={`/service-single/[slug]`}
|
||||||
as={`/service-single/${service.slug}`} // Dynamic slug
|
as={`/service-single/${service.slug}`}
|
||||||
>
|
>
|
||||||
{service.sTitle} {/* Service Title */}
|
{service.sTitle}
|
||||||
</Link>
|
</Link>
|
||||||
</h2>
|
</h2>
|
||||||
<p
|
<p>{service.description}</p>
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html:
|
|
||||||
service.description.length > 100
|
|
||||||
? service.description.substring(0, 100) + '...'
|
|
||||||
: service.description,
|
|
||||||
}}
|
|
||||||
></p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
locales: ['en', 'es'],
|
locales: ['en', 'es'],
|
||||||
localeDetection: false,
|
localeDetection: false,
|
||||||
},
|
},
|
||||||
ns: ['common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction', 'blog', 'footer', 'ourMission', 'racialJustice', 'services', 'ourStory', 'aboutService', 'aboutMission', 'aboutRacial', 'aboutDonor', 'contact'],
|
ns: ['common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction', 'blog', 'footer', 'ourMission', 'racialJustice', 'services', 'ourStory', 'aboutService', 'aboutMission', 'aboutRacial', 'aboutDonor'],
|
||||||
defaultNS: 'common',
|
defaultNS: 'common',
|
||||||
// localePath: './public/locales',
|
// localePath: './public/locales',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export default HomePage;
|
|||||||
export async function getStaticProps({ locale }) {
|
export async function getStaticProps({ locale }) {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
...(await serverSideTranslations(locale, ['common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction', 'blog', 'footer', 'services'])), // Add 'home', 'footer', etc. if needed
|
...(await serverSideTranslations(locale, ['common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction', 'blog', 'footer'])), // Add 'home', 'footer', etc. if needed
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user