From ad44334e0014cc1a48ac8fc58f6491084379a96e Mon Sep 17 00:00:00 2001 From: aldemirlucas Date: Fri, 17 May 2024 19:46:38 -0300 Subject: [PATCH] fix bug in input dataset home --- next/components/atoms/ControlledInput.js | 2 +- next/components/atoms/FilterAccordion.js | 4 +- next/components/organisms/Database.js | 3 +- next/pages/dataset/index.js | 282 ++++++++++++----------- 4 files changed, 148 insertions(+), 143 deletions(-) diff --git a/next/components/atoms/ControlledInput.js b/next/components/atoms/ControlledInput.js index ca0ae62e..0b129ea2 100644 --- a/next/components/atoms/ControlledInput.js +++ b/next/components/atoms/ControlledInput.js @@ -78,7 +78,7 @@ export function DebouncedControlledInput({ useEffect(() => { clearTimeout(_timeout); - _setTimeout(setTimeout(() => onChange(_value), 200)); + _setTimeout(setTimeout(() => onChange(_value), 1000)); }, [_value]); useEffect(() => { diff --git a/next/components/atoms/FilterAccordion.js b/next/components/atoms/FilterAccordion.js index 293bd76c..8a09c85c 100644 --- a/next/components/atoms/FilterAccordion.js +++ b/next/components/atoms/FilterAccordion.js @@ -32,7 +32,7 @@ export function BaseFilterAccordion({ isHovering = true }) { return ( - + {({ isExpanded }) => ( <> @@ -342,7 +342,7 @@ export function SimpleFilterAccordion({ styleChildren }) { return ( - + {({ isExpanded }) => ( <> diff --git a/next/components/organisms/Database.js b/next/components/organisms/Database.js index 1a1fa4a6..5529952f 100644 --- a/next/components/organisms/Database.js +++ b/next/components/organisms/Database.js @@ -192,8 +192,9 @@ export default function Database({ height="36px" spacing={2} > - {themes.slice(0,6).map((elm) => ( + {themes.slice(0,6).map((elm, i) => ( { if(fetchApi) clearTimeout(fetchApi) - setCount() + setIsLoading(true) + setCount(0) + setShowEmptyState(false) + const fetchFunc = setTimeout(() => { getDatasets({ q: query?.q, filters: fetchFilter(query), page: query?.page || 1 }) - }, 400) + }, 1000) setSelectedFilters(fetchFilter(query)) setFetchApi(fetchFunc) @@ -744,17 +746,21 @@ export default function SearchPage() { width="100%" paddingLeft={isMobileMod() ? "" : "40px !important"} > - {showEmptyState && resource.length === 0 ? + {showEmptyState && - : - <> + } + + {!showEmptyState && {count ? - `${count} conjunto${count > 1 ? "s": ""} encontrado${count > 1 ? "s": ""}` + `${count} conjunto${count > 1 ? "s": ""} encontrado${count > 1 ? "s": ""} para ${query.q}` : - - encontrando conjuntos + + encontrando conjuntos {query.q ? ` para ${query.q}` : ""} - } - {query.q ? ` para ${query.q}` : ""} + } + } - {/* Tags container */} - {/* - {Object.entries(paramFilters) - .filter(([k, v]) => v.length > 0) - .map(([k, values]) => ( - - ))} - */} - - {/* Order container */} - {/* + {Object.entries(paramFilters) + .filter(([k, v]) => v.length > 0) + .map(([k, values]) => ( + + ))} + */} + + {/* Order container */} + {/* + - Ordenar: + { - setOrder(event.target.value); - }} - > - - - - - - */} - - - {isLoading - ? new Array(10).fill(0).map(() => ( - <> - {useCheckMobile() ? - - : - - } - - - )) - : - (resource || []).map((res) => ( - <> - - - - )) - } - {showEmptyState && - " : "Próxima"} - breakLabel={"..."} - breakClassName={"break-me"} - forcePage={pageInfo.page - 1 || 0} - pageCount={Math.ceil(pageInfo.count / 10)} - marginPagesDisplayed={useCheckMobile() ? 0 : 1} - pageRangeDisplayed={useCheckMobile() ? 0 : 2} - onPageChange={(newPage) => { - router.push({ - pathname: router.pathname, - query: {...query, page: newPage.selected + 1 || 1} - }) - }} - containerClassName={"pagination"} - activeClassName={"active"} - pageClassName={isLoading && "disabled"} - previousClassName={isLoading && "disabled"} - nextClassName={isLoading && "disabled"} - /> - } - - {pageInfo?.count === 1 && - + + + + + + */} + + + {isLoading + ? new Array(10).fill(0).map((e, i) => ( + + {useCheckMobile() ? + + : + + } + + + )) + : + (resource || []).map((res, i) => ( + + + + + )) } - {pageInfo.page >= 2 && - " : "Próxima"} + breakLabel={"..."} + breakClassName={"break-me"} + forcePage={pageInfo.page - 1 || 0} + pageCount={Math.ceil(pageInfo.count / 10) || 1} + marginPagesDisplayed={useCheckMobile() ? 0 : 1} + pageRangeDisplayed={useCheckMobile() ? 0 : 2} + onPageChange={(newPage) => { + router.push({ + pathname: router.pathname, + query: {...query, page: newPage.selected + 1 || 1} + }) + }} + containerClassName={"pagination"} + activeClassName={"active"} + pageClassName={isLoading && "disabled"} + previousClassName={isLoading && "disabled"} + nextClassName={isLoading && "disabled"} /> } - } + + + {pageInfo?.count >=1 && pageInfo?.count <=10 && + + } + + {pageInfo.page >= 2 && + + } - ) }