From ecca4038b313c5985b5ab915a2c2c6986e37429f Mon Sep 17 00:00:00 2001 From: matthew Date: Wed, 5 Oct 2022 00:38:22 +0400 Subject: [PATCH] fix bugs --- .../app/core/components/Footer/Footer.tsx | 33 +++++++++++++++---- .../core/components/Footer/styles.module.css | 19 ++++++++--- .../core/components/SearchForm/SearchForm.tsx | 11 ++++--- searching-front/app/core/helpers/metrika.ts | 3 ++ .../app/core/pages/Search/Search.tsx | 10 +++--- searching-front/app/i18n/en.ts | 4 +++ searching-front/app/i18n/ru.ts | 4 +++ searching-front/pages/_document.tsx | 32 +++++++++++++----- 8 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 searching-front/app/core/helpers/metrika.ts diff --git a/searching-front/app/core/components/Footer/Footer.tsx b/searching-front/app/core/components/Footer/Footer.tsx index 7e3f666..9db4f50 100644 --- a/searching-front/app/core/components/Footer/Footer.tsx +++ b/searching-front/app/core/components/Footer/Footer.tsx @@ -1,4 +1,5 @@ import { Routes } from "@blitzjs/next" +import { count } from "app/core/helpers/metrika" import TonLogo from "app/core/icons/TonLogo" import { useRouter } from "next/router" import { useTranslation } from "react-i18next" @@ -7,20 +8,38 @@ import ThemeSwitcher from "../ThemeSwitcher/ThemeSwitcher" import s from "./styles.module.css" import TGLogo from "./TGLogo" -const Header = () => { - const { route } = useRouter() - const router = useRouter() +interface FooterLinkProps { + href: string; + keyLink: string; + isTg?: boolean; + +} + +const FooterLink = ({href,keyLink,isTg}:FooterLinkProps) => { + const { t } = useTranslation() + const onClick =() => { + count(keyLink) + } + return ( + + {isTg && } {t(keyLink)} + + ) +} + +const Footer = () => { const { t } = useTranslation() return (
-
- {t("footer.contacts-description")} - +
+ + +
) } -export default Header +export default Footer diff --git a/searching-front/app/core/components/Footer/styles.module.css b/searching-front/app/core/components/Footer/styles.module.css index 3758cb3..e10e1bb 100644 --- a/searching-front/app/core/components/Footer/styles.module.css +++ b/searching-front/app/core/components/Footer/styles.module.css @@ -3,14 +3,25 @@ display: flex; justify-content: center; } + .tgIcon { - width: 25px; - height: 25px; - margin-top: 10px; + width: 10px; + height: 10px; + margin-right: 5px; } + .contactsWrapper { + flex: 1; display: flex; - flex-direction: column; + justify-content: space-between; align-items: center; color: var(--text_secondary); + max-width: 600px; +} + +.footerLinkRoot { + text-decoration: none; + color: var(--text_secondary); + display: flex; + align-items: center; } \ No newline at end of file diff --git a/searching-front/app/core/components/SearchForm/SearchForm.tsx b/searching-front/app/core/components/SearchForm/SearchForm.tsx index f36211d..4e133ac 100644 --- a/searching-front/app/core/components/SearchForm/SearchForm.tsx +++ b/searching-front/app/core/components/SearchForm/SearchForm.tsx @@ -52,11 +52,15 @@ const SearchForm = () => { setFocusedSuggestion(null) await router.push(Routes.SearchPage({ query })) } + + const filteredSuggestion = suggestions?.filter((item) => item.text !== value) + const shouldShowSuggestion = filteredSuggestion && !!filteredSuggestion.length + useKeyPressEvent("Enter", async () => { if (inputIsFocused) { blurInput() if (filteredSuggestion?.length && suggestions && focusedSuggestion) { - await onSubmit(suggestions[focusedSuggestion - 1]?.text) + await onSubmit(filteredSuggestion[focusedSuggestion - 1]?.text) } else { await onSubmit(value) } @@ -111,9 +115,8 @@ const SearchForm = () => { setInputFocused(true) }, []) - const filteredSuggestion = suggestions?.filter((item) => item.text !== value) - const shouldShowSuggestion = filteredSuggestion && !!filteredSuggestion.length - + + debugger return ( diff --git a/searching-front/app/core/helpers/metrika.ts b/searching-front/app/core/helpers/metrika.ts new file mode 100644 index 0000000..c62b93a --- /dev/null +++ b/searching-front/app/core/helpers/metrika.ts @@ -0,0 +1,3 @@ +export const count = (event:string) => { + yaCounter90644479.reachGoal(event) +} \ No newline at end of file diff --git a/searching-front/app/core/pages/Search/Search.tsx b/searching-front/app/core/pages/Search/Search.tsx index b14d73b..3cb0061 100644 --- a/searching-front/app/core/pages/Search/Search.tsx +++ b/searching-front/app/core/pages/Search/Search.tsx @@ -5,17 +5,18 @@ import WebsiteCard from "app/core/components/WebsiteCard" import getSearchResult from "app/search-requests/queries/getSearchResult" import { useRouter } from "next/router" import { useState } from "react" +import { useTranslation } from "react-i18next" import ReactPaginate from "react-paginate" import s from "./styles.module.css" const Search = () => { const router = useRouter() - + const {t} = useTranslation() const [page, setPage] = useState(0) - + const text = router.query.query as string; const [res] = useQuery( getSearchResult, - { text: router.query.query as string, page }, + { text, page }, { suspense: false, keepPreviousData: true } ) const onPageChange = (page: number) => { @@ -41,7 +42,8 @@ const Search = () => {
) } else if (res && !res.hits.length) { - return "not found" + return
{t("searchPage.notFound")}«{text}»
+ } return "loading" } diff --git a/searching-front/app/i18n/en.ts b/searching-front/app/i18n/en.ts index b397392..e5d24fe 100644 --- a/searching-front/app/i18n/en.ts +++ b/searching-front/app/i18n/en.ts @@ -2,7 +2,11 @@ const en = { translation: { "search.placeholder": "Find your own ton", "search.button": "Search", + "searchPage.notFound": "No results found for ", "footer.contacts-description": "Feedback, suggestions, bug reports", + "footer.linkContacts": "Contact Us", + "footer.linkAnnouncments": "Announcments", + "footer.linkFeedback": "Feedback", }, } diff --git a/searching-front/app/i18n/ru.ts b/searching-front/app/i18n/ru.ts index 4d8fec1..f2c144a 100644 --- a/searching-front/app/i18n/ru.ts +++ b/searching-front/app/i18n/ru.ts @@ -2,7 +2,11 @@ const ru = { translation: { "search.placeholder": "Найди свой собственный TON", "search.button": "Найти", + "searchPage.notFound": "Ничего не найдено по запросу ", "footer.contacts-description": "Отзывы, предложения, багрепорты", + "footer.linkContacts": "Связаться с нами", + "footer.linkAnnouncments": "Новости", + "footer.linkFeedback": "Оставить обратную связь", }, } diff --git a/searching-front/pages/_document.tsx b/searching-front/pages/_document.tsx index a5064a3..e8e6638 100644 --- a/searching-front/pages/_document.tsx +++ b/searching-front/pages/_document.tsx @@ -11,10 +11,25 @@ class MyDocument extends Document { -
- + + - + `, + }} + >