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
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return Inertia::render('admin/manage/order/index', [
|
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>[] => [
|
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",
|
accessorKey: "proof_url",
|
||||||
header: "Bukti",
|
header: "Bukti",
|
||||||
@ -33,14 +43,6 @@ export const getColumns = ({ onEdit, onDelete, onPreviewImage }: ColumnProps): C
|
|||||||
},
|
},
|
||||||
meta: { title: "Bukti" },
|
meta: { title: "Bukti" },
|
||||||
},
|
},
|
||||||
{
|
|
||||||
accessorKey: "user.name",
|
|
||||||
header: ({ column }) => (
|
|
||||||
<DataTableColumnHeader column={column} title="Pegawai" />
|
|
||||||
),
|
|
||||||
cell: ({ row }) => row.original.user?.name,
|
|
||||||
meta: { title: "Pegawai" },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
accessorKey: "name",
|
accessorKey: "name",
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
|
|||||||
@ -24,6 +24,16 @@ export const getColumns = ({
|
|||||||
onDelete,
|
onDelete,
|
||||||
onPrint,
|
onPrint,
|
||||||
}: ColumnProps): ColumnDef<Order>[] => [
|
}: 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',
|
accessorKey: 'order_number',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
|
|||||||
@ -1,20 +1,25 @@
|
|||||||
import type { Product } from "./product";
|
import type { Product } from "./product";
|
||||||
|
import type { User } from "./auth";
|
||||||
|
|
||||||
export interface Order {
|
export interface Order {
|
||||||
id: number;
|
id: number;
|
||||||
order_number: string;
|
order_number: string;
|
||||||
customer_name: string;
|
customer_name: string;
|
||||||
cogs: number;
|
cogs: number;
|
||||||
|
cogs_formatted: string;
|
||||||
subtotal: number;
|
subtotal: number;
|
||||||
subtotal_formatted: string;
|
subtotal_formatted: string;
|
||||||
discount: number;
|
discount: number;
|
||||||
|
discount_formatted: string;
|
||||||
payment: number;
|
payment: number;
|
||||||
|
payment_formatted: string;
|
||||||
total: number;
|
total: number;
|
||||||
total_formatted: string;
|
total_formatted: string;
|
||||||
payment_method: 'cash' | 'transfer' | 'e_wallet' | 'qris';
|
payment_method: 'cash' | 'transfer' | 'e_wallet' | 'qris';
|
||||||
order_status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
|
order_status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
|
||||||
order_channel: 'tiktok' | 'shopee' | 'tokopedia' | 'lazada' | 'facebook' | 'website' | 'store' | 'other';
|
order_channel: 'tiktok' | 'shopee' | 'tokopedia' | 'lazada' | 'facebook' | 'website' | 'store' | 'other';
|
||||||
items?: OrderItem[];
|
items?: OrderItem[];
|
||||||
|
user?: User;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,11 +44,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can access expense index page', function () {
|
it('can access expense index page', function () {
|
||||||
|
Expense::factory()->create();
|
||||||
|
|
||||||
get(route('expense.index'))
|
get(route('expense.index'))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertInertia(fn ($page) => $page
|
->assertInertia(fn ($page) => $page
|
||||||
->component('admin/finance/expense/index')
|
->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 () {
|
it('can access order index page', function () {
|
||||||
|
Order::factory()->create();
|
||||||
|
|
||||||
get(route('order.index'))
|
get(route('order.index'))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertInertia(fn ($page) => $page
|
->assertInertia(fn ($page) => $page
|
||||||
->component('admin/manage/order/index')
|
->component('admin/manage/order/index')
|
||||||
->has('orders')
|
->has('orders', fn ($page) => $page
|
||||||
|
->has('0.user')
|
||||||
|
->etc()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user