Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+70
-30
@@ -34,11 +34,19 @@ export default function LoginScreen({
|
||||
const emailError = actionData?.fieldErrors?.email;
|
||||
const passwordError = actionData?.fieldErrors?.password;
|
||||
const loginEmailRef = useRef<HTMLInputElement | null>(null);
|
||||
const loginPasswordRef = useRef<HTMLInputElement | null>(null);
|
||||
const [loginPassword, setLoginPassword] = useState("");
|
||||
const [magicRequestOpen, setMagicRequestOpen] = useState(Boolean(actionData?.magicLinkRequest));
|
||||
const [magicEmail, setMagicEmail] = useState(actionData?.magicLinkEmail ?? actionData?.fields?.email ?? "");
|
||||
const showMagicRequest = !actionData?.magicLinkSent && (magicRequestOpen || Boolean(actionData?.magicLinkRequest));
|
||||
const invalidCredentials = actionData?.error === t("api.errors.invalidPassword");
|
||||
const credentialFieldError = invalidCredentials ? t("account.login.invalidCredentialsTitle") : undefined;
|
||||
const passwordFieldError = credentialFieldError ?? passwordError;
|
||||
const emailErrorId = emailError ? "login-email-error" : undefined;
|
||||
const passwordErrorId = passwordFieldError ? "login-password-error" : undefined;
|
||||
const shouldClearPassword = Boolean(
|
||||
actionData && !actionData.magicLinkRequest && !actionData.magicLinkSent && (passwordError || actionData.error || actionData.requiresCaptcha)
|
||||
);
|
||||
const formError = actionData?.error && !actionData.requiresCaptcha ? actionData.error : undefined;
|
||||
const captchaSitekey = actionData?.sitekey ?? appConfiguration.auth.captcha.loginSiteKey;
|
||||
const compactActionButtons = Boolean(invalidCredentials || actionData?.requiresCaptcha);
|
||||
@@ -50,6 +58,15 @@ export default function LoginScreen({
|
||||
}
|
||||
}, [actionData?.requiresMfa, mfaVerifyPath, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldClearPassword) {
|
||||
setLoginPassword("");
|
||||
}
|
||||
if (passwordFieldError) {
|
||||
loginPasswordRef.current?.focus();
|
||||
}
|
||||
}, [actionData, passwordFieldError, shouldClearPassword]);
|
||||
|
||||
if (actionData?.requiresMfa) {
|
||||
return (
|
||||
<AuthShell title={t("account.loginMfa.title")} dataUiId="ui.auth.login.page">
|
||||
@@ -193,14 +210,14 @@ export default function LoginScreen({
|
||||
<span
|
||||
className={
|
||||
compactActionButtons
|
||||
? "text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary"
|
||||
: "text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary"
|
||||
? "text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary"
|
||||
: "text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary"
|
||||
}
|
||||
>
|
||||
{t("account.login.noAccount")}
|
||||
</span>
|
||||
<Link to="/signup" className="no-underline" data-ui-id="ui.auth.login.register">
|
||||
<LinkButton size="small" hideIcon>
|
||||
<LinkButton size="small" variant="subtle" hideIcon>
|
||||
{t("account.login.register")}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
@@ -262,28 +279,40 @@ export default function LoginScreen({
|
||||
</Card>
|
||||
</>
|
||||
) : null}
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.email")}
|
||||
helpText={credentialFieldError ? "" : emailError ?? ""}
|
||||
message={credentialFieldError ?? ""}
|
||||
error={Boolean(emailError || credentialFieldError)}
|
||||
type="email"
|
||||
>
|
||||
<TextInput.Input
|
||||
ref={loginEmailRef}
|
||||
name="email"
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<TextInput
|
||||
className="h-auto w-full flex-none"
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.email")}
|
||||
message={credentialFieldError ?? ""}
|
||||
error={Boolean(emailError || credentialFieldError)}
|
||||
type="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
defaultValue={actionData?.fields?.email}
|
||||
disabled={isSubmitting}
|
||||
data-ui-id="ui.auth.login.email"
|
||||
/>
|
||||
</TextInput>
|
||||
>
|
||||
<TextInput.Input
|
||||
ref={loginEmailRef}
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
autoComplete="email"
|
||||
placeholder={t("account.shared.emailPlaceholder")}
|
||||
defaultValue={actionData?.fields?.email}
|
||||
disabled={isSubmitting}
|
||||
aria-invalid={emailError ? true : undefined}
|
||||
aria-describedby={emailErrorId}
|
||||
data-ui-id="ui.auth.login.email"
|
||||
/>
|
||||
</TextInput>
|
||||
{emailError ? (
|
||||
<span
|
||||
id={emailErrorId}
|
||||
className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative"
|
||||
role="alert"
|
||||
>
|
||||
{emailError}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<TextInput
|
||||
@@ -291,26 +320,37 @@ export default function LoginScreen({
|
||||
fillContainer
|
||||
showLabel
|
||||
label={t("account.shared.password")}
|
||||
helpText={credentialFieldError ? "" : passwordError ?? ""}
|
||||
message={credentialFieldError ?? ""}
|
||||
error={Boolean(passwordError || credentialFieldError)}
|
||||
error={Boolean(passwordFieldError)}
|
||||
type="password"
|
||||
>
|
||||
<TextInput.Input
|
||||
ref={loginPasswordRef}
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
autoComplete="current-password"
|
||||
placeholder={t("account.shared.passwordPlaceholder")}
|
||||
defaultValue={actionData?.fields?.password}
|
||||
placeholder={t("account.login.passwordPlaceholder")}
|
||||
value={loginPassword}
|
||||
onChange={(event) => setLoginPassword(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
aria-invalid={passwordFieldError ? true : undefined}
|
||||
aria-describedby={passwordErrorId}
|
||||
data-ui-id="ui.auth.login.password"
|
||||
/>
|
||||
</TextInput>
|
||||
{passwordFieldError ? (
|
||||
<span
|
||||
id={passwordErrorId}
|
||||
className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-negative"
|
||||
role="alert"
|
||||
>
|
||||
{passwordFieldError}
|
||||
</span>
|
||||
) : null}
|
||||
|
||||
<div className="flex w-full items-start justify-end">
|
||||
<Link to="/forgot-password" className="no-underline" data-ui-id="ui.auth.login.forgot">
|
||||
<LinkButton size="small" hideIcon>
|
||||
<LinkButton size="small" variant="subtle" hideIcon>
|
||||
{t("account.login.forgot")}
|
||||
</LinkButton>
|
||||
</Link>
|
||||
|
||||
Reference in new issue
Block a user