import { Button, Code, Paper, Text } from "@mantine/core";
import { notifications } from "@mantine/notifications";
import { Navigate } from "react-router";
import { useUserContext } from "../context/user-context";
import { Layout } from "../components/layouts/layout";
import { ReactNode } from "react";
export const ContinuePage = () => {
const queryString = window.location.search;
const params = new URLSearchParams(queryString);
const redirectUri = params.get("redirect_uri") ?? "";
const { isLoggedIn, disableContinue } = useUserContext();
if (!isLoggedIn) {
return ;
}
if (redirectUri === "null" || redirectUri === "") {
return ;
}
const redirect = () => {
notifications.show({
title: "Redirecting",
message: "You should be redirected to the app soon",
color: "blue",
});
setTimeout(() => {
window.location.href = redirectUri;
}, 500);
};
if (!URL.canParse(redirectUri)) {
return (
Invalid Redirect
The redirect URL is invalid, please contact the app owner to fix the
issue.
);
}
const uri = new URL(redirectUri);
if (
window.location.protocol === "https:" &&
uri.protocol === "http:"
) {
return (
Insecure Redirect
Your are logged in but trying to redirect from https to{" "}
http, please click the button to redirect.
);
}
if (disableContinue) {
window.location.href = redirectUri;
return (
Redirecting
You should be redirected to your app soon.
);
}
return (
Continue
Click the button to continue to your app.
);
};
export const ContinuePageLayout = ({ children }: { children: ReactNode }) => {
return (
{children}
);
};