feat: 統一全系統頁面標題樣式、優化側邊欄與實作角色成員查看功能
This commit is contained in:
@@ -25,6 +25,7 @@ interface Props {
|
||||
export default function RoleCreate({ groupedPermissions }: Props) {
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
name: '',
|
||||
display_name: '',
|
||||
permissions: [] as string[],
|
||||
});
|
||||
|
||||
@@ -70,8 +71,9 @@ export default function RoleCreate({ groupedPermissions }: Props) {
|
||||
'edit': '編輯',
|
||||
'delete': '刪除',
|
||||
'publish': '發布',
|
||||
'adjust': '調整',
|
||||
'adjust': '新增 / 調整',
|
||||
'transfer': '調撥',
|
||||
'safety_stock': '安全庫存設定',
|
||||
};
|
||||
|
||||
return map[action] || action;
|
||||
@@ -87,29 +89,34 @@ export default function RoleCreate({ groupedPermissions }: Props) {
|
||||
>
|
||||
<Head title="建立角色" />
|
||||
|
||||
<div className="p-8 max-w-7xl 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">
|
||||
<Shield 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('roles.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('roles.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">
|
||||
<Shield 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" />
|
||||
@@ -120,9 +127,25 @@ export default function RoleCreate({ groupedPermissions }: Props) {
|
||||
|
||||
{/* Role Name */}
|
||||
<div className="bg-white p-6 rounded-xl border border-gray-200 shadow-sm">
|
||||
<div className="max-w-md space-y-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">角色名稱 (英文代號)</Label>
|
||||
<Label htmlFor="display_name">顯示名稱 (中文/自定義)</Label>
|
||||
<Input
|
||||
id="display_name"
|
||||
placeholder="例如:行政管理員"
|
||||
value={data.display_name}
|
||||
onChange={e => setData('display_name', e.target.value)}
|
||||
/>
|
||||
{errors.display_name && (
|
||||
<p className="text-sm text-red-500">{errors.display_name}</p>
|
||||
)}
|
||||
<p className="text-xs text-gray-500">
|
||||
這是在介面上看到的名稱。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">英文代號 (系統識別用)</Label>
|
||||
<Input
|
||||
id="name"
|
||||
placeholder="e.g. sales-manager"
|
||||
|
||||
@@ -21,6 +21,7 @@ interface GroupedPermission {
|
||||
interface Role {
|
||||
id: number;
|
||||
name: string;
|
||||
display_name: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -32,6 +33,7 @@ interface Props {
|
||||
export default function RoleEdit({ role, groupedPermissions, currentPermissions }: Props) {
|
||||
const { data, setData, put, processing, errors } = useForm({
|
||||
name: role.name,
|
||||
display_name: role.display_name || '',
|
||||
permissions: currentPermissions,
|
||||
});
|
||||
|
||||
@@ -76,8 +78,9 @@ export default function RoleEdit({ role, groupedPermissions, currentPermissions
|
||||
'edit': '編輯',
|
||||
'delete': '刪除',
|
||||
'publish': '發布',
|
||||
'adjust': '調整',
|
||||
'adjust': '新增 / 調整',
|
||||
'transfer': '調撥',
|
||||
'safety_stock': '安全庫存設定',
|
||||
};
|
||||
|
||||
return map[action] || action;
|
||||
@@ -93,29 +96,34 @@ export default function RoleEdit({ role, groupedPermissions, currentPermissions
|
||||
>
|
||||
<Head title={`編輯角色 - ${role.name}`} />
|
||||
|
||||
<div className="p-8 max-w-7xl 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">
|
||||
<Shield 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('roles.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('roles.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">
|
||||
<Shield 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" />
|
||||
@@ -126,15 +134,31 @@ export default function RoleEdit({ role, groupedPermissions, currentPermissions
|
||||
|
||||
{/* Role Name */}
|
||||
<div className="bg-white p-6 rounded-xl border border-gray-200 shadow-sm">
|
||||
<div className="max-w-md space-y-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">角色名稱 (英文代號)</Label>
|
||||
<Label htmlFor="display_name">顯示名稱 (中文/自定義)</Label>
|
||||
<Input
|
||||
id="display_name"
|
||||
placeholder="例如:行政管理員"
|
||||
value={data.display_name}
|
||||
onChange={e => setData('display_name', e.target.value)}
|
||||
/>
|
||||
{errors.display_name && (
|
||||
<p className="text-sm text-red-500">{errors.display_name}</p>
|
||||
)}
|
||||
<p className="text-xs text-gray-500">
|
||||
這是在介面上看到的名稱。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">英文代號 (系統識別用)</Label>
|
||||
<Input
|
||||
id="name"
|
||||
value={data.name}
|
||||
onChange={e => setData('name', e.target.value)}
|
||||
className="font-mono bg-gray-50"
|
||||
disabled={role.name === 'super-admin'} // Should be handled by controller redirect, but extra safety
|
||||
disabled={role.name === 'super-admin'}
|
||||
/>
|
||||
{errors.name && (
|
||||
<p className="text-sm text-red-500">{errors.name}</p>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
|
||||
import { Head, Link, router } from '@inertiajs/react';
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Shield, Plus, Pencil, Trash2, Users } from 'lucide-react';
|
||||
import { Button } from '@/Components/ui/button';
|
||||
import {
|
||||
@@ -12,13 +13,30 @@ import {
|
||||
} from "@/Components/ui/table";
|
||||
import { format } from 'date-fns';
|
||||
import { toast } from 'sonner';
|
||||
import { Can } from '@/Components/Permission/Can';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/Components/ui/dialog";
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
username: string;
|
||||
}
|
||||
|
||||
interface Role {
|
||||
id: number;
|
||||
name: string;
|
||||
display_name: string;
|
||||
users_count: number;
|
||||
permissions_count: number;
|
||||
created_at: string;
|
||||
users?: User[];
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -26,6 +44,8 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function RoleIndex({ roles }: Props) {
|
||||
const [selectedRole, setSelectedRole] = useState<Role | null>(null);
|
||||
|
||||
const handleDelete = (id: number, name: string) => {
|
||||
if (confirm(`確定要刪除角色「${name}」嗎?此操作無法復原。`)) {
|
||||
router.delete(route('roles.destroy', id), {
|
||||
@@ -34,17 +54,6 @@ export default function RoleIndex({ roles }: Props) {
|
||||
}
|
||||
};
|
||||
|
||||
const translateRoleName = (name: string) => {
|
||||
const map: Record<string, string> = {
|
||||
'super-admin': '超級管理員',
|
||||
'admin': '管理員',
|
||||
'warehouse-manager': '倉庫主管',
|
||||
'purchaser': '採購人員',
|
||||
'viewer': '檢視者',
|
||||
};
|
||||
return map[name] || name;
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
breadcrumbs={[
|
||||
@@ -65,12 +74,14 @@ export default function RoleIndex({ roles }: Props) {
|
||||
設定系統角色與功能存取權限
|
||||
</p>
|
||||
</div>
|
||||
<Link href={route('roles.create')}>
|
||||
<Button className="button-filled-primary">
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
新增角色
|
||||
</Button>
|
||||
</Link>
|
||||
<Can permission="roles.create">
|
||||
<Link href={route('roles.create')}>
|
||||
<Button className="button-filled-primary">
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
新增角色
|
||||
</Button>
|
||||
</Link>
|
||||
</Can>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
||||
@@ -94,7 +105,7 @@ export default function RoleIndex({ roles }: Props) {
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
<div className="flex items-center gap-2">
|
||||
{translateRoleName(role.name)}
|
||||
{role.display_name}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-gray-500 font-mono text-xs">
|
||||
@@ -106,10 +117,19 @@ export default function RoleIndex({ roles }: Props) {
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<div className="flex items-center justify-center gap-1 text-gray-600">
|
||||
<Users className="h-3 w-3" />
|
||||
<button
|
||||
onClick={() => role.users_count > 0 && setSelectedRole(role)}
|
||||
className={cn(
|
||||
"flex items-center justify-center gap-1 w-full h-full py-2 rounded-md transition-colors",
|
||||
role.users_count > 0
|
||||
? "text-[#01ab83] hover:bg-[#01ab83]/10 font-bold"
|
||||
: "text-gray-400 cursor-default"
|
||||
)}
|
||||
title={role.users_count > 0 ? "點擊查看成員名單" : ""}
|
||||
>
|
||||
<Users className="h-3.5 w-3.5" />
|
||||
{role.users_count}
|
||||
</div>
|
||||
</button>
|
||||
</TableCell>
|
||||
<TableCell className="text-left text-gray-500 text-sm">
|
||||
{format(new Date(role.created_at), 'yyyy/MM/dd')}
|
||||
@@ -117,26 +137,30 @@ export default function RoleIndex({ roles }: Props) {
|
||||
<TableCell className="text-center">
|
||||
{role.name !== 'super-admin' && (
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Link href={route('roles.edit', role.id)}>
|
||||
<Can permission="roles.edit">
|
||||
<Link href={route('roles.edit', role.id)}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-primary"
|
||||
title="編輯"
|
||||
>
|
||||
<Pencil className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
</Can>
|
||||
<Can permission="roles.delete">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-primary"
|
||||
title="編輯"
|
||||
className="button-outlined-error"
|
||||
title="刪除"
|
||||
disabled={role.users_count > 0}
|
||||
onClick={() => handleDelete(role.id, role.display_name)}
|
||||
>
|
||||
<Pencil className="h-4 w-4" />
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-error"
|
||||
title="刪除"
|
||||
disabled={role.users_count > 0}
|
||||
onClick={() => handleDelete(role.id, translateRoleName(role.name))}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</Can>
|
||||
</div>
|
||||
)}
|
||||
</TableCell>
|
||||
@@ -146,6 +170,54 @@ export default function RoleIndex({ roles }: Props) {
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 成員名單對話框 */}
|
||||
<Dialog open={!!selectedRole} onOpenChange={(open) => !open && setSelectedRole(null)}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
<Users className="h-5 w-5 text-[#01ab83]" />
|
||||
{selectedRole?.display_name} - 成員名單
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
目前共有 {selectedRole?.users_count} 位使用者具備此角色權限
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="max-h-[60vh] overflow-y-auto pr-2">
|
||||
{selectedRole?.users && selectedRole.users.length > 0 ? (
|
||||
<div className="space-y-3">
|
||||
{selectedRole.users.map((user) => (
|
||||
<div
|
||||
key={user.id}
|
||||
className="flex items-center justify-between p-3 rounded-lg border border-gray-100 bg-gray-50/50"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="h-8 w-8 rounded-full bg-white border border-gray-200 flex items-center justify-center text-xs font-bold text-gray-500 shadow-sm">
|
||||
{user.name.charAt(0)}
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm font-semibold text-gray-900">{user.name}</p>
|
||||
<p className="text-xs text-gray-500 font-mono italic">@{user.username}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Link
|
||||
href={route('users.edit', user.id)}
|
||||
className="text-xs text-[#01ab83] hover:underline font-medium"
|
||||
>
|
||||
查看帳號
|
||||
</Link>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center py-8 text-gray-500 italic">
|
||||
暫無成員
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</AuthenticatedLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { FormEvent } from 'react';
|
||||
interface Role {
|
||||
id: number;
|
||||
name: string;
|
||||
display_name: string;
|
||||
}
|
||||
|
||||
interface UserData {
|
||||
@@ -48,16 +49,6 @@ export default function UserEdit({ user, roles, currentRoles }: Props) {
|
||||
}
|
||||
};
|
||||
|
||||
const translateRoleName = (name: string) => {
|
||||
const map: Record<string, string> = {
|
||||
'super-admin': '超級管理員',
|
||||
'admin': '管理員',
|
||||
'warehouse-manager': '倉庫主管',
|
||||
'purchaser': '採購人員',
|
||||
'viewer': '檢視者',
|
||||
};
|
||||
return map[name] || name;
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
@@ -69,29 +60,34 @@ export default function UserEdit({ user, roles, currentRoles }: Props) {
|
||||
>
|
||||
<Head title={`編輯使用者 - ${user.name}`} />
|
||||
|
||||
<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" />
|
||||
@@ -203,7 +199,7 @@ export default function UserEdit({ user, roles, currentRoles }: Props) {
|
||||
htmlFor={`role-${role.id}`}
|
||||
className="text-sm font-medium leading-none cursor-pointer"
|
||||
>
|
||||
{translateRoleName(role.name)}
|
||||
{role.display_name}
|
||||
</label>
|
||||
<p className="text-xs text-gray-500 font-mono">
|
||||
{role.name}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from "@/Components/ui/table";
|
||||
import { format } from 'date-fns';
|
||||
import { toast } from 'sonner';
|
||||
import { Can } from '@/Components/Permission/Can';
|
||||
|
||||
interface Role {
|
||||
id: number;
|
||||
@@ -88,12 +89,14 @@ export default function UserIndex({ users }: Props) {
|
||||
管理系統使用者帳號與角色分配
|
||||
</p>
|
||||
</div>
|
||||
<Link href={route('users.create')}>
|
||||
<Button className="button-filled-primary">
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
新增使用者
|
||||
</Button>
|
||||
</Link>
|
||||
<Can permission="users.create">
|
||||
<Link href={route('users.create')}>
|
||||
<Button className="button-filled-primary">
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
新增使用者
|
||||
</Button>
|
||||
</Link>
|
||||
</Can>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
||||
@@ -151,25 +154,29 @@ export default function UserIndex({ users }: Props) {
|
||||
</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Link href={route('users.edit', user.id)}>
|
||||
<Can permission="users.edit">
|
||||
<Link href={route('users.edit', user.id)}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-primary"
|
||||
title="編輯"
|
||||
>
|
||||
<Pencil className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
</Can>
|
||||
<Can permission="users.delete">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-primary"
|
||||
title="編輯"
|
||||
className="button-outlined-error"
|
||||
title="刪除"
|
||||
onClick={() => handleDelete(user.id, user.name)}
|
||||
>
|
||||
<Pencil className="h-4 w-4" />
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-error"
|
||||
title="刪除"
|
||||
onClick={() => handleDelete(user.id, user.name)}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</Can>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user