complete integration of direct share link as discussed in #35

This commit is contained in:
Milo Schwartz
2025-01-12 13:43:16 -05:00
parent bfd1b21f9c
commit a2ed7c7117
15 changed files with 215 additions and 37 deletions

View File

@@ -30,6 +30,7 @@ export default function AccessToken({
redirectUrl
}: AccessTokenProps) {
const [loading, setLoading] = useState(true);
const [isValid, setIsValid] = useState(false);
const api = createApiClient(useEnvContext());
@@ -49,6 +50,7 @@ export default function AccessToken({
});
if (res.data.data.session) {
setIsValid(true);
window.location.href = redirectUrl;
}
} catch (e) {
@@ -61,24 +63,47 @@ export default function AccessToken({
check();
}, [accessTokenId, accessToken]);
function renderTitle() {
if (isValid) {
return "Access Granted";
} else {
return "Access URL Invalid";
}
}
function renderContent() {
if (isValid) {
return (
<div>
You have been granted access to this resource. Redirecting
you...
</div>
);
} else {
return (
<div>
This shared access URL is invalid. Please contact the
resource owner for a new URL.
<div className="text-center mt-4">
<Button>
<Link href="/">Go Home</Link>
</Button>
</div>
</div>
);
}
}
return loading ? (
<div></div>
) : (
<Card className="w-full max-w-md">
<CardHeader>
<CardTitle className="text-center text-2xl font-bold">
Access URL Invalid
{renderTitle()}
</CardTitle>
</CardHeader>
<CardContent>
This shared access URL is invalid. Please contact the resource
owner for a new URL.
<div className="text-center mt-4">
<Button>
<Link href="/">Go Home</Link>
</Button>
</div>
</CardContent>
<CardContent>{renderContent()}</CardContent>
</Card>
);
}