diff --git a/frontend/src/components/inbox/components/ConversationsList.tsx b/frontend/src/components/inbox/components/ConversationsList.tsx index 3a1b1c8b..2d71b614 100644 --- a/frontend/src/components/inbox/components/ConversationsList.tsx +++ b/frontend/src/components/inbox/components/ConversationsList.tsx @@ -21,7 +21,6 @@ import { useTranslate } from "@/hooks/useTranslate"; import { Title } from "@/layout/content/Title"; import { EntityType, RouterType } from "@/services/types"; import { normalizeDate } from "@/utils/date"; -import { extractQueryParamsUrl } from "@/utils/URL"; import { getAvatarSrc } from "../helpers/mapMessages"; import { useChat } from "../hooks/ChatContext"; @@ -75,10 +74,7 @@ export const SubscribersList = (props: { { chat.setSubscriberId(subscriber.id); - push({ - pathname: `/${RouterType.INBOX}/subscribers/${subscriber.id}`, - query: extractQueryParamsUrl(window.location.href), - }); + push(`/${RouterType.INBOX}/subscribers/${subscriber.id}`); }} className="changeColor" key={subscriber.id} diff --git a/frontend/src/components/inbox/index.tsx b/frontend/src/components/inbox/index.tsx index e57e8192..a34d6d62 100644 --- a/frontend/src/components/inbox/index.tsx +++ b/frontend/src/components/inbox/index.tsx @@ -26,7 +26,7 @@ import { AssignedTo } from "./types"; export const Inbox = () => { const { t } = useTranslate(); - const { onSearch, searchPayload, searchText } = useSearch({ + const { onSearch, searchPayload } = useSearch({ $or: ["first_name", "last_name"], }); const [channels, setChannels] = useState([]); @@ -48,7 +48,6 @@ export const Inbox = () => { onSearch("")} className="changeColor" onChange={(v) => onSearch(v)} diff --git a/frontend/src/hooks/useSearch.tsx b/frontend/src/hooks/useSearch.tsx index ac4e2605..34c6ab25 100644 --- a/frontend/src/hooks/useSearch.tsx +++ b/frontend/src/hooks/useSearch.tsx @@ -7,8 +7,7 @@ */ import { debounce } from "@mui/material"; -import { useRouter } from "next/router"; -import { ChangeEvent, useCallback, useEffect, useState } from "react"; +import { ChangeEvent, useState } from "react"; import { TBuildInitialParamProps, @@ -53,38 +52,13 @@ const buildNeqInitialParams = ({ ); export const useSearch = (params: TParamItem) => { - const router = useRouter(); - const [searchText, setSearchText] = useState( - (router.query.search as string) || "", + const [searchText, setSearchText] = useState(""); + const onSearch = debounce( + (e: ChangeEvent | string) => { + setSearchText(typeof e === "string" ? e : e.target.value); + }, + 300, ); - - useEffect(() => { - if (router.query.search !== searchText) { - setSearchText((router.query.search as string) || ""); - } - }, [router.query.search]); - - const updateQueryParams = useCallback( - debounce(async (newSearchText: string) => { - await router.replace( - { - pathname: router.pathname, - query: { ...router.query, search: newSearchText || undefined }, - }, - undefined, - { shallow: true }, - ); - }, 300), - [router], - ); - const onSearch = ( - e: ChangeEvent | string, - ) => { - const newSearchText = typeof e === "string" ? e : e.target.value; - - setSearchText(newSearchText); - updateQueryParams(newSearchText); - }; const { $eq: eqInitialParams, $iLike: iLikeParams, @@ -93,7 +67,6 @@ export const useSearch = (params: TParamItem) => { } = params; return { - searchText, onSearch, searchPayload: { where: { diff --git a/frontend/src/utils/URL.ts b/frontend/src/utils/URL.ts index 4656c4ee..bbb01a14 100644 --- a/frontend/src/utils/URL.ts +++ b/frontend/src/utils/URL.ts @@ -6,8 +6,6 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ -import qs from "qs"; - export const buildURL = (baseUrl: string, relativePath: string): string => { try { return new URL(relativePath).toString(); @@ -39,12 +37,3 @@ export const isAbsoluteUrl = (value: string = ""): boolean => { return false; } }; - -// todo: in the future we might need to extract this logic into a hook -export const extractQueryParamsUrl = (fullUrl: string): string => { - const extractedQueryParams = qs.parse(new URL(fullUrl).search, { - ignoreQueryPrefix: true, - }); - - return qs.stringify(extractedQueryParams); -};