InnerDetails.js
2.74 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
import Image from "next/image";
import Link from "next/link";
import React, { useState } from "react";
import { Col, Row } from "react-bootstrap";
import { useRouter } from "next/router";
import { cleanImage } from "../services/imageHandling";
const InnerDetails = ({ subCategories }) => {
const router = useRouter();
const { category } = router.query;
const [sort, setSort] = useState("");
const handleChange = (e) => {
setSort(e.target.value);
};
// Safety check
if (!subCategories || !category) return null;
// const filteredSubCategories = subCategories.filter(
// (item) => item?.collection_category?.slug === "kitchens"
// );
return (
<section className="collection-m-section sec_padd">
<div className="custom_container">
{/* Header Row */}
<Row>
<Col xs={6}>
<h3>
{category
.split("-")
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ")}
</h3>
</Col>
<Col xs={6} className="d-flex justify-content-end">
<div className="sortby-wrapper">
<select
className="sortby-select"
value={sort}
onChange={handleChange}
>
<option value="">Sort By</option>
<option value="latest">Latest</option>
<option value="name-asc">Name: A–Z</option>
<option value="name-desc">Name: Z–A</option>
</select>
</div>
</Col>
</Row>
{/* Sub-category cards */}
<Row>
{subCategories?.map((sub) => (
<Col md={6} key={sub.slug}>
<div className="collections-item">
{/* <Link
href={sub?.show_detail_page ? `collections/${category}/${sub?.show_detail_page?.slug}` : `/collections/${category}/${sub.slug}`}
> */}
<Link
href={
sub?.show_detail_page
? `/collections/${category}/${sub?.show_detail_page?.slug}`
: `/collections/${category}/${sub.slug}`
}
>
<Image
width={868}
height={560}
src={cleanImage(sub.image?.url)}
alt={sub.title}
/>
<div className="title">{sub.title}</div>
</Link>
</div>
</Col>
))}
</Row>
{/* <Row>
<Col>
<div className="text-center">
<button className="btn3">View More <i className="fa-solid fa-arrow-right"></i></button>
</div>
</Col>
</Row> */}
</div>
</section>
);
};
export default InnerDetails;