feat: 統一全系統頁面標題樣式、優化側邊欄與實作角色成員查看功能

This commit is contained in:
2026-01-13 17:00:58 +08:00
parent 6600cde3bc
commit f18fb169f3
33 changed files with 938 additions and 472 deletions

View File

@@ -8,7 +8,7 @@ import { Checkbox } from '@/Components/ui/checkbox';
import { FormEvent } from 'react';
interface Props {
roles: Record<string, string>; // ID -> Name map from pluck
roles: Record<string, string>; // Name (ID) -> DisplayName map from pluck
}
export default function UserCreate({ roles }: Props) {
@@ -34,16 +34,6 @@ export default function UserCreate({ roles }: Props) {
}
};
const translateRoleName = (name: string) => {
const map: Record<string, string> = {
'super-admin': '超級管理員',
'admin': '管理員',
'warehouse-manager': '倉庫主管',
'purchaser': '採購人員',
'viewer': '檢視者',
};
return map[name] || name;
}
return (
<AuthenticatedLayout
@@ -55,29 +45,34 @@ export default function UserCreate({ roles }: Props) {
>
<Head title="新增使用者" />
<div className="p-8 max-w-4xl mx-auto">
<form onSubmit={handleSubmit} className="space-y-8">
{/* Header */}
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
<Users className="h-6 w-6 text-[#01ab83]" />
使
</h1>
<p className="text-gray-500 mt-1">
</p>
</div>
<div className="flex items-center gap-3">
<Link href={route('users.index')}>
<Button variant="outline" type="button">
<ArrowLeft className="h-4 w-4 mr-2" />
</Button>
</Link>
<div className="container mx-auto p-6 max-w-7xl">
<form onSubmit={handleSubmit} className="space-y-6">
{/* Header Area */}
<div>
<Link href={route('users.index')}>
<Button
variant="outline"
type="button"
className="gap-2 button-outlined-primary mb-2"
>
<ArrowLeft className="h-4 w-4" />
使
</Button>
</Link>
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
<Users className="h-6 w-6 text-[#01ab83]" />
使
</h1>
<p className="text-gray-500 mt-1">
</p>
</div>
<Button
type="submit"
className="bg-[#01ab83] hover:bg-[#019a76]"
className="button-filled-primary"
disabled={processing}
>
<Check className="h-4 w-4 mr-2" />
@@ -170,22 +165,22 @@ export default function UserCreate({ roles }: Props) {
<div className="bg-white p-6 rounded-xl border border-gray-200 shadow-sm h-full">
<h3 className="font-bold text-gray-900 border-b pb-2 mb-4"></h3>
<div className="space-y-4">
{Object.entries(roles).map(([id, name]) => (
<div key={id} className="flex items-start space-x-3 p-2 hover:bg-gray-50 rounded-lg transition-colors">
{Object.entries(roles).map(([roleName, displayName]) => (
<div key={roleName} className="flex items-start space-x-3 p-2 hover:bg-gray-50 rounded-lg transition-colors">
<Checkbox
id={`role-${id}`}
checked={data.roles.includes(name)}
onCheckedChange={() => toggleRole(name)}
id={`role-${roleName}`}
checked={data.roles.includes(roleName)}
onCheckedChange={() => toggleRole(roleName)}
/>
<div className="grid gap-1.5 leading-none">
<label
htmlFor={`role-${id}`}
htmlFor={`role-${roleName}`}
className="text-sm font-medium leading-none cursor-pointer"
>
{translateRoleName(name)}
{displayName}
</label>
<p className="text-xs text-gray-500 font-mono">
{name}
{roleName}
</p>
</div>
</div>