perbaikan fitur inventory

This commit is contained in:
aji@catalis.app
2025-07-12 14:23:33 +07:00
parent b1eee524c7
commit 8d7e5dae76
2 changed files with 44 additions and 28 deletions

View File

@@ -9,7 +9,7 @@
| "vb_timesheet" | "vb_timesheet"
| "vb_inventory" | "vb_inventory"
| "vb_projects" | "vb_projects"
| "vb_vendors" | "vb_vendor"
| "vb_employee" | "vb_employee"
| "vb_transport" | "vb_transport"
| "vb_dinning" | "vb_dinning"
@@ -22,7 +22,7 @@
vb_timesheet: 0, vb_timesheet: 0,
vb_inventory: 0, vb_inventory: 0,
vb_projects: 0, vb_projects: 0,
vb_vendors: 0, vb_vendor: 0,
vb_employee: 0, vb_employee: 0,
vb_transport: 0, vb_transport: 0,
vb_dinning: 0, vb_dinning: 0,
@@ -73,7 +73,7 @@
}, },
{ {
label: "Total Vendor", label: "Total Vendor",
key: "vb_vendors", key: "vb_vendor",
color: "text-orange-600", color: "text-orange-600",
icon: "building-storefront", icon: "building-storefront",
}, },

View File

@@ -441,10 +441,15 @@
<span>📋</span> <span>📋</span>
Inventory Management Inventory Management
</h2> </h2>
<p class="text-sm text-gray-600"> <p class="text-sm text-gray-600 mb-2">
Manage your inventory items, track stock levels, and ensure Manage your inventory items, track stock levels, and ensure
everything is in order. everything is in order.
</p> </p>
<p class="text-xs text-gray-500 italic mb-2">
Note : Tekan tombol Enter untuk menyimpan. <span
class="text-red-500">⚠️</span
>
</p>
</div> </div>
<div class="flex flex-col sm:flex-row sm:items-center gap-2"> <div class="flex flex-col sm:flex-row sm:items-center gap-2">
<input <input
@@ -525,7 +530,7 @@
<thead class="bg-gray-100"> <thead class="bg-gray-100">
<tr> <tr>
{#each columns as col} {#each columns as col}
{#if col.key === "guest_name"} {#if col.key === "item_name"}
<th <th
class="sticky left-0 px-4 py-3 text-left font-semibold text-gray-700 uppercase tracking-wider whitespace-nowrap" class="sticky left-0 px-4 py-3 text-left font-semibold text-gray-700 uppercase tracking-wider whitespace-nowrap"
style="background-color: #f0f8ff; z-index: 10;" style="background-color: #f0f8ff; z-index: 10;"
@@ -544,10 +549,10 @@
</thead> </thead>
<tbody class="bg-white divide-y divide-gray-200"> <tbody class="bg-white divide-y divide-gray-200">
{#each inventoryItems as item} {#each inventoryItems as item}
<tr> <tr class="hover:bg-gray-100 transition duration-150">
{#each columns as col} {#each columns as col}
<td class="px-4 py-3 whitespace-nowrap"> {#if +col.key >= 1 && +col.key <= 12}
{#if +col.key >= 1 && +col.key <= 12} <td class="px-4 py-3 whitespace-nowrap">
<input <input
type="number" type="number"
min="0" min="0"
@@ -579,21 +584,33 @@
}); });
}} }}
/> />
{:else if col.key === "created_at" || col.key === "updated_at"} </td>
<td class="px-4 py-2"> {:else if col.key === "item_name"}
{item[col.key] !== undefined <td
? new Date( class="px-4 py-2 sticky left-0 whitespace-nowrap bg-gray-100 z-10"
item[col.key] as >
| string <span
| number class="font-medium text-gray-800 hover:text-blue-600"
| Date, >
).toLocaleString() {item.item_name}
: "N/A"} </span>
</td> </td>
{:else if col.key === "actions"} {:else if col.key === "created_at" || col.key === "updated_at"}
<td class="px-4 py-2">
{item[col.key] !== undefined
? new Date(
item[col.key] as
| string
| number
| Date,
).toLocaleString()
: "N/A"}
</td>
{:else if col.key === "actions"}
<td class="px-4 py-2">
<div class="flex space-x-2"> <div class="flex space-x-2">
<button <button
class="text-blue-600 hover:underline" class="inline-flex items-center gap-1 rounded bg-blue-600 px-3 py-1.5 text-white text-xs font-medium hover:bg-blue-700"
on:click={() => { on:click={() => {
isEditing = true; isEditing = true;
currentEditingId = item.id; currentEditingId = item.id;
@@ -615,7 +632,7 @@
✏️ Edit ✏️ Edit
</button> </button>
<button <button
class="text-red-600 hover:underline" class="inline-flex items-center gap-1 rounded bg-red-600 px-3 py-1.5 text-white text-xs font-medium hover:bg-red-700"
on:click={async () => { on:click={async () => {
const { error } = await supabase const { error } = await supabase
.from("vb_inventory") .from("vb_inventory")
@@ -645,10 +662,12 @@
🗑️ Delete 🗑️ Delete
</button> </button>
</div> </div>
{:else} </td>
{:else}
<td class="px-4 py-2">
{item[col.key as keyof Inventory]} {item[col.key as keyof Inventory]}
{/if} </td>
</td> {/if}
{/each} {/each}
</tr> </tr>
{:else} {:else}
@@ -725,9 +744,6 @@
</div> </div>
</div> </div>
</div> </div>
<p class="text-xs text-gray-500 italic mb-2">
Tekan tombol Enter untuk menyimpan.
</p>
<!-- Modal --> <!-- Modal -->
{#if showModal} {#if showModal}