PageBanner.js
4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import React from "react";
import Link from "next/link";
import Image from "next/image";
import { useRouter } from "next/router";
import { Swiper, SwiperSlide } from "swiper/react";
import { Pagination, Autoplay } from "swiper/modules";
import { Container } from "react-bootstrap";
const PageBanner = ({ banners = [] }) => {
const router = useRouter();
// Function to generate breadcrumbs for client servicing pages
const generateClientServicingBreadcrumbs = () => {
const pathname = router.asPath;
// Only apply custom breadcrumbing for client-servicing pages
if (!pathname.includes('/client-servicing')) {
return null;
}
const pathSegments = pathname.split('/').filter(segment => segment);
const breadcrumbs = [];
// Create breadcrumb mapping for better display names
const segmentNameMap = {
'client-servicing': 'Client Servicing',
// Virtual Finance Office section
'virtual-finance-office': 'Virtual Finance Office',
'virtual-cfo': 'Virtual CFO Services',
'virtual-fc': 'Virtual FC Services',
'book-closures-audit': 'Book Closures and Audit Support',
'apc': 'Accounting Payroll & Compliance',
// Advisory Services section
'advisory-services': 'Advisory Services',
'transaction-advisory': 'Transaction Advisory',
'risk-advisory': 'Risk Advisory',
'business-advisory': 'Business Advisory',
// GCC as a Service
'gcc-as-a-service': 'GCC as a Service',
// Digital Transformation
'digital-transformation': 'Digital Transformation',
// Empowering Finance Consultants
'empowering-finance-consultants': 'Empowering Finance Consultants',
// Bespoke Services
'bespoke-services': 'Bespoke Services',
// Legacy mappings for existing pages
'cfo': 'CFO',
'ba': 'BA',
'ta': 'TA',
'ra': 'RA'
};
// Build breadcrumbs from path segments
let currentPath = '';
pathSegments.forEach((segment, index) => {
currentPath += `/${segment}`;
const displayName = segmentNameMap[segment] || segment.replace(/-/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
breadcrumbs.push({
name: displayName,
url: currentPath,
isLast: index === pathSegments.length - 1
});
});
return breadcrumbs;
};
const clientServicingBreadcrumbs = generateClientServicingBreadcrumbs();
return (
<Swiper
spaceBetween={30}
pagination={{
clickable: true,
}}
breakpoints={{
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 1,
},
1200: {
slidesPerView: 1,
},
}}
autoplay={{
delay: 5000,
disableOnInteraction: true,
pauseOnMouseEnter: true,
}}
modules={[Autoplay]}
className="page-banner-swiper"
>
{banners.map((banner, index) => (
<SwiperSlide key={index}>
<div className="page-title-area">
<div className="image-wrapper">
<Image
src={banner.imageSrc}
alt={banner.pageTitle}
fill
style={{ objectFit: "fill" }} // Replace objectFit prop
priority
className="img-fluid postion-absolute"
/>
</div>
<Container>
<div className="page-title-content">
<h2>{banner.pageTitle}</h2>
<ul>
{clientServicingBreadcrumbs ? (
// Custom breadcrumbs for client servicing pages
clientServicingBreadcrumbs.map((breadcrumb, breadcrumbIndex) => (
<li key={breadcrumbIndex}>
{breadcrumb.isLast ? (
breadcrumb.name
) : (
<Link href={breadcrumb.url}>{breadcrumb.name}</Link>
)}
</li>
))
) : (
// Default breadcrumbs for other pages
<>
<li>
<Link href={banner.homePageUrl}>{banner.homePageText}</Link>
</li>
<li>{banner.activePageText}</li>
</>
)}
</ul>
</div>
</Container>
</div>
</SwiperSlide>
))}
</Swiper>
);
};
export default PageBanner;