import { Button } from "@/components/ui/button";
import {
Card,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { Navigate, useLocation, useNavigate } from "react-router";
export const UnauthorizedPage = () => {
const { search } = useLocation();
const { t } = useTranslation();
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
const searchParams = new URLSearchParams(search);
const username = searchParams.get("username");
const resource = searchParams.get("resource");
const groupErr = searchParams.get("groupErr");
const ip = searchParams.get("ip");
const handleRedirect = () => {
setLoading(true);
navigate("/login");
};
if (!username && !ip) {
return ;
}
let i18nKey = "unauthorizedLoginSubtitle";
if (resource) {
i18nKey = "unauthorizedResourceSubtitle";
}
if (groupErr === "true") {
i18nKey = "unauthorizedGroupsSubtitle";
}
if (ip) {
i18nKey = "unauthorizedIpSubtitle";
}
return (
{t("unauthorizedTitle")}
,
}}
values={{
username,
resource,
ip,
}}
/>
);
};