This commit is contained in:
2026-04-28 09:27:54 +07:00
commit 68d05da584
320 changed files with 26229 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import { useRouter } from "next/navigation";
const useGoBack = () => {
const router = useRouter();
const goBack = () => {
if (window.history.length > 1) {
router.back(); // Navigate to the previous route
} else {
router.push("/"); // Redirect to home if no history exists
}
};
return goBack;
};
export default useGoBack;
+12
View File
@@ -0,0 +1,12 @@
"use client";
import { useState, useCallback } from "react";
export const useModal = (initialState: boolean = false) => {
const [isOpen, setIsOpen] = useState(initialState);
const openModal = useCallback(() => setIsOpen(true), []);
const closeModal = useCallback(() => setIsOpen(false), []);
const toggleModal = useCallback(() => setIsOpen((prev) => !prev), []);
return { isOpen, openModal, closeModal, toggleModal };
};