Skip to content

Commit 6d53eb6

Browse files
committed
created clickHandler function
1 parent 342da52 commit 6d53eb6

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

www/src/pages/secret.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { type NextPage } from "next";
8+
import { useState } from "react";
89
import Head from "next/head";
910
import Link from "next/link";
1011
import LandingPage from "./components/LandingPage";
@@ -13,17 +14,31 @@ import Blogs from "./components/Blogs";
1314
import { trpc } from "../utils/trpc";
1415

1516
const secret: NextPage = () => {
17+
18+
const [isAdmin, setIsAdmin] = useState<boolean>(false);
19+
const [password, setPassword] = useState<string>("")
20+
21+
const clickHandler = (e:any) => {
22+
if (process.env.NEXT_PUBLIC_ADMIN_PASSWORD === password) {
23+
setIsAdmin(true);
24+
}
25+
};
26+
1627
return (
1728
<>
18-
<div className = 'flex h-screen items-center justify-center'>
29+
{!isAdmin && <div className = 'flex h-screen items-center justify-center'>
1930
<input
2031
type="password"
32+
value={password}
33+
onChange={(e)=>setPassword(e.target.value)}
2134
required
2235
placeholder="password"
2336
className="block w-50 rounded-md border border-gray-300 px-5 py-3 text-base text-gray-900 placeholder-gray-500 shadow-sm focus:border-rose-500 focus:ring-rose-500 mr-8">
2437
</input>
25-
<button className="blockrounded-md border rounded border-transparent bg-rose-500 px-5 py-3 text-base font-medium text-white shadow hover:bg-rose-600 focus:outline-none focus:ring-2 focus:ring-rose-500 focus:ring-offset-2 sm:px-10">Submit</button>
26-
</div>
38+
<button onClick={e => clickHandler(e)} className="blockrounded-md border rounded border-transparent bg-rose-500 px-5 py-3 text-base font-medium text-white shadow hover:bg-rose-600 focus:outline-none focus:ring-2 focus:ring-rose-500 focus:ring-offset-2 sm:px-10">Submit</button>
39+
</div>}
40+
{isAdmin && <div>You logged in!</div>}
41+
2742
</>
2843
);
2944
};

0 commit comments

Comments
 (0)