diff --git a/client/src/App.tsx b/client/src/App.tsx index 214605b..e8b9b3d 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,6 +2,7 @@ import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; import { Toaster } from "./ui/elements/sonner"; import { Home } from "./ui/screens/Home"; import { TooltipProvider } from "@/ui/elements/tooltip"; +import DevPage from "./ui/screens/DevPage"; export default function App() { return ( @@ -9,6 +10,7 @@ export default function App() { } /> + } /> diff --git a/client/src/main.tsx b/client/src/main.tsx index aa675a0..db088b2 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -13,6 +13,7 @@ import { sepolia, mainnet } from "@starknet-react/chains"; import cartridgeConnector from "./cartridgeConnector.tsx"; import "./index.css"; +import DevPage from "./ui/screens/DevPage.tsx"; const { VITE_PUBLIC_DEPLOY_TYPE } = import.meta.env; @@ -58,7 +59,10 @@ export function Main() { ) : ( - + <> + + {import.meta.env.DEV && } + )} diff --git a/client/src/ui/components/PasswordProtected.tsx b/client/src/ui/components/PasswordProtected.tsx new file mode 100644 index 0000000..7e73cf7 --- /dev/null +++ b/client/src/ui/components/PasswordProtected.tsx @@ -0,0 +1,47 @@ +// src/components/PasswordProtected.jsx +import React, { useState } from "react"; + +const PasswordProtected = ({ children }) => { + const [password, setPassword] = useState(""); + const [isAuthenticated, setIsAuthenticated] = useState(false); + const correctPassword = import.meta.env.VITE_TESTINGPAGE_PASSWORD; + + const handleSubmit = (e) => { + e.preventDefault(); + if (password === correctPassword) { + setIsAuthenticated(true); + } else { + alert("Mot de passe incorrect !"); + } + }; + + if (isAuthenticated) { + return <>{children}; + } + + return ( +
+
+

Entrez le mot de passe

+ setPassword(e.target.value)} + placeholder="Mot de passe" + className="w-full px-4 py-2 border rounded mb-4" + /> + +
+
+ ); +}; + +export default PasswordProtected; diff --git a/client/src/ui/screens/DevPage.tsx b/client/src/ui/screens/DevPage.tsx new file mode 100644 index 0000000..5e833e2 --- /dev/null +++ b/client/src/ui/screens/DevPage.tsx @@ -0,0 +1,16 @@ +import PasswordProtected from "../components/PasswordProtected"; + +const DevPage = () => { + return ( + +
+

+ Page de développement +

+

Cette page est uniquement visible en mode développement.

+
+
+ ); +}; + +export default DevPage;