diff --git a/src/features/auth/ui/LoginForm/LoginForm.tsx b/src/features/auth/ui/LoginForm/LoginForm.tsx index 5b1c8f7..bfe4e7f 100644 --- a/src/features/auth/ui/LoginForm/LoginForm.tsx +++ b/src/features/auth/ui/LoginForm/LoginForm.tsx @@ -1,16 +1,52 @@ import { + selectEmail, selectFormValid, + selectPassword, selectStatusIsLoading, useAuthStore, } from "../../model"; -import type { SubmitEvent, ChangeEvent } from "react"; +import { + type SubmitEvent, + type ChangeEvent, + type HTMLAttributes, + type InputHTMLAttributes, + type ButtonHTMLAttributes, + cloneElement, + type ReactElement, +} from "react"; + +export type InputAttributes = InputHTMLAttributes; +export type ButtonAttributes = ButtonHTMLAttributes; + +export interface Props { + InputComponent?: ReactElement; + ButtonComponent?: ReactElement; +} + +const DefaultInputComponent = ({ + value, + onChange, + ["aria-label"]: ariaLabel, +}: InputAttributes) => ( + +); + +const DefaultButtonComponent = ({ disabled }: ButtonAttributes) => ( + + {InputComponent ? ( + cloneElement(InputComponent, { + type: "email", + value: email, + onChange: handleEmailChange, + "aria-label": "Email", + }) + ) : ( + + )} + {InputComponent ? ( + cloneElement(InputComponent, { + type: "password", + value: password, + onChange: handlePasswordChange, + "aria-label": "Password", + }) + ) : ( + + )} + {ButtonComponent ? ( + cloneElement(ButtonComponent, { + type: "submit", + disabled: disabled, + children: "Login", + }) + ) : ( + + Login + + )} ); }