"use client";
import { Button, Stack } from "@mui/material";
import Link from "next/link";
import { useSearchParams } from "next/navigation";

const LoginLinkRouting = () => {
    const searchParams = useSearchParams();

    const redirect = searchParams.get("redirect");

    return (
        <Stack direction="row" alignItems="center" justifyContent="center">
            <Button
                component={Link}
                data-testid="link_routing"
                sx={{ margin: 2 }}
                color="secondary"
                href={redirect ? decodeURIComponent(redirect) : "/"}
            >
                {`بازگشت به ${redirect ? "صفحه قبلی" : "صفحه اصلی"}`}
            </Button>
        </Stack>
    );
};
export default LoginLinkRouting;
