index.js
7.21 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import React, { useEffect, useState } from "react";
import Image from "next/image";
import PageBanner from "@/components/reuseables/PageBanner";
import { Col, Container, Row } from "react-bootstrap";
import Heading from "@/components/reuseables/Heading";
import { motion } from "framer-motion";
import { slideFromLeft } from "@/components/reuseables/variants";
import Link from "next/link";
import { useDispatch, useSelector } from "react-redux";
import { fetchTaxwireList } from "@/redux/slices/taxwireslice";
import { cleanImage } from "@/layout/imageHandling";
import qs from "qs";
import axios from "axios";
import ReactPaginate from "react-paginate";
import Seo from "@/components/reuseables/Seo/Seo";
import Pagination from "react-js-pagination";
import ConversionCode from "@/components/reuseables/ConversionCode/ConversionCode";
const TaxWire = ({ TaxwireData ,conversionData }) => {
const banners = [
{
imageSrc: cleanImage(TaxwireData?.Banner?.Image?.url),
pageTitle: TaxwireData?.Banner?.Heading,
homePageUrl: "/knowledge",
homePageText: "knowledge",
activePageText: TaxwireData?.Banner?.Heading,
},
];
const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchTaxwireList());
}, []);
const taxwirelist = useSelector((state) => state.taxwirelist.data);
const code = conversionData?.conversion;
const seo = TaxwireData?.seo;
// Pagination setup
const [currentPage, setCurrentPage] = useState(1);
const postsPerPage = 6;
const offset = (currentPage - 1) * postsPerPage;
const currentItems = taxwirelist?.slice(offset, offset + postsPerPage);
const handlePageClick = (pageNumber) => {
setCurrentPage(pageNumber);
};
return (
<>
<Seo seo={seo} />
<ConversionCode code={code} />
<PageBanner banners={banners} />
<div className="tax-wire-page-area pt-70 pb-100 bg-light ">
<Container>
<div className="section-title">
<Heading heading={TaxwireData?.Heading?.Title} el="h2" className="primary-text" />
</div>
<p className="text-center mb-3 mb-lg-5 ">
{TaxwireData?.Heading?.Description}
</p>
<Row className="align-items-center">
{currentItems &&
currentItems?.map((service, index) => (
<Col lg={4} md={6} sm={12} key={service.id}>
<motion.div
variants={slideFromLeft(0.5)}
initial={"hidden"}
whileInView={"show"}
viewport={{ once: false, amount: 0.4 }}
>
<div className="services-box-budget">
<div className="d-flex align-items-center">
<Image
src={cleanImage(service?.Image?.url)}
alt={
service?.alternativeText
? service?.alternativeText
: "image"
}
width={40}
height={40}
className="img-fluid me-3"
/>
<h3>
<Link
href={
service?.slug?.endsWith(".pdf")
? `https://api.advithconsulting.in/uploads/${service.slug}`
: `/taxwire/${
service?.slug ? service.slug : "#"
}`
}
target={
service?.slug?.endsWith(".pdf")
? "_blank"
: "_self"
}
rel={
service?.slug?.endsWith(".pdf")
? "noopener noreferrer"
: undefined
}
>
{service?.Title || "Default Service Name"}
</Link>
</h3>
</div>
<p>{service.Description}</p>
<Link
href={
service?.slug?.endsWith(".pdf")
? `https://api.advithconsulting.in/uploads/${service.slug}`
: `/taxwire/${service?.slug ? service.slug : "#"}`
}
target={
service?.slug?.endsWith(".pdf") ? "_blank" : "_self"
}
rel={
service?.slug?.endsWith(".pdf")
? "noopener noreferrer"
: undefined
}
className="default-btn"
>
Read More
<i className="ri-arrow-right-line"></i>
</Link>
</div>
</motion.div>
</Col>
))}
</Row>
{/* <ReactPaginate
previousLabel={"<<"}
nextLabel={">>"}
breakLabel={"..."}
pageCount={pageCount}
marginPagesDisplayed={2}
pageRangeDisplayed={3}
onPageChange={handlePageClick}
containerClassName={"pagination custom-pagination"}
activeClassName={"active"}
/> */}
{taxwirelist?.length > postsPerPage && (
<div className="custom-pagination">
<Pagination
activePage={currentPage}
itemsCountPerPage={postsPerPage}
totalItemsCount={taxwirelist?.length}
onChange={handlePageClick}
hideNavigation={true}
itemClass="page-item"
linkClass="page-numbers"
linkClassFirst="prev"
linkClassLast="next"
/>
</div>
)}
</Container>
</div>
</>
);
};
export default TaxWire;
export async function getServerSideProps() {
try {
const query1 = {
populate: [
"Banner.Image",
"Heading",
"seo",
"seo.metaImage",
"seo.schema",
],
};
const query2 = {
populate: ["conversion"],
};
const query1String = qs.stringify(query1, {
encodeValuesOnly: true,
});
const query12String = qs.stringify(query2, {
encodeValuesOnly: true,
});
const endpoint1 = `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/taxwire-page?${query1String}`;
const endpoint2 = `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/google-manger?${query12String}`;
console.log(`Final url: ${endpoint2}`);
const [response1, response2] = await Promise.all([
axios.get(endpoint1),
axios.get(endpoint2),
]);
const TaxwireData = response1.data.data;
const conversionData = response2.data.data;
return {
props: { TaxwireData ,conversionData },
};
} catch (error) {
console.log("Error", error);
}
}