diff --git a/package-lock.json b/package-lock.json index 0a4bd74..e63f396 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "tmsc-kasir-perhiasan", + "name": "Kasir", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/resources/js/components/ProductCard.vue b/resources/js/components/ProductCard.vue index 1253d5b..650784a 100644 --- a/resources/js/components/ProductCard.vue +++ b/resources/js/components/ProductCard.vue @@ -1,65 +1,31 @@ diff --git a/resources/js/pages/Produk.vue b/resources/js/pages/Produk.vue index 8fe0318..566dce7 100644 --- a/resources/js/pages/Produk.vue +++ b/resources/js/pages/Produk.vue @@ -4,14 +4,27 @@

PRODUK

- - + +
+ + + + + +
-
@@ -22,78 +35,90 @@ v-for="item in filteredProducts" :key="item.id" :product="item" - @showDetail="openOverlay" + @click="openOverlay(item.id)" /> -
-
- - + +
+
+ +
+ + [gambar] - -
- - [gambar] -
- - -

{{ detail.item_count }} pcs

- - -

- {{ detail.nama }} -

- - -
-

Harga Beli : Rp. {{ formatNumber(detail.harga_beli) }}

-

{{ detail.kadar }} K

-

Harga Jual : Rp. {{ formatNumber(detail.harga_jual) }}

-

{{ detail.berat }} gram

-

- Harga/gram : Rp. {{ formatNumber(detail.harga_per_gram) }} -

-
- - -
- - - -
+ +
+ {{ detail.item_count }} pcs
+ + +
+ {{ detail.nama }} +
+ + + + +
+ + +
+ +

Harga Jual : Rp. {{ formatNumber(detail.harga_jual) }}

+

{{ detail.kadar }} K

+

+ Berat : {{ detail.berat }} gram +

+

+ Harga/gram : Rp. {{ formatNumber(detail.harga_per_gram) }} +

+
+ + +
+ + + +
+
+
+ @@ -106,10 +131,12 @@ import searchbar from "../components/searchbar.vue"; const products = ref([]); const searchQuery = ref(""); +const selectedCategory = ref("semua"); // overlay state const showOverlay = ref(false); const detail = ref({}); +const currentFotoIndex = ref(0); // Fetch data awal onMounted(async () => { @@ -121,29 +148,60 @@ onMounted(async () => { } }); -// Filter +// Filter gabungan (kategori + search) const filteredProducts = computed(() => { - if (!searchQuery.value) return products.value; - return products.value.filter((p) => - p.nama.toLowerCase().includes(searchQuery.value.toLowerCase()) - ); + let hasil = products.value; + + // filter kategori + if (selectedCategory.value !== "semua") { + hasil = hasil.filter( + (p) => p.kategori.toLowerCase() === selectedCategory.value + ); + } + + // filter search + if (searchQuery.value) { + hasil = hasil.filter((p) => + p.nama.toLowerCase().includes(searchQuery.value.toLowerCase()) + ); + } + + return hasil; }); -// Fungsi buka overlay +// buka overlay async function openOverlay(id) { try { const res = await axios.get(`http://127.0.0.1:8000/api/produk/${id}`); detail.value = res.data; + currentFotoIndex.value = 0; // reset ke foto pertama showOverlay.value = true; } catch (error) { console.error("Gagal fetch detail produk:", error); } } -// Fungsi tutup overlay +// tutup overlay function closeOverlay() { showOverlay.value = false; detail.value = {}; + currentFotoIndex.value = 0; +} + +// foto navigation +function nextFoto() { + if (detail.value.foto && detail.value.foto.length > 0) { + currentFotoIndex.value = + (currentFotoIndex.value + 1) % detail.value.foto.length; + } +} + +function prevFoto() { + if (detail.value.foto && detail.value.foto.length > 0) { + currentFotoIndex.value = + (currentFotoIndex.value - 1 + detail.value.foto.length) % + detail.value.foto.length; + } } // Format angka