Files
co-lite/solvway-admin-portal/app/components/users/PasswordFields.tsx
T
ngqileandClaude Opus 5.5 dd9bbbe036 fix: browser context on password-change history, plain settings errors, New password label
Found in the browser check: change-password history rows had no browser
or IP, settings errors named internal fields, and the dialog's new
password field read just "Password".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-30 14:52:15 +08:00

53 lines
1.9 KiB
TypeScript

"use client";
import { Input } from "@/app/components/ui/input";
import { Label } from "@/app/components/ui/label";
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();
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="user-password-hint"
/>
<p id="user-password-hint" className="text-sm text-muted-foreground">{t("AdminPasswordHint")}</p>
{props.passwordError && <p 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>
</>
);
}