Skip to content

Commit 2ff4387

Browse files
committed
created conditional rendering of elements
1 parent 6d53eb6 commit 2ff4387

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

www/src/pages/secret.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ import Blogs from "./components/Blogs";
1414
import { trpc } from "../utils/trpc";
1515

1616
const secret: NextPage = () => {
17-
1817
const [isAdmin, setIsAdmin] = useState<boolean>(false);
19-
const [password, setPassword] = useState<string>("")
18+
const [password, setPassword] = useState<string>("");
2019

21-
const clickHandler = (e:any) => {
20+
const clickHandler = () => {
2221
if (process.env.NEXT_PUBLIC_ADMIN_PASSWORD === password) {
2322
setIsAdmin(true);
2423
}
@@ -35,7 +34,7 @@ const secret: NextPage = () => {
3534
placeholder="password"
3635
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">
3736
</input>
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>
37+
<button onClick={clickHandler} 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>
3938
</div>}
4039
{isAdmin && <div>You logged in!</div>}
4140

0 commit comments

Comments
 (0)