import React, { useState } from "react"; import { signIn, auth } from "./pocketbase"; export default function Root({ children }) { const [userAuth, setUserAuth] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (event) => { event.preventDefault(); setLoading(true) await signIn(email,password) setLoading(false) }; auth.onChange(async function (user) { if (user !== null) { setUserAuth(user); } }); return ( <> {userAuth != "" ? ( <>{children} ) : (

Docs

setEmail(e.target.value)} style={{ marginBottom: "10px", padding: "5px", borderRadius: "5px", border: "1px solid #ccc", }} /> setPassword(e.target.value)} style={{ marginBottom: "10px", padding: "5px", borderRadius: "5px", border: "1px solid #ccc", }} />
)} ); }