feat: include user relationship in order data and update finance and order tables to display employee details
This commit is contained in:
parent
eb13532b0b
commit
2763f1fbcc
@ -23,7 +23,7 @@ class OrderController extends Controller
|
||||
public function index(): Response
|
||||
{
|
||||
return Inertia::render('admin/manage/order/index', [
|
||||
'orders' => Order::with(['items.product'])->latest()->get(),
|
||||
'orders' => Order::with(['items.product', 'user'])->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,16 @@ interface ColumnProps {
|
||||
|
||||
|
||||
export const getColumns = ({ onEdit, onDelete, onPreviewImage }: ColumnProps): ColumnDef<Expense>[] => [
|
||||
{
|
||||
accessorKey: "user.name",
|
||||
header: ({ column }) => (
|
||||
<DataTableColumnHeader column={column} title="Pegawai" />
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm">{row.original.user?.name || '-'}</span>
|
||||
),
|
||||
meta: { title: "Pegawai" },
|
||||
},
|
||||
{
|
||||
accessorKey: "proof_url",
|
||||
header: "Bukti",
|
||||
@ -33,14 +43,6 @@ export const getColumns = ({ onEdit, onDelete, onPreviewImage }: ColumnProps): C
|
||||
},
|
||||
meta: { title: "Bukti" },
|
||||
},
|
||||
{
|
||||
accessorKey: "user.name",
|
||||
header: ({ column }) => (
|
||||
<DataTableColumnHeader column={column} title="Pegawai" />
|
||||
),
|
||||
cell: ({ row }) => row.original.user?.name,
|
||||
meta: { title: "Pegawai" },
|
||||
},
|
||||
{
|
||||
accessorKey: "name",
|
||||
header: ({ column }) => (
|
||||
|
||||
@ -24,6 +24,16 @@ export const getColumns = ({
|
||||
onDelete,
|
||||
onPrint,
|
||||
}: ColumnProps): ColumnDef<Order>[] => [
|
||||
{
|
||||
accessorKey: 'user.name',
|
||||
header: ({ column }) => (
|
||||
<DataTableColumnHeader column={column} title="Pegawai" />
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm">{row.original.user?.name || '-'}</span>
|
||||
),
|
||||
meta: { title: 'Pegawai' },
|
||||
},
|
||||
{
|
||||
accessorKey: 'order_number',
|
||||
header: ({ column }) => (
|
||||
|
||||
@ -1,20 +1,25 @@
|
||||
import type { Product } from "./product";
|
||||
import type { User } from "./auth";
|
||||
|
||||
export interface Order {
|
||||
id: number;
|
||||
order_number: string;
|
||||
customer_name: string;
|
||||
cogs: number;
|
||||
cogs_formatted: string;
|
||||
subtotal: number;
|
||||
subtotal_formatted: string;
|
||||
discount: number;
|
||||
discount_formatted: string;
|
||||
payment: number;
|
||||
payment_formatted: string;
|
||||
total: number;
|
||||
total_formatted: string;
|
||||
payment_method: 'cash' | 'transfer' | 'e_wallet' | 'qris';
|
||||
order_status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
|
||||
order_channel: 'tiktok' | 'shopee' | 'tokopedia' | 'lazada' | 'facebook' | 'website' | 'store' | 'other';
|
||||
items?: OrderItem[];
|
||||
user?: User;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
@ -44,11 +44,16 @@
|
||||
});
|
||||
|
||||
it('can access expense index page', function () {
|
||||
Expense::factory()->create();
|
||||
|
||||
get(route('expense.index'))
|
||||
->assertOk()
|
||||
->assertInertia(fn ($page) => $page
|
||||
->component('admin/finance/expense/index')
|
||||
->has('expenses')
|
||||
->has('expenses', fn ($page) => $page
|
||||
->has('0.user')
|
||||
->etc()
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -48,11 +48,16 @@
|
||||
});
|
||||
|
||||
it('can access order index page', function () {
|
||||
Order::factory()->create();
|
||||
|
||||
get(route('order.index'))
|
||||
->assertOk()
|
||||
->assertInertia(fn ($page) => $page
|
||||
->component('admin/manage/order/index')
|
||||
->has('orders')
|
||||
->has('orders', fn ($page) => $page
|
||||
->has('0.user')
|
||||
->etc()
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user