- Login: company-code hint after an invalid-credentials failure with an empty company. - Password forms show the active rules (label-first, count-safe) and tie hint and refusal to the input. - Interests and roles: soft delete with confirm dialogs; deactivate now confirms too. - Dashboard figure explanations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { Input } from "@/app/components/ui/input";
|
|
import { Label } from "@/app/components/ui/label";
|
|
import { PasswordRulesHint } from "./PasswordRulesHint";
|
|
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
|
|
|
/** Password + confirmation inputs shared by the create form and "Set temporary password". */
|
|
export function PasswordFields(props: {
|
|
password: string;
|
|
confirmPassword: string;
|
|
onPassword: (v: string) => void;
|
|
onConfirmPassword: (v: string) => void;
|
|
disabled?: boolean;
|
|
passwordError?: string;
|
|
confirmError?: string;
|
|
/** i18n key for the first field's label; "Password" by default. */
|
|
passwordLabel?: string;
|
|
}) {
|
|
const t = useT();
|
|
const [hintShown, setHintShown] = useState(false);
|
|
return (
|
|
<>
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="user-password">{t(props.passwordLabel ?? "Password")}</Label>
|
|
<Input
|
|
id="user-password"
|
|
type="password"
|
|
autoComplete="new-password"
|
|
value={props.password}
|
|
onChange={(e) => props.onPassword(e.target.value)}
|
|
disabled={props.disabled}
|
|
aria-invalid={!!props.passwordError}
|
|
aria-describedby={[hintShown && "user-password-hint", props.passwordError && "user-password-error"].filter(Boolean).join(" ") || undefined}
|
|
/>
|
|
<PasswordRulesHint source="admin" id="user-password-hint" onShown={setHintShown} />
|
|
{props.passwordError && <p id="user-password-error" role="alert" className="text-sm text-destructive">{props.passwordError}</p>}
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="user-confirm-password">{t("UsrConfirmPassword")}</Label>
|
|
<Input
|
|
id="user-confirm-password"
|
|
type="password"
|
|
autoComplete="new-password"
|
|
value={props.confirmPassword}
|
|
onChange={(e) => props.onConfirmPassword(e.target.value)}
|
|
disabled={props.disabled}
|
|
aria-invalid={!!props.confirmError}
|
|
/>
|
|
{props.confirmError && <p role="alert" className="text-sm text-destructive">{props.confirmError}</p>}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|