commented unused const

This commit is contained in:
Kelvin 2025-01-10 02:07:10 -03:00
parent bff430602d
commit 87b053a283

View file

@ -33,8 +33,8 @@ const filterCategoryColors = {
};
const PAGE_SIZE = 20;
const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10
const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 225
const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10;
// const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTOM = 225;
export default function Catalogue() {
const abortControllerRef = useRef<AbortController | null>(null);
@ -50,8 +50,8 @@ export default function Catalogue() {
const [isLoading, setIsLoading] = useState(true);
const [results, setResults] = useState<any[]>([]);
const [wantGoUpButtonIsVisible, setWantGoUpButtonIsVisible] = useState(false)
const [wantGoUpButtonIsVisible, setWantGoUpButtonIsVisible] = useState(false);
const [itemsCount, setItemsCount] = useState(0);
@ -85,19 +85,21 @@ export default function Catalogue() {
).current;
useEffect(() => {
results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM ? setWantGoUpButtonIsVisible(true) : setWantGoUpButtonIsVisible(false)
console.log(cataloguePageRef.current?.scrollTop)
}, [results])
results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM
? setWantGoUpButtonIsVisible(true)
: setWantGoUpButtonIsVisible(false);
console.log(cataloguePageRef.current?.scrollTop);
}, [results]);
useEffect(() => {
const handleScroll = () => {
if (cataloguePageRef.current) {
console.log(cataloguePageRef.current.scrollTop)
console.log(cataloguePageRef.current.scrollTop);
// setScrollPosition(cataloguePageRef.current.scrollTop);
}
};
if(cataloguePageRef.current){
if (cataloguePageRef.current) {
cataloguePageRef.current.addEventListener("scroll", handleScroll);
}
@ -112,7 +114,7 @@ export default function Catalogue() {
abortControllerRef.current?.abort();
debouncedSearch(filters, PAGE_SIZE, (page - 1) * PAGE_SIZE);
return () => {
debouncedSearch.cancel();
};
@ -257,14 +259,14 @@ export default function Catalogue() {
]);
const handleWantGoUpButtonClick = () => {
if(cataloguePageRef.current){
if (cataloguePageRef.current) {
cataloguePageRef.current.scrollTo({
top: 0,
behavior: 'smooth'
})
setWantGoUpButtonIsVisible(false)
behavior: "smooth",
});
setWantGoUpButtonIsVisible(false);
}
}
};
return (
<div className="catalogue" ref={cataloguePageRef}>
@ -370,18 +372,15 @@ export default function Catalogue() {
</div>
{wantGoUpButtonIsVisible && (
<div style={{position: 'fixed', bottom: 16, left: 16 }}>
<Button
onClick={handleWantGoUpButtonClick}
theme="outline"
>
{t("result_count", {
resultCount: formatNumber(itemsCount),
})}, voltar ao topo <ArrowUpIcon />
<div style={{ position: "fixed", bottom: 16, left: 16 }}>
<Button onClick={handleWantGoUpButtonClick} theme="outline">
{t("result_count", {
resultCount: formatNumber(itemsCount),
})}
, voltar ao topo <ArrowUpIcon />
</Button>
</div>
)}
</div>
<div className="catalogue__filters-container">