Compare commits

..

No commits in common. "420cf47f2095dd759a4d88d2370222cf97ff3ccd" and "c28be3706e6b1f07da23fcf395668bf218d88ae9" have entirely different histories.

4 changed files with 218 additions and 290 deletions

View File

@ -1,33 +0,0 @@
<?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,151 +1,143 @@
<template>
<ConfirmDeleteModal
v-if="showDeleteModal"
:isOpen="showDeleteModal"
title="Konfirmasi"
message="Yakin ingin menghapus item ini?"
@confirm="hapusPesanan"
@cancel="closeDeleteModal"
/>
<ConfirmDeleteModal
: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>
<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"
>
<input
type="text"
v-model="kodeItem"
@keyup.enter="inputItem"
placeholder="Scan atau masukkan kode item"
class="bg-A focus:outline-none focus:border-C focus:ring focus:ring-D focus:ring-opacity-50 p-2 w-full rounded-l-md"
/>
<button
v-if="!loadingItem"
@click="inputItem"
class="px-3 bg-D hover:bg-D/80 text-A rounded-r-md"
>
<i class="fas fa-arrow-right"></i>
</button>
<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"
>
<i class="fas fa-spinner"></i>
</div>
<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
>
<div
class="flex flex-row justify-between mt-1 w-full rounded-md bg-A shadow-sm sm:text-sm border-B"
>
<input
type="text"
v-model="kodeItem"
@keyup.enter="inputItem"
placeholder="Scan atau masukkan kode item"
class="bg-A focus:outline-none focus:border-C focus:ring focus:ring-D focus:ring-opacity-50 p-2 w-full rounded-l-md"
/>
<button
v-if="!loadingItem"
@click="inputItem"
class="px-3 bg-D hover:bg-D/80 text-A rounded-r-md"
>
<i class="fas fa-arrow-right"></i>
</button>
<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"
>
<i class="fas fa-spinner"></i>
</div>
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-D"
>Harga Jual</label
>
<InputField
v-model="hargaJual"
type="number"
placeholder="Masukkan Harga Jual"
/>
</div>
<div class="flex justify-between gap-4">
<button
@click="tambahItem"
class="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"
>
Lanjut
</button>
</div>
</div>
<div class="flex pt-10 justify-center">
<div class="text-start">
<span class="block text-gray-600 font-medium">Total:</span>
<span class="text-3xl font-bold text-D">
Rp{{ total.toLocaleString() }},-
</span>
</div>
</div>
</div>
</div>
<!-- Input Harga Jual -->
<div>
<label class="block text-sm font-medium text-D">Harga Jual</label>
<InputField
v-model="hargaJual"
type="number"
placeholder="Masukkan Harga Jual"
/>
<div class="mb-4">
<p
v-if="error"
:class="{ 'animate-shake': error }"
class="text-sm text-red-600 mt-1"
>
{{ error }}
</p>
<p v-if="info" class="text-sm text-C mt-1">{{ info }}</p>
</div>
<!-- Tombol Aksi -->
<div class="flex flex-col sm:flex-row justify-between gap-2">
<button
@click="tambahItem"
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="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>
<!-- 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-2xl sm:text-3xl font-bold text-D">
Rp{{ total.toLocaleString() }},-
</span>
</div>
</div>
<table
class="w-full border border-B text-sm rounded-lg overflow-hidden"
>
<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">Posisi</th>
<th class="border border-B p-2">Harga</th>
<th class="border border-B p-2"></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">
Belum ada item dipesan
</td>
</tr>
<tr
v-else
v-for="(item, index) in pesanan"
:key="index"
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">
{{ item.produk.nama }}
</td>
<td class="border border-B p-2">
{{ item.posisi ? item.posisi : "Brankas" }}
</td>
<td class="border border-B p-2">
Rp{{ item.harga_deal.toLocaleString() }}
</td>
<td class="border border-B p-2 text-center">
<button
@click="openDeleteModal(index)"
class="text-red-500 hover:text-red-700"
>
<i class="fas fa-trash"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Error & Info -->
<div class="mb-4">
<p
v-if="error"
:class="{ 'animate-shake': error }"
class="text-sm text-red-600 mt-1"
>
{{ error }}
</p>
<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 rounded-lg overflow-hidden text-xs sm:text-sm"
>
<thead class="bg-A text-D">
<tr>
<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 w-10"></th>
</tr>
</thead>
<tbody>
<tr v-if="pesanan.length == 0" class="text-center text-D/70">
<td colspan="5" class="h-16 border border-B text-xs sm:text-sm">
Belum ada item dipesan
</td>
</tr>
<tr
v-else
v-for="(item, index) in pesanan"
:key="index"
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 truncate max-w-[120px] sm:max-w-none">
{{ item.produk.nama }}
</td>
<td class="border border-B p-2 truncate max-w-[80px]">
{{ item.posisi ? item.posisi : "Brankas" }}
</td>
<td class="border border-B p-2 whitespace-nowrap">
Rp{{ item.harga_deal.toLocaleString() }}
</td>
<td class="border border-B p-2 text-center">
<button
@click="openDeleteModal(index)"
class="text-red-500 hover:text-red-700"
>
<i class="fas fa-trash"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script setup>
import { ref, computed } from "vue";
import InputField from "./InputField.vue";

View File

@ -1,31 +1,26 @@
<template>
<div class="overflow-x-auto">
<h3 class="text-lg font-semibold mb-4 text-gray-800">Transaksi</h3>
<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 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>
<tr v-for="trx in props.transaksi" :key="trx.id" class="hover:bg-A">
<td class="border border-B p-2">{{ trx.tanggal }}</td>
<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>
</td>
</tr>
</tbody>
</table>
</div>
<h3 class="text-lg font-semibold mb-4 text-gray-800">Transaksi</h3>
<table class="w-full 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>
</tr>
</thead>
<tbody>
<tr v-for="trx in props.transaksi" :key="trx.id" class="hover:bg-A">
<td class="border border-B p-2">{{ trx.tanggal }}</td>
<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>
</td>
</tr>
</tbody>
</table>
</template>
<script setup>

View File

@ -1,105 +1,79 @@
<template>
<mainLayout>
<div class="lg:p-2 pt-6">
<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-auto lg:h-full"
>
<div class="p-2 sm:p-3 md:p-4 h-auto lg:h-full">
<KasirForm />
</div>
</div>
</div>
<!-- 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 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 -->
<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>
</div>
<!-- Transaction List -->
<KasirTransaksiList
v-else
:transaksi="transaksi"
@detail="lihatDetail"
/>
</div>
</div>
</div>
<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]">
<!-- 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">
<KasirForm />
</div>
</div>
</div>
</mainLayout>
<!-- 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>
<!-- 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" />
</svg>
<p class="text-[var(--color-D)]/60 text-sm">Belum ada transaksi</p>
</div>
<!-- Transaction List -->
<KasirTransaksiList
v-else
:transaksi="transaksi"
@detail="lihatDetail"
/>
</div>
</div>
</div>
</div>
</div>
</mainLayout>
</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;
const res = await axios.get("/api/transaksi?limit=10", {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
transaksi.value = res.data;
} catch (err) {
console.error("Gagal fetch transaksi:", err);
} finally {
loading.value = false;
}
});
try {
loading.value = true
const res = await axios.get("/api/transaksi?limit=10", {
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
})
transaksi.value = res.data
} catch (err) {
console.error("Gagal fetch transaksi:", err)
} finally {
loading.value = false
}
})
const lihatDetail = (trx) => {
alert(`Detail transaksi: ${trx.kode}`);
};
alert(`Detail transaksi: ${trx.kode}`)
}
</script>