From 185f5d2c27f8e16f11530059650506402ea43caa Mon Sep 17 00:00:00 2001 From: Leonid Chelakhov Date: Mon, 16 Dec 2024 14:46:39 +0300 Subject: [PATCH 1/3] Implement Footer Link Filtering Mechanism --- .../FooterComponents/FooterNavigation.jsx | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/FrontEnd/src/components/Footer/FooterComponents/FooterNavigation.jsx b/FrontEnd/src/components/Footer/FooterComponents/FooterNavigation.jsx index ae64cf63f..851860d9a 100644 --- a/FrontEnd/src/components/Footer/FooterComponents/FooterNavigation.jsx +++ b/FrontEnd/src/components/Footer/FooterComponents/FooterNavigation.jsx @@ -1,77 +1,76 @@ -import { HashLink } from 'react-router-hash-link'; import { Link } from 'react-router-dom'; - import css from './FooterNavigation.module.css'; - const PAGE_NAVIGATION_LINKS = [ { title: 'Компанії', - link: '/profiles/companies', + params: { companyType: 'companies' }, }, { title: 'Стартапи', - link: '/profiles/startups', + params: { companyType: 'startups' }, }, ]; + const SERVICES_LINKS = [ { title: 'Виробники', - link: '/profiles/producers', + params: { activity: 'producers' }, }, { title: 'Імпортери', - link: '/profiles/importers', + params: { activity: 'importers' }, }, { title: 'Роздрібні мережі', - link: '/profiles/retailers', + params: { activity: 'retailers' }, }, { title: 'HORECA', - link: '/profiles/horeca', + params: { activity: 'horeca' }, }, { title: 'Інші послуги', - link: '/profiles/other-services', + params: { activity: 'other-services' }, }, ]; function FooterNavigation() { - + const generateQueryString = (params) => + new URLSearchParams(params).toString(); return (

Підприємства

- {PAGE_NAVIGATION_LINKS.map((element) => ( - - {element.title} - - ))} + {PAGE_NAVIGATION_LINKS.map((element) => ( + + {element.title} + + ))}

Сектори

-
- {SERVICES_LINKS.map((element) => ( - - {element.title} - - ))} +
+ {SERVICES_LINKS.map((element) => ( + + {element.title} + + ))}
); } -export default FooterNavigation; \ No newline at end of file +export default FooterNavigation; From 6a711e3861a65d15a0e80c9e5290b2012bb97818 Mon Sep 17 00:00:00 2001 From: Leonid Chelakhov Date: Mon, 16 Dec 2024 19:21:48 +0300 Subject: [PATCH 2/3] added useffect profilelistpage --- FrontEnd/src/pages/ProfileList/ProfileListPage.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx b/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx index 8f1596f43..4be87222b 100644 --- a/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx +++ b/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx @@ -126,6 +126,11 @@ export default function ProfileListPage({ isAuthorized, isSaved }) { } }, [fetchedProfiles, pageSize, currentPage, isSaved]); + useEffect(() => { + setActiveTab(searchParams.get('companyType') || 'all'); + setActiveBtn(searchParams.get('activity') || 'all'); + }, [searchParams]); + const changeCompanies = (companyId, saved) => { setProfiles((prevProfiles) => prevProfiles.map((profile) => From 67c376afead5ba4d2b4c3908411dcedf016e833f Mon Sep 17 00:00:00 2001 From: Leonid Chelakhov Date: Tue, 17 Dec 2024 11:47:49 +0300 Subject: [PATCH 3/3] deleted unnecessary functions --- FrontEnd/src/pages/ProfileList/ProfileListPage.jsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx b/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx index 4be87222b..032a247f4 100644 --- a/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx +++ b/FrontEnd/src/pages/ProfileList/ProfileListPage.jsx @@ -165,14 +165,6 @@ export default function ProfileListPage({ isAuthorized, isSaved }) { updateQueryParams(page); }; - const handleActiveTab = (activeTab) => { - setActiveTab(activeTab); - }; - - const handleActiveBtn = (activeBtn) => { - setActiveBtn(activeBtn); - }; - return (
{error && error.response.status !==401 ? ( @@ -193,7 +185,7 @@ export default function ProfileListPage({ isAuthorized, isSaved }) { className={activeTab === item.key ? css['company-list__tabs--element--active'] : css['company-list__tabs--element']} - onClick={() => (handleFilters(item.value, activity), handleActiveTab(item.key))} + onClick={() => (handleFilters(item.value, activity))} > {item.title === 'Усі підприємства' ? linkText : item.title} @@ -213,7 +205,7 @@ export default function ProfileListPage({ isAuthorized, isSaved }) { className={activeBtn === item.key ? css['company-list__btns--element--active'] : css['company-list__btns--element']} - onClick={() => (handleFilters(companyType, item.value), handleActiveBtn(item.key))} + onClick={() => (handleFilters(companyType, item.value))} > {item.title}