at main 56 lines 1.7 kB view raw
1import { useCallback, useState } from 'react'; 2import { PostJson } from './Fetch'; 3 4export function SecretPassword({ did, role }) { 5 const [submission, setSubmission] = useState(0); 6 const [submitting, setSubmitting] = useState(false); 7 8 const handleSubmit = useCallback(e => { 9 e.preventDefault(); 10 setSubmission(n => n + 1); 11 setSubmitting(true); 12 }) 13 14 return ( 15 <form method="post" onSubmit={handleSubmit}> 16 <h2>Secret early access</h2> 17 <p>This demo is still in development! Your support helps keep it going: <a href="https://github.com/sponsors/uniphil/" target="_blank">github sponsors</a>, <a href="https://ko-fi.com/bad_example" target="_blank">ko-fi</a>.</p> 18 19 {submitting ? ( 20 <PostJson 21 key={submission} 22 endpoint="/super-top-secret-access" 23 data={{ secret_password: "letmein" }} 24 credentials 25 loading={() => (<>Checking&hellip;</>)} 26 error={e => { 27 console.log('err', e); 28 return ( 29 <> 30 <p>whateverrrr</p> 31 <p> 32 <button onClick={() => setSubmitting(false)}>retry</button> 33 </p> 34 </> 35 ); 36 }} 37 ok={() => ( 38 <> 39 <p style={{ color: "#9f0" }}>Secret password accepted.</p> 40 <p> 41 {/* an <a> tag, not a <Link>, on purpose so we relaod for our role */} 42 <a className="button" href="/early?hello"> 43 Continue 44 </a> 45 </p> 46 </> 47 )} 48 /> 49 ) : ( 50 <p> 51 <button type="submit">Let me in</button> 52 </p> 53 )} 54 </form> 55 ); 56}