Skip to content

Commit

Permalink
feat: show transaction history in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
nisrinasalm committed Dec 10, 2024
1 parent 056b28a commit d94a271
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/TransactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function index(Request $request)

$category = Category::all();

$transaction = Transaction::with(['cart_product.product.category'])
$transaction = Transaction::with(['cart_product.user', 'cart_product.product.category'])
->whereHas('cart_product.product.category', function ($query) use ($categoryIds) {
if (!empty($categoryIds)) {
$query->whereIn('category_id', $categoryIds);
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Layouts/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function Navbar() {
Cart
</NavLink>
)}{" "}
{auth.user !== null && auth.user.role === "user" && (
{auth.user !== null && (
<NavLink
href={route("transaction.index")}
active={route().current("transaction.index")}
Expand Down
6 changes: 6 additions & 0 deletions resources/js/Pages/Transaction/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ export default function TransactionIndex({
<Typography variant="s3" className="text-typo-secondary">
TR/{format(new Date(t.created_at), "yyyyMMdd")}/{t.id}
</Typography>
<Typography variant="s3" className="text-typo-tertiary">
|
</Typography>
<Typography variant="s3" className="text-typo-secondary">
{t.cart_product[0].user.name}
</Typography>
</div>
<div className="flex flex-col gap-4 w-full">
<ProductItems
Expand Down
4 changes: 4 additions & 0 deletions resources/js/types/entities/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export type CartType = {
product_id: string;
quantity: number;
product: ProductType;
user: {
id: string;
name: string;
};
};

0 comments on commit d94a271

Please sign in to comment.