feat: 實作銷售單匯入權限控管並全面精簡權限顯示名稱
This commit is contained in:
@@ -27,6 +27,7 @@ import { format } from 'date-fns';
|
||||
import Pagination from "@/Components/shared/Pagination";
|
||||
import { SearchableSelect } from "@/Components/ui/searchable-select";
|
||||
import { router } from "@inertiajs/react";
|
||||
import { usePermission } from "@/hooks/usePermission";
|
||||
|
||||
interface ImportBatch {
|
||||
id: number;
|
||||
@@ -51,6 +52,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function SalesImportIndex({ batches, filters = {} }: Props) {
|
||||
const { can } = usePermission();
|
||||
const [perPage, setPerPage] = useState(filters?.per_page?.toString() || "10");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -88,12 +90,14 @@ export default function SalesImportIndex({ batches, filters = {} }: Props) {
|
||||
匯入並管理銷售出貨紀錄
|
||||
</p>
|
||||
</div>
|
||||
<Link href={route('sales-imports.create')}>
|
||||
<Button className="button-filled-primary gap-2">
|
||||
<Plus className="h-4 w-4" />
|
||||
新增匯入
|
||||
</Button>
|
||||
</Link>
|
||||
{can('sales_imports.create') && (
|
||||
<Link href={route('sales-imports.create')}>
|
||||
<Button className="button-filled-primary gap-2">
|
||||
<Plus className="h-4 w-4" />
|
||||
新增匯入
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg border shadow-sm overflow-hidden">
|
||||
@@ -142,7 +146,7 @@ export default function SalesImportIndex({ batches, filters = {} }: Props) {
|
||||
<Eye className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
{batch.status === 'pending' && (
|
||||
{batch.status === 'pending' && can('sales_imports.delete') && (
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button variant="outline" size="sm" className="button-outlined-error" title="刪除">
|
||||
|
||||
Reference in New Issue
Block a user