feat: portal password hints, company hint, interest and role delete, dashboard notes

- 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
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-02 02:59:44 +08:00
1 parent 5e68478670
commit 8ce9fcf471
36 files changed
+934 -45

No files matched your search

@@ -6,6 +6,7 @@ import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "
import { setAdminUserPassword } from "@/app/lib/services/adminUsers";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import { PasswordFields } from "./PasswordFields";
import { passwordRuleError } from "./PasswordRulesHint";
/** "Set temporary password" on the user edit page: the admin types it; the user must change it at next sign-in. */
export function SetPasswordButton({ userId, onDone }: { userId: number; onDone: () => void }) {
@@ -15,6 +16,7 @@ export function SetPasswordButton({ userId, onDone }: { userId: number; onDone:
const [confirmPassword, setConfirmPassword] = useState("");
const [error, setError] = useState<string | null>(null);
const [saving, setSaving] = useState(false);
const [ruleError, setRuleError] = useState<string | undefined>();
function close() {
// The password lives only in this state; clear it whenever the dialog closes.
@@ -22,6 +24,7 @@ export function SetPasswordButton({ userId, onDone }: { userId: number; onDone:
setPassword("");
setConfirmPassword("");
setError(null);
setRuleError(undefined);
}
async function submit(event: FormEvent<HTMLFormElement>) {
@@ -30,12 +33,15 @@ export function SetPasswordButton({ userId, onDone }: { userId: number; onDone:
if (password !== confirmPassword) return setError("UsrPasswordMismatch");
setSaving(true);
setError(null);
setRuleError(undefined);
try {
await setAdminUserPassword(userId, password, confirmPassword);
close();
onDone();
} catch (err) {
setError(err instanceof Error ? err.message : "UsrSetPasswordFailed");
const rule = passwordRuleError(err, t);
if (rule) setRuleError(rule);
else setError(err instanceof Error ? err.message : "UsrSetPasswordFailed");
} finally {
setSaving(false);
}
@@ -60,6 +66,7 @@ export function SetPasswordButton({ userId, onDone }: { userId: number; onDone:
onPassword={setPassword}
onConfirmPassword={setConfirmPassword}
disabled={saving}
passwordError={ruleError}
/>
{error && (
<div role="alert" className="rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive">