Compare commits

..

2 Commits

4 changed files with 291 additions and 219 deletions

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@ -1,19 +1,21 @@
<template>
<ConfirmDeleteModal
<ConfirmDeleteModal
v-if="showDeleteModal"
:isOpen="showDeleteModal"
title="Konfirmasi"
message="Yakin ingin menghapus item ini?"
@confirm="hapusPesanan"
@cancel="closeDeleteModal"
/>
/>
<div class="p-2 sm:p-4">
<!-- Grid Form & Total -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<!-- Input Form -->
<div class="order-2 md:order-1 flex flex-col gap-4">
<!-- Input Kode Item -->
<div>
<div class="grid grid-cols-2 h-full gap-4 mb-4">
<div class="flex flex-col gap-4">
<div>
<label class="block text-sm font-medium text-D"
>Kode Item *</label
>
<label class="block text-sm font-medium text-D">Kode Item *</label>
<div
class="flex flex-row justify-between mt-1 w-full rounded-md bg-A shadow-sm sm:text-sm border-B"
>
@ -31,10 +33,7 @@
>
<i class="fas fa-arrow-right"></i>
</button>
<div
v-else
class="flex items-center justify-center px-3"
>
<div v-else class="flex items-center justify-center px-3">
<div
class="rounded-full h-5 w-5 border-b-2 border-A flex items-center justify-center"
>
@ -43,10 +42,10 @@
</div>
</div>
</div>
<!-- Input Harga Jual -->
<div>
<label class="block text-sm font-medium text-D"
>Harga Jual</label
>
<label class="block text-sm font-medium text-D">Harga Jual</label>
<InputField
v-model="hargaJual"
type="number"
@ -54,31 +53,35 @@
/>
</div>
<div class="flex justify-between gap-4">
<!-- Tombol Aksi -->
<div class="flex flex-col sm:flex-row justify-between gap-2">
<button
@click="tambahItem"
class="px-4 py-2 rounded-md bg-C text-D font-medium hover:bg-C/80 transition"
class="w-full sm:w-auto px-4 py-2 rounded-md bg-C text-D font-medium hover:bg-C/80 transition"
>
Tambah Item
</button>
<button
@click="konfirmasiPenjualan"
class="px-6 py-2 rounded-md bg-D text-A font-semibold hover:bg-D/80 transition"
class="w-full sm:w-auto px-6 py-2 rounded-md bg-D text-A font-semibold hover:bg-D/80 transition"
>
Lanjut
</button>
</div>
</div>
<div class="flex pt-10 justify-center">
<div class="text-start">
<!-- Total -->
<div class="order-1 md:order-2 flex flex-col md:flex-row md:items-center md:justify-center gap-1">
<div class="text-left md:text-start">
<span class="block text-gray-600 font-medium">Total:</span>
<span class="text-3xl font-bold text-D">
<span class="text-2xl sm:text-3xl font-bold text-D">
Rp{{ total.toLocaleString() }},-
</span>
</div>
</div>
</div>
<!-- Error & Info -->
<div class="mb-4">
<p
v-if="error"
@ -90,21 +93,23 @@
<p v-if="info" class="text-sm text-C mt-1">{{ info }}</p>
</div>
<!-- Table Responsive -->
<div class="overflow-x-auto">
<table
class="w-full border border-B text-sm rounded-lg overflow-hidden"
class="w-full border border-B rounded-lg overflow-hidden text-xs sm:text-sm"
>
<thead class="bg-A text-D">
<tr>
<th class="border border-B p-2">No</th>
<th class="border border-B p-2">Nam Produk</th>
<th class="border border-B p-2 w-8">No</th>
<th class="border border-B p-2">Nama Produk</th>
<th class="border border-B p-2">Posisi</th>
<th class="border border-B p-2">Harga</th>
<th class="border border-B p-2"></th>
<th class="border border-B p-2 w-10"></th>
</tr>
</thead>
<tbody>
<tr v-if="pesanan.length == 0" class="text-center text-D/70">
<td colspan="5" class="h-20 border border-B">
<td colspan="5" class="h-16 border border-B text-xs sm:text-sm">
Belum ada item dipesan
</td>
</tr>
@ -115,13 +120,13 @@
class="hover:bg-gray-50 text-center"
>
<td class="border border-B p-2">{{ index + 1 }}</td>
<td class="border border-B p-2 text-left">
<td class="border border-B p-2 text-left truncate max-w-[120px] sm:max-w-none">
{{ item.produk.nama }}
</td>
<td class="border border-B p-2">
<td class="border border-B p-2 truncate max-w-[80px]">
{{ item.posisi ? item.posisi : "Brankas" }}
</td>
<td class="border border-B p-2">
<td class="border border-B p-2 whitespace-nowrap">
Rp{{ item.harga_deal.toLocaleString() }}
</td>
<td class="border border-B p-2 text-center">
@ -135,9 +140,12 @@
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script setup>
import { ref, computed } from "vue";
import InputField from "./InputField.vue";

View File

@ -1,12 +1,13 @@
<template>
<div class="overflow-x-auto">
<h3 class="text-lg font-semibold mb-4 text-gray-800">Transaksi</h3>
<table class="w-full border border-B rounded-lg text-sm">
<table class="w-full min-w-[500px] border border-B rounded-lg text-sm">
<thead class="bg-A text-D">
<tr>
<th class="border border-B p-2">Tanggal</th>
<th class="border border-B p-2">Kode Transaksi</th>
<th class="border border-B p-2">Pendapatan</th>
<th class="border border-B p-2">Detail Item</th>
<th class="border border-B p-2 text-left">Tanggal</th>
<th class="border border-B p-2 text-left">Kode Transaksi</th>
<th class="border border-B p-2 text-left">Pendapatan</th>
<th class="border border-B p-2 text-center">Detail Item</th>
</tr>
</thead>
<tbody>
@ -15,12 +16,16 @@
<td class="border border-B p-2">{{ trx.kode }}</td>
<td class="border border-B p-2">Rp{{ (trx.pendapatan || 0).toLocaleString() }}</td>
<td class="border border-B p-2 text-center">
<button @click="$emit('detail', trx)"
class="px-3 py-1 rounded-md bg-D text-A hover:bg-D/80 transition">Detail</button>
<button
@click="$emit('detail', trx)"
class="px-3 py-1 rounded-md bg-D text-A hover:bg-D/80 transition">
Detail
</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script setup>

View File

@ -1,11 +1,15 @@
<template>
<mainLayout>
<div class="lg:p-2 pt-6">
<div class="grid grid-cols-1 lg:grid-cols-5 gap-3 sm:gap-2 mx-auto min-h-[75vh]">
<div
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-3 sm:gap-2 mx-auto min-h-[75vh]"
>
<!-- Left Section - Form Kasir -->
<div class="lg:col-span-3">
<div class="bg-white rounded-xl shadow-lg border border-B overflow-hidden h-full">
<div class="p-2 md:p-4 h-full">
<div
class="bg-white rounded-xl shadow-lg border border-B overflow-hidden h-auto lg:h-full"
>
<div class="p-2 sm:p-3 md:p-4 h-auto lg:h-full">
<KasirForm />
</div>
</div>
@ -13,22 +17,44 @@
<!-- Right Section - Transaction List -->
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-lg border border-B overflow-hidden lg:h-fit sticky top-4">
<!-- Transaction List Content -->
<div class="p-4 sm:p-6 overflow-y-auto">
<!-- Loading State -->
<div v-if="loading" class="flex items-center justify-center py-8">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-C"></div>
<span class="ml-3 text-D/70">Memuat transaksi...</span>
<div
class="bg-white rounded-xl shadow-lg border border-B overflow-hidden lg:h-fit sticky top-4 max-h-[70vh] overflow-y-auto"
>
<div class="p-3 sm:p-4 md:p-6">
<!-- Loading -->
<div
v-if="loading"
class="flex items-center justify-center py-8"
>
<div
class="animate-spin rounded-full h-8 w-8 border-b-2 border-C"
></div>
<span class="ml-3 text-D/70"
>Memuat transaksi...</span
>
</div>
<!-- Empty State -->
<div v-else-if="!transaksi.length" class="text-center py-8">
<svg class="w-16 h-16 mx-auto text-B mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1"
d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
<!-- Empty -->
<div
v-else-if="!transaksi.length"
class="text-center py-8"
>
<svg
class="w-16 h-16 mx-auto text-B mb-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1"
d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
/>
</svg>
<p class="text-[var(--color-D)]/60 text-sm">Belum ada transaksi</p>
<p class="text-[var(--color-D)]/60 text-sm">
Belum ada transaksi
</p>
</div>
<!-- Transaction List -->
@ -46,34 +72,34 @@
</template>
<script setup>
import { ref, onMounted } from "vue"
import axios from "axios"
import { ref, onMounted } from "vue";
import axios from "axios";
import mainLayout from '../layouts/mainLayout.vue'
import KasirForm from '../components/KasirForm.vue'
import KasirTransaksiList from '../components/KasirTransaksiList.vue'
import mainLayout from "../layouts/mainLayout.vue";
import KasirForm from "../components/KasirForm.vue";
import KasirTransaksiList from "../components/KasirTransaksiList.vue";
const transaksi = ref([])
const loading = ref(true)
const transaksi = ref([]);
const loading = ref(true);
onMounted(async () => {
try {
loading.value = true
loading.value = true;
const res = await axios.get("/api/transaksi?limit=10", {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
})
});
transaksi.value = res.data
transaksi.value = res.data;
} catch (err) {
console.error("Gagal fetch transaksi:", err)
console.error("Gagal fetch transaksi:", err);
} finally {
loading.value = false
loading.value = false;
}
})
});
const lihatDetail = (trx) => {
alert(`Detail transaksi: ${trx.kode}`)
}
alert(`Detail transaksi: ${trx.kode}`);
};
</script>