21 lines
474 B
TypeScript
21 lines
474 B
TypeScript
import Form from "@/islands/Form.tsx";
|
|
import { Signal } from "@preact/signals";
|
|
|
|
interface AskCodeProps {
|
|
page: Signal<string>;
|
|
}
|
|
|
|
export default function AskCode({ page }: AskCodeProps) {
|
|
const on_success = (data: { code: string }) => {
|
|
localStorage.setItem("code", data.code);
|
|
page.value = "keys";
|
|
};
|
|
|
|
return (
|
|
<Form action="/api/verify_code" on_success={on_success}>
|
|
<input type="text" name="code" />
|
|
<button type="submit">Enter</button>
|
|
</Form>
|
|
);
|
|
}
|