|
| 1 | +import { fr } from "@codegouvfr/react-dsfr"; |
| 2 | +import Button from "@codegouvfr/react-dsfr/Button"; |
| 3 | +import Input from "@codegouvfr/react-dsfr/Input"; |
| 4 | +import { getKcClsx } from "keycloakify/login/lib/kcClsx"; |
| 5 | +import type { PageProps } from "keycloakify/login/pages/PageProps"; |
| 6 | +import type { I18n } from "../i18n"; |
| 7 | +import type { KcContext } from "../KcContext"; |
| 8 | + |
| 9 | +export default function LoginResetPassword(props: PageProps<Extract<KcContext, { pageId: "login-reset-password.ftl" }>, I18n>) { |
| 10 | + const { kcContext, i18n, doUseDefaultCss, Template, classes } = props; |
| 11 | + |
| 12 | + const { kcClsx } = getKcClsx({ |
| 13 | + doUseDefaultCss, |
| 14 | + classes |
| 15 | + }); |
| 16 | + |
| 17 | + const { url, messagesPerField } = kcContext; |
| 18 | + |
| 19 | + const { msg, msgStr } = i18n; |
| 20 | + |
| 21 | + return ( |
| 22 | + <Template |
| 23 | + kcContext={kcContext} |
| 24 | + i18n={i18n} |
| 25 | + doUseDefaultCss={doUseDefaultCss} |
| 26 | + classes={classes} |
| 27 | + displayMessage={!messagesPerField.existsError("username")} |
| 28 | + headerNode={msg("emailForgotTitle")} |
| 29 | + > |
| 30 | + <form |
| 31 | + id="kc-reset-password-form" |
| 32 | + className={kcClsx("kcFormClass")} |
| 33 | + action={url.loginAction} |
| 34 | + method="post" |
| 35 | + > |
| 36 | + <div className={kcClsx("kcFormGroupClass")}> |
| 37 | + <Input |
| 38 | + label={msgStr("email")} |
| 39 | + state={messagesPerField.existsError("username") ? "error" : "default"} |
| 40 | + stateRelatedMessage={messagesPerField.getFirstError("username")} |
| 41 | + nativeInputProps={{ |
| 42 | + type: "email", |
| 43 | + id: "username", |
| 44 | + name: "username", |
| 45 | + autoFocus: true, |
| 46 | + autoComplete: "email" |
| 47 | + }} |
| 48 | + /> |
| 49 | + </div> |
| 50 | + |
| 51 | + <div className={kcClsx("kcFormGroupClass")}> |
| 52 | + <div id="kc-form-options" className={kcClsx("kcFormOptionsClass")}> |
| 53 | + <div className={kcClsx("kcFormOptionsWrapperClass")} /> |
| 54 | + </div> |
| 55 | + <div id="kc-form-buttons" className={fr.cx("fr-mt-3w")} style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}> |
| 56 | + <Button type="submit">{msgStr("doSubmit")}</Button> |
| 57 | + |
| 58 | + <div> |
| 59 | + <a className={fr.cx("fr-link")} href={url.loginUrl}> |
| 60 | + {msg("backToLogin")} |
| 61 | + </a> |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + </form> |
| 66 | + </Template> |
| 67 | + ); |
| 68 | +} |
0 commit comments