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