Files
tfm_ainventory/frontend/components/admin/IdentityManager.tsx
Daniel Bedeleanu 9a87064dbe fix(design): replace all 40+ hardcoded colors with DESIGN.md semantic system
Phase 10 Implementation: Bulk color system compliance across frontend

Applied DESIGN_COLOR_RULES.md to 40 component and page files:
- Indigo (3) → primary/secondary (primary actions)
- Green (12) → tertiary (#00e639) (success/healthy status)
- Red/Rose (20) → error (#ffb4ab) (destructive actions)
- Amber/Sky (9) → primary/secondary (warnings/info)
- Blue/Slate (various) → primary/design system colors (focus states)
- Black → bg-surface-container-lowest (proper design color)

Files updated: 40 components + pages
Color replacements: 44+ instances
Build status: ✓ Zero errors, compiled in 6.3s
Test status: Pending (npm run test)

All colors now follow DESIGN.md Industrial Precision system:
 Primary: #ffb781 (caution orange)
 Secondary: #c8c6c5 (gray)
 Tertiary: #00e639 (healthy green)
 Error: #ffb4ab (destructive red)
 Design system enforced across all UI/UX

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-25 17:19:53 +03:00

146 lines
5.8 KiB
TypeScript

import React from 'react';
import { User, UserPlus, Shield, Edit2, Trash2, X } from 'lucide-react';
import { cn } from '@/lib/utils';
interface IdentityManagerProps {
users: any[];
onAddUser: () => void;
onDeleteUser: (id: number, username: string) => void;
editingUser: any | null;
setEditingUser: (user: any | null) => void;
editUserForm: any;
setEditUserForm: (form: any) => void;
onUpdateUserSubmit: () => void;
}
export default function IdentityManager({
users,
onAddUser,
onDeleteUser,
editingUser,
setEditingUser,
editUserForm,
setEditUserForm,
onUpdateUserSubmit
}: IdentityManagerProps) {
return (
<div className="level-1 p-4 md:p-6 flex flex-col transition-all group/identity h-full">
<div className="flex items-center justify-between mb-3">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-primary/10 flex items-center justify-center text-primary border border-primary/20">
<User size={20} />
</div>
<h2 className="text-xl font-normal text-white tracking-tight">Identity Management</h2>
</div>
<button
onClick={onAddUser}
data-testid="add-user-button"
className="btn-primary"
aria-label="Add new user"
>
<UserPlus size={16} /> Add User
</button>
</div>
<div className="flex-1 space-y-1 pr-2 -mr-2 overflow-y-auto max-h-[400px] custom-scrollbar">
{users.map((user) => (
<div key={user.id} className="flex items-center justify-between p-3 level-0 border border-border/40 hover:border-primary/30 transition-all group">
<div className="flex items-center gap-3 min-w-0">
<div className={cn(
"w-9 h-9 flex items-center justify-center transition-colors shrink-0",
user.role === 'admin' ? "bg-primary/10 text-primary border border-primary/20" : "bg-surface-bright text-muted border border-border"
)}>
{user.role === 'admin' ? <Shield size={16} /> : <User size={16} />}
</div>
<div className="min-w-0">
<p className="card-title truncate">{user.username}</p>
<p className="card-subtitle">{user.role}</p>
</div>
</div>
<div className="flex items-center gap-1.5 ml-2">
<button
onClick={() => {
setEditingUser(user);
setEditUserForm({ username: user.username, password: '', role: user.role });
}}
className="p-2 text-secondary hover:text-primary hover:bg-primary/5 transition-all"
aria-label={`Edit user ${user.username}`}
>
<Edit2 size={16} />
</button>
{user.username !== 'Admin' && (
<button
onClick={() => onDeleteUser(user.id, user.username)}
data-testid="delete-user-button"
className="p-2 text-secondary hover:text-error hover:bg-error/5 transition-all"
aria-label={`Delete user ${user.username}`}
>
<Trash2 size={16} />
</button>
)}
</div>
</div>
))}
</div>
{/* Edit User Modal */}
{editingUser && (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-background/80 animate-in fade-in duration-200">
<div className="level-2 p-6 w-full max-w-md">
<div className="flex justify-between items-center mb-3">
<h3 className="text-xl font-normal text-white tracking-tight">Edit Identity</h3>
<button
onClick={() => setEditingUser(null)}
className="p-2 text-muted hover:text-white transition-colors border border-border"
aria-label="Close edit dialog"
>
<X size={20} />
</button>
</div>
<div className="space-y-2">
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">Username</label>
<input
type="text"
value={editUserForm.username}
onChange={(e) => setEditUserForm({ ...editUserForm, username: e.target.value })}
className="input-field w-full text-sm font-mono"
/>
</div>
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">New Password (Leave Empty To Keep)</label>
<input
type="password"
value={editUserForm.password}
onChange={(e) => setEditUserForm({ ...editUserForm, password: e.target.value })}
placeholder="********"
className="input-field w-full text-sm font-mono"
/>
</div>
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">Role</label>
<select
value={editUserForm.role}
onChange={(e) => setEditUserForm({ ...editUserForm, role: e.target.value })}
className="input-field w-full text-sm appearance-none"
>
<option value="user">Standard User</option>
<option value="admin">Administrator</option>
</select>
</div>
<button
onClick={onUpdateUserSubmit}
className="btn-primary w-full py-2.5 mt-2"
>
Apply Changes
</button>
</div>
</div>
</div>
)}
</div>
);
}