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 5
5
*/
6
6
7
7
import { type NextPage } from "next" ;
8
+ import { useState } from "react" ;
8
9
import Head from "next/head" ;
9
10
import Link from "next/link" ;
10
11
import LandingPage from "./components/LandingPage" ;
@@ -13,17 +14,31 @@ import Blogs from "./components/Blogs";
13
14
import { trpc } from "../utils/trpc" ;
14
15
15
16
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
+
16
27
return (
17
28
< >
18
- < div className = 'flex h-screen items-center justify-center' >
29
+ { ! isAdmin && < div className = 'flex h-screen items-center justify-center' >
19
30
< input
20
31
type = "password"
32
+ value = { password }
33
+ onChange = { ( e ) => setPassword ( e . target . value ) }
21
34
required
22
35
placeholder = "password"
23
36
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" >
24
37
</ 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
+
27
42
</ >
28
43
) ;
29
44
} ;
You can’t perform that action at this time.
0 commit comments