| 123456789101112131415161718192021222324252627282930 |
- // components/BackButton.js
- "use client";
- import { Button } from "@nextui-org/react";
- import { useRouter } from "next/navigation";
- export default function BackButton({ currentPath, isAdmin = false }) {
- const router = useRouter();
- const handleBackNavigation = () => {
- const pathArray = currentPath.split("/").filter(Boolean);
- if (pathArray.length > 1) {
- pathArray.pop();
- const basePath = isAdmin ? "/admin-view" : "/niederlassung";
- router.push(`${basePath}/${pathArray.join("/")}`);
- }
- };
- return (
- <Button
- variant="flat"
- size="sm"
- color="default"
- className="hover:bg-sky-500 hover:text-white"
- onClick={handleBackNavigation}
- >
- Zurück
- </Button>
- );
- }
|