From 61da44d56d393b79f76e49ce9a82185c87aadc19 Mon Sep 17 00:00:00 2001 From: KyzukY Date: Wed, 19 Jun 2024 12:00:59 +0300 Subject: [PATCH 1/3] add useScrollToTop.js to hooks --- .../HeaderFooter/footer/top/FooterNavigation.jsx | 3 +++ .../PrivacyPolicyPage/PrivacyPolicyPage.jsx | 8 ++++---- FrontEnd/src/hooks/useScrollToTop.js | 12 ++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 FrontEnd/src/hooks/useScrollToTop.js diff --git a/FrontEnd/src/components/HeaderFooter/footer/top/FooterNavigation.jsx b/FrontEnd/src/components/HeaderFooter/footer/top/FooterNavigation.jsx index a393666fe..cbf2b9932 100644 --- a/FrontEnd/src/components/HeaderFooter/footer/top/FooterNavigation.jsx +++ b/FrontEnd/src/components/HeaderFooter/footer/top/FooterNavigation.jsx @@ -1,6 +1,7 @@ import { HashLink } from 'react-router-hash-link'; import { Link } from 'react-router-dom'; import css from './FooterNavigation.module.css'; +import useScrollToTop from '../../../../hooks/useScrollToTop'; const PAGE_NAVIGATION_LINKS = [ { @@ -51,6 +52,8 @@ const CONTACTS = [ ]; function FooterNavigation() { + useScrollToTop(); + return (
diff --git a/FrontEnd/src/components/PrivacyPolicyPage/PrivacyPolicyPage.jsx b/FrontEnd/src/components/PrivacyPolicyPage/PrivacyPolicyPage.jsx index 43af96dbc..6ff7513d6 100644 --- a/FrontEnd/src/components/PrivacyPolicyPage/PrivacyPolicyPage.jsx +++ b/FrontEnd/src/components/PrivacyPolicyPage/PrivacyPolicyPage.jsx @@ -1,14 +1,14 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import styles from './PrivacyPolicy.module.css'; import privacyPolicyText from './text'; import TEXT_CONTENT from './text'; import LinkContainer from '../CookiesPolicyPage/LinkContainer.jsx'; import renderContent from '../CookiesPolicyPage/RenderContent.jsx'; +import useScrollToTop from '../../hooks/useScrollToTop'; + const PrivacyPolicy = () => { - useEffect(() => { - window.scrollTo(0, 0); - }, []); + useScrollToTop(); return (
diff --git a/FrontEnd/src/hooks/useScrollToTop.js b/FrontEnd/src/hooks/useScrollToTop.js new file mode 100644 index 000000000..bd7af5fdf --- /dev/null +++ b/FrontEnd/src/hooks/useScrollToTop.js @@ -0,0 +1,12 @@ +import { useEffect } from 'react'; +import { useLocation } from 'react-router-dom'; + +const useScrollToTop = () => { + const location = useLocation(); + + useEffect(() => { + window.scrollTo(0, 0); + }, [location]); +}; + +export default useScrollToTop; \ No newline at end of file From faeca9ac1be59d650603452faf6d5f0c9a73a5ec Mon Sep 17 00:00:00 2001 From: KyzukY Date: Fri, 21 Jun 2024 12:51:54 +0300 Subject: [PATCH 2/3] add useScrollToTop.js to Cookies,Contact,Terms --- FrontEnd/src/components/Contact/Contact.jsx | 5 ++--- .../components/CookiesPolicyPage/CookiesPolicyComponent.jsx | 5 ++--- .../terms_conditions/TermsAndConditionsComponent.jsx | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/FrontEnd/src/components/Contact/Contact.jsx b/FrontEnd/src/components/Contact/Contact.jsx index 9cd95b90b..65adc27e6 100644 --- a/FrontEnd/src/components/Contact/Contact.jsx +++ b/FrontEnd/src/components/Contact/Contact.jsx @@ -4,11 +4,10 @@ import LinkContainer from '../CookiesPolicyPage/LinkContainer.jsx'; import styles from './Contact.module.css'; import contactText from './text'; import TEXT_CONTENT from './text'; +import useScrollToTop from '../../hooks/useScrollToTop'; const Contact = () => { - useEffect(() => { - window.scrollTo(0, 0); - }, []); + useScrollToTop(); return (
diff --git a/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx b/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx index c04cbc603..9e351091b 100644 --- a/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx +++ b/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx @@ -4,11 +4,10 @@ import CookiesPolicyText from './text.js'; import TEXT_CONTENT from './text.js'; import LinkContainer from './LinkContainer.jsx'; import renderContent from './RenderContent.jsx'; +import useScrollToTop from '../../hooks/useScrollToTop'; const CookiesPolicy = () => { - useEffect(() => { - window.scrollTo(0, 0); - }, []); + useScrollToTop(); return (
diff --git a/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx b/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx index fcad6abad..53e9c1fb7 100644 --- a/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx +++ b/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx @@ -4,11 +4,11 @@ import TermsAndConditionsText from './text'; import TEXT_CONTENT from './text'; import LinkContainer from '../../CookiesPolicyPage/LinkContainer.jsx'; import renderContent from '../../CookiesPolicyPage/RenderContent.jsx'; +import useScrollToTop from '../../../hooks/useScrollToTop'; + const TermsAndConditions = () => { - useEffect(() => { - window.scrollTo(0, 0); - }, []); + useScrollToTop(); return (
From cc50b477af9f0201d2f0d1f1cdb80f964a931fb5 Mon Sep 17 00:00:00 2001 From: KyzukY Date: Fri, 21 Jun 2024 12:56:04 +0300 Subject: [PATCH 3/3] fix import --- FrontEnd/src/components/Contact/Contact.jsx | 2 +- .../src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx | 2 +- .../terms_conditions/TermsAndConditionsComponent.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FrontEnd/src/components/Contact/Contact.jsx b/FrontEnd/src/components/Contact/Contact.jsx index 65adc27e6..5ab483a20 100644 --- a/FrontEnd/src/components/Contact/Contact.jsx +++ b/FrontEnd/src/components/Contact/Contact.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import renderContent from '../CookiesPolicyPage/RenderContent.jsx'; import LinkContainer from '../CookiesPolicyPage/LinkContainer.jsx'; import styles from './Contact.module.css'; diff --git a/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx b/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx index 9e351091b..9c5d93b77 100644 --- a/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx +++ b/FrontEnd/src/components/CookiesPolicyPage/CookiesPolicyComponent.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import styles from './cookiesPolicyComponent.module.css'; import CookiesPolicyText from './text.js'; import TEXT_CONTENT from './text.js'; diff --git a/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx b/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx index 53e9c1fb7..ba5bfc7fc 100644 --- a/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx +++ b/FrontEnd/src/components/terms-and-conditions-app/terms_conditions/TermsAndConditionsComponent.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import styles from './TermsAndConditionsComponent.module.css'; import TermsAndConditionsText from './text'; import TEXT_CONTENT from './text';