Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | "use client" import { FormEventHandler, RefObject, useRef } from "react" import Login from "./Login" import prepareComponent from "@bluframe/grapple/prepareComponent" export interface LoginInput { password: string username: string } // eslint-disable-next-line no-unused-vars export type OnSubmitLogin = (login: LoginInput) => void export interface LoginProps {} export interface Props { isLoading?: boolean name?: string onSubmitLogin: OnSubmitLogin usernameLabel?: string } export interface ComponentProps extends Omit<Props, "onSubmitLogin"> { onSubmit: FormEventHandler passwordRef: RefObject<HTMLInputElement> usernameRef: RefObject<HTMLInputElement> } export const usePrepareComponent = ({ isLoading, name, onSubmitLogin, usernameLabel }: Props): ComponentProps => { const usernameRef = useRef<HTMLInputElement>(null) const passwordRef = useRef<HTMLInputElement>(null) const onSubmit: FormEventHandler = (event) => { event.preventDefault() onSubmitLogin({ password: passwordRef.current?.value ?? "", username: usernameRef.current?.value ?? "" }) } return { isLoading, name, onSubmit, passwordRef, usernameLabel, usernameRef } } export default prepareComponent<Props, ComponentProps>(usePrepareComponent)( Login ) |