-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
208 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useCSRF } from "src/hooks/useCSRF"; | ||
import { request, handleRequestError } from "src/utils/request"; | ||
import ConnectButton from "src/components/ConnectButton"; | ||
|
||
export default function Start() { | ||
const [unlockPassword, setUnlockPassword] = React.useState(""); | ||
const [loading, setLoading] = React.useState(false); | ||
const navigate = useNavigate(); | ||
const { data: csrf } = useCSRF(); | ||
|
||
async function onSubmit(e: React.FormEvent) { | ||
e.preventDefault(); | ||
try { | ||
setLoading(true); | ||
if (!csrf) { | ||
throw new Error("info not loaded"); | ||
} | ||
const res = await request("/api/start", { | ||
method: "POST", | ||
headers: { | ||
"X-CSRF-Token": csrf, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
unlockPassword, | ||
}), | ||
}); | ||
console.log({ res }); | ||
|
||
navigate("/apps"); | ||
} catch (error) { | ||
handleRequestError("Failed to connect", error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<form onSubmit={onSubmit}> | ||
<> | ||
<label | ||
htmlFor="greenlight-invite-code" | ||
className="block font-medium text-gray-900 dark:text-white" | ||
> | ||
Unlock password | ||
</label> | ||
<input | ||
name="unlock" | ||
onChange={(e) => setUnlockPassword(e.target.value)} | ||
value={unlockPassword} | ||
type="password" | ||
className="dark:bg-surface-00dp block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:ring-2 focus:ring-purple-700 dark:border-gray-700 dark:text-white dark:placeholder-gray-400 dark:ring-offset-gray-800 dark:focus:ring-purple-600" | ||
/> | ||
<ConnectButton isConnecting={loading} /> | ||
</> | ||
</form> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.