NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

"use client";
import Link from "next/link";
import React, { useEffect, useState } from "react";
import { apiUrl } from "@/app/constant/constant";
import FilterLeft from "./FilterLeft";
import { FcCheckmark } from "react-icons/fc";
import { useRouter } from "next/navigation";
import { useTranslation } from "react-i18next";
import { Pagination } from "@/app/components/Pagination/Pagination";
import QuotationModal from "@/app/components/modals/page";
import TableData from "./TableData";
import RestrictedRoute from "@/app/components/AuthProvider/RestritcedRoute";
import { fetchWithAuth } from "@/app/utils/api";

const FilterProduct = ({ data }) => {
console.log(data);
const [currentPage, setCurrentPage] = useState(1);
const { t } = useTranslation();
const router = useRouter();
const [categoryWiseData, setCategoryWiseData] = useState([]);
const [filterWiseData, setFilterWiseData] = useState([]);
const [search, setSearch] = useState("");
const [activeItems, setActiveItems] = useState([]);
const [dataItems, setDataItems] = useState([]);
const [product, setProduct] = useState([]);
const [modalIsOpen, setModalIsOpen] = useState(false);
const [categoryIds, setCategoryIds] = useState([]);
const pageSize = 10;

const onPageChange = (page) => {
setCurrentPage(page);
};

useEffect(() => {
const savedDataString = localStorage.getItem("selectData");
const savedData = JSON.parse(savedDataString) || [];
setProduct(savedData);
}, []);

useEffect(() => {
const fetchData = async () => {
try {
const sessionVariable =
typeof window !== "undefined"
? JSON.parse(localStorage.getItem("selectedCatIds"))
: null;
console.log(sessionVariable);
const purchasedId = localStorage.getItem("purchasedCatId");
console.log(purchasedId, "purchasedId");

const newSessionVar = purchasedId
? sessionVariable.concat(parseInt(purchasedId))
: sessionVariable;
console.log(newSessionVar, "newSessionVar");

if (sessionVariable) {
let options = {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
category_ids: newSessionVar,
lang: null,
}),
};
const response = await fetchWithAuth(
`${apiUrl}api/product/categorywise`,
options
);
const responseJson = await response.json();
if (responseJson.success === "true") {
setCategoryWiseData(responseJson);
}
}
} catch (error) {
console.error("Error fetching data:", error);
}
};
fetchData();
}, []);

const onChangeData = (data) => {
setFilterWiseData(data);
};

const filterSearch = search
? filterWiseData.filter((item) => {
const fname =
item.pro_name &&
item.pro_name.toLowerCase().includes(search.toLowerCase());
const supplier =
item.supplier &&
item.supplier.toLowerCase().includes(search.toLowerCase());
const main_system =
item.main_system &&
item.main_system.toLowerCase().includes(search.toLowerCase());
const price =
item.price && item.price.toLowerCase().includes(search.toLowerCase());
const compatibility_secondary =
item.compatibility_secondary &&
item.compatibility_secondary
.toLowerCase()
.includes(search.toLowerCase());
const connectivity_primary =
item.connectivity_primary &&
item.connectivity_primary
.toLowerCase()
.includes(search.toLowerCase());
const handling =
item.handling &&
item.handling.toLowerCase().includes(search.toLowerCase());
const self_programming =
item.self_programming &&
item.self_programming.toLowerCase().includes(search.toLowerCase());
return (
fname ||
supplier ||
main_system ||
price ||
compatibility_secondary ||
connectivity_primary ||
handling ||
self_programming
);
})
: filterWiseData;

return (
<RestrictedRoute>
<>
<section
className="banner"
style={{ backgroundImage: `url(/assets/img/banner3.jpg)` }}
>
<div className="container">
<div className="row">
<div className="col-md-12">
<div className="banner-caption">
<h3>{t("FilterProduct")}</h3>

<ul className="breadcrumb">
<li>
<a href="/">{t("Start")}</a>
</li>
<li>{t("FilterProduct")}</li>
</ul>
</div>
</div>
</div>
</div>
</section>

<section className="service py-100">
<div className="container-fluid">
<div className="row">
<div className="col-md-3 col-lg-2">
<div className="sidebar-header">
<h3>Filter</h3>
<a href="#">Collapse all</a>
</div>

<div className="search">
<form
onSubmit={(e) => {
e.preventDefault();
}}
>
<input
type="search"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Keyword"
/>
</form>
</div>

<FilterLeft
data={categoryWiseData}
categoryIds={categoryIds}
onChangeData={onChangeData}
/>
</div>

<div className="col-md-9 col-lg-10">
<div className="row justify-content-center">
<div className="col-md-8">
<div className="about-2-title mb-5 text-center wow fadeInUp">
<span className="section-id">Vergleich</span>
<h2 className="s-52 mb-30">
We Have <span>Many Service</span> Currentrly
</h2>
<p className="mb-0">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Quaerat alias possimus vitae. Eveniet dicta voluptatem
voluptatibus soluta vero enim iusto maxime cum corrupti
odio nemo sed eaque velit, vitae similique!
</p>
</div>
</div>
</div>

<TableData filterSearch={filterWiseData} />
</div>
</div>
</div>
</section>
</>
</RestrictedRoute>
);
};

export default FilterProduct;
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.