File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 55 */
66
77import { type NextPage } from "next" ;
8+ import { useState } from "react" ;
89import Head from "next/head" ;
910import Link from "next/link" ;
1011import LandingPage from "./components/LandingPage" ;
@@ -13,17 +14,31 @@ import Blogs from "./components/Blogs";
1314import { trpc } from "../utils/trpc" ;
1415
1516const 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} ;
You can’t perform that action at this time.
0 commit comments