added a beta access feature
All checks were successful
Deploy / deploy (push) Successful in 47s

This commit is contained in:
2026-01-30 22:55:36 -06:00
parent c9f5d1d693
commit 27cc7d159b
3 changed files with 152 additions and 7 deletions

View File

@@ -0,0 +1,37 @@
import { type ReactNode, useEffect, useState } from "react";
import { Navigate, useLocation } from "react-router-dom";
const STORAGE_KEY = "skymoney_beta_access";
type Props = {
children: ReactNode;
};
export function BetaGate({ children }: Props) {
const location = useLocation();
const [hasAccess, setHasAccess] = useState<boolean | null>(null);
useEffect(() => {
setHasAccess(localStorage.getItem(STORAGE_KEY) === "true");
}, []);
if (location.pathname === "/beta") {
return <>{children}</>;
}
if (hasAccess === null) {
return (
<div className="flex min-h-[40vh] items-center justify-center text-sm muted">
Checking access
</div>
);
}
if (!hasAccess) {
return <Navigate to="/beta" replace />;
}
return <>{children}</>;
}
export const betaAccessStorageKey = STORAGE_KEY;