first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
function useContainerHeight(): string {
|
||||
const [containerHeight, setContainerHeight] = useState("100vh");
|
||||
|
||||
useEffect(() => {
|
||||
const calculateHeight = () => {
|
||||
const footer = document.getElementById("tx.home.footer.container");
|
||||
return footer ? `calc(100vh - ${footer.clientHeight}px - 138px)` : "100vh";
|
||||
};
|
||||
|
||||
setContainerHeight(calculateHeight());
|
||||
|
||||
// Escuchar cambios de tamaño en la ventana por si el footer cambia
|
||||
const handleResize = () => setContainerHeight(calculateHeight());
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
|
||||
return containerHeight;
|
||||
}
|
||||
|
||||
export default useContainerHeight;
|
||||
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const useWindowSize = () => {
|
||||
const [size, setSize] = useState<[number, number]>([0, 0]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
const updateSize = () => {
|
||||
setSize([window.innerWidth, window.innerHeight]);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", updateSize);
|
||||
window.addEventListener("load", updateSize);
|
||||
updateSize();
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("load", updateSize);
|
||||
window.removeEventListener("resize", updateSize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return size;
|
||||
};
|
||||
|
||||
export default useWindowSize;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { useFilterStore } from "@core/Store/Filter.Store";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export const useNavigation = () => {
|
||||
const filter = useFilterStore();
|
||||
const router = useRouter();
|
||||
|
||||
const goTo = (path: string) => {
|
||||
router.push(path);
|
||||
filter.clear();
|
||||
};
|
||||
|
||||
return { goTo };
|
||||
};
|
||||
Reference in New Issue
Block a user