Merge branch 'production' of https://git.abbauf.com/Magang-2025/Kasir into production
This commit is contained in:
commit
21c96c54c5
@ -1,8 +1,8 @@
|
||||
APP_NAME=Laravel
|
||||
APP_NAME=Abbauf-Kasir
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_URL=http://localhost:8000
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
|
@ -37,7 +37,7 @@ class DatabaseSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
|
||||
$kategoriList = ['cincin', 'gelang rantai', 'gelang bulat', 'kalung', 'liontin', 'anting', 'giwang'];
|
||||
$kategoriList = ['Cincin', 'Gelang Rantai', 'Gelang Bulat', 'Kalung', 'Liontin', 'Anting', 'Giwang'];
|
||||
foreach ($kategoriList as $kategori) {
|
||||
Kategori::factory()->create([
|
||||
'nama' => $kategori
|
||||
@ -50,7 +50,8 @@ class DatabaseSeeder extends Seeder
|
||||
$fotoData = [];
|
||||
for ($i = 0; $i < $jumlah_foto; $i++) {
|
||||
$fotoData[] = [
|
||||
'url' => 'https://random-image-pepebigotes.vercel.app/api/random-image'
|
||||
// 'url' => 'https://random-image-pepebigotes.vercel.app/api/random-image'
|
||||
'url' => 'https://static.promediateknologi.id/crop/0x0:0x0/0x0/webp/photo/p2/255/2024/12/10/Screenshot_2024-12-10-11-50-18-88_1c337646f29875672b5a61192b9010f9-1-1282380831.jpg'
|
||||
];
|
||||
}
|
||||
$produk->foto()->createMany($fotoData);
|
||||
|
1538
package-lock.json
generated
1538
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,16 +4,17 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
"dev": "concurrently \"php artisan serve\" \"vite\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"axios": "^1.11.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"concurrently": "^9.2.1",
|
||||
"laravel-vite-plugin": "^2.0.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^7.0.4"
|
||||
"vite": "^7.0.4",
|
||||
"vite-plugin-vue-devtools": "^8.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.5.19",
|
||||
|
@ -7,11 +7,11 @@
|
||||
class="bg-white rounded-lg shadow-lg p-6 w-[350px] text-center relative"
|
||||
>
|
||||
<!-- Judul -->
|
||||
<p class="text-lg font-semibold mb-2">Yakin hapus produk ini?</p>
|
||||
<p class="text-lg font-semibold mb-2">{{ props.title }}?</p>
|
||||
|
||||
<!-- Deskripsi tambahan -->
|
||||
<p class="text-sm text-gray-600 mb-4">
|
||||
Produk yang sudah dihapus tidak akan bisa dikembalikan.
|
||||
{{ props.message }}
|
||||
</p>
|
||||
|
||||
<!-- Tombol aksi -->
|
||||
@ -34,7 +34,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
isOpen: Boolean,
|
||||
title:String,
|
||||
message:String
|
||||
});
|
||||
</script>
|
||||
|
73
resources/js/components/CreateKategori.vue
Normal file
73
resources/js/components/CreateKategori.vue
Normal file
@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div v-if="isOpen" class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
|
||||
<div class="bg-white rounded-lg shadow-lg w-96 p-6 relative">
|
||||
<!-- Header -->
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h2 class="text-lg font-bold text-gray-800">
|
||||
{{ product ? 'Edit Kategori' : 'Tambah Kategori Baru' }}
|
||||
</h2>
|
||||
<button @click="emit('close')" class="text-gray-400 hover:text-gray-600">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- Form -->
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-medium text-gray-700">Nama Kategori</label>
|
||||
<input
|
||||
v-model="form.nama"
|
||||
type="text"
|
||||
placeholder="Masukkan nama kategori"
|
||||
class="mt-1 block w-full border border-gray-300 rounded-md px-3 py-2 focus:ring focus:ring-[#c6a77d]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Buttons -->
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
@click="emit('close')"
|
||||
class="px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300"
|
||||
>
|
||||
Batal
|
||||
</button>
|
||||
<button
|
||||
@click="saveKategori"
|
||||
:disabled="!form.nama"
|
||||
class="px-4 py-2 bg-[#c6a77d] text-white rounded hover:bg-[#b09065] disabled:opacity-50"
|
||||
>
|
||||
Simpan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
const props = defineProps({
|
||||
isOpen: Boolean,
|
||||
product: Object
|
||||
})
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const form = ref({ nama: '' })
|
||||
|
||||
// Sync kalau ubah kategori
|
||||
watch(() => props.product, (val) => {
|
||||
form.value.nama = val ? val.nama : ''
|
||||
}, { immediate: true })
|
||||
|
||||
const saveKategori = async () => {
|
||||
try {
|
||||
if (props.product) {
|
||||
await axios.put(`/api/kategori/${props.product.id}`, form.value)
|
||||
} else {
|
||||
await axios.post('/api/kategori', form.value)
|
||||
}
|
||||
emit('close') // tutup modal
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
alert('Gagal menyimpan kategori')
|
||||
}
|
||||
}
|
||||
</script>
|
66
resources/js/components/EditKategori.vue
Normal file
66
resources/js/components/EditKategori.vue
Normal file
@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-40 z-50">
|
||||
<div class="bg-white rounded-lg shadow-lg w-[400px] p-6 relative">
|
||||
|
||||
<!-- Tombol close -->
|
||||
<button @click="$emit('close')" class="absolute top-3 right-3 text-gray-600 hover:text-black">
|
||||
✕
|
||||
</button>
|
||||
|
||||
<!-- Judul -->
|
||||
<h2 class="text-xl font-bold text-center text-D mb-4">Edit Kategori</h2>
|
||||
|
||||
<!-- Input Nama Kategori -->
|
||||
<div class="mb-4">
|
||||
<label for="editKategori" class="block text-sm font-medium text-D mb-1">Nama Kategori</label>
|
||||
<input
|
||||
v-model="editNamaKategori"
|
||||
type="text"
|
||||
id="editKategori"
|
||||
placeholder="Masukkan nama kategori"
|
||||
class="w-full p-2 border rounded-md bg-Focus outline-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Aksi -->
|
||||
<div class="flex justify-end gap-3">
|
||||
<button @click="$emit('close')" class="px-4 py-2 bg-gray-300 rounded-md hover:bg-gray-400">
|
||||
Batal
|
||||
</button>
|
||||
<button @click="updateKategori" class="px-4 py-2 bg-B text-white rounded-md hover:bg-A">
|
||||
Update
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
kategori: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const editNamaKategori = ref("");
|
||||
|
||||
watch(
|
||||
() => props.kategori,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
editNamaKategori.value = newVal.nama;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const updateKategori = () => {
|
||||
if (editNamaKategori.value.trim() === "") {
|
||||
alert("Nama kategori tidak boleh kosong!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit hasil update ke parent
|
||||
emit("update", { ...props.kategori, nama: editNamaKategori.value });
|
||||
};
|
||||
</script>
|
@ -1,95 +0,0 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import logo from "../../images/logo.png";
|
||||
|
||||
|
||||
const isOpen = ref(false);
|
||||
|
||||
const items = [
|
||||
{ label: "Kasir", route: "/kasir" },
|
||||
{ label: "Laporan", route: "/laporan" },
|
||||
{ label: "Akun", route: "/akun" },
|
||||
];
|
||||
|
||||
const subItems = [
|
||||
{ label: "Brankas", route: "/brankas" },
|
||||
{ label: "Nampan", route: "/nampan" },
|
||||
{ label: "Produk", route: "/produk" },
|
||||
{ label: "Sales", route: "/sales" },
|
||||
];
|
||||
|
||||
const toggleDropdown = () => {
|
||||
isOpen.value = !isOpen.value;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-25 shadow-lg shadow-D rounded-b-md">
|
||||
<div class="bg-D h-5 rounded-b-md shadow-lg">
|
||||
<div class="h-15"></div>
|
||||
<div class="relative">
|
||||
<div class="w-full px-50 flex justify-between items-center h-5 relative">
|
||||
<div class="absolute left-[50%]">
|
||||
<img :src="logo" alt="Logo" class="h-12 w-auto" />
|
||||
</div>
|
||||
|
||||
<!-- 🔹 LEFT MENU -->
|
||||
<div class="flex items-center gap-10">
|
||||
<!-- Dropdown khusus "Manajemen Produk" -->
|
||||
<div class="relative">
|
||||
<button
|
||||
@click="toggleDropdown"
|
||||
class="text-center text-lg text-D hover:underline cursor-pointer"
|
||||
>
|
||||
Manajemen Produk
|
||||
</button>
|
||||
|
||||
<!-- isi dropdown -->
|
||||
<div
|
||||
v-if="isOpen"
|
||||
class="absolute left-0 mt-2 w-48 bg-white border rounded-md shadow-lg z-50"
|
||||
>
|
||||
<ul>
|
||||
<li
|
||||
v-for="(sub, index) in subItems"
|
||||
:key="index"
|
||||
class="px-4 py-2 hover:bg-A cursor-pointer"
|
||||
>
|
||||
<router-link :to="sub.route" class="block w-full h-full">
|
||||
{{ sub.label }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Menu Kasir -->
|
||||
<router-link
|
||||
:to="items[0].route"
|
||||
class="text-center text-lg text-D hover:underline cursor-pointer"
|
||||
>
|
||||
{{ items[0].label }}
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<!-- 🔹 RIGHT MENU -->
|
||||
<div class="flex items-center gap-8">
|
||||
<router-link
|
||||
:to="items[1].route"
|
||||
class="text-center text-lg text-D hover:underline cursor-pointer"
|
||||
>
|
||||
{{ items[1].label }}
|
||||
</router-link>
|
||||
<router-link
|
||||
:to="items[2].route"
|
||||
class="text-center text-lg text-D hover:underline cursor-pointer"
|
||||
>
|
||||
{{ items[2].label }}
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
70
resources/js/components/NavDesktop.vue
Normal file
70
resources/js/components/NavDesktop.vue
Normal file
@ -0,0 +1,70 @@
|
||||
<script setup>
|
||||
import { inject } from "vue";
|
||||
|
||||
const {
|
||||
logo,
|
||||
items,
|
||||
openDropdownIndex,
|
||||
toggleDropdown,
|
||||
logout
|
||||
} = inject('navigationData');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Desktop Navbar -->
|
||||
<div class="hidden md:block shadow-lg shadow-D rounded-b-md">
|
||||
<div class="bg-D h-5 rounded-b-md shadow-lg"></div>
|
||||
<div class="relative rounded-b-md shadow-lg">
|
||||
<!-- Logo Row -->
|
||||
<div class="flex justify-center items-center">
|
||||
<img :src="logo" alt="Logo" class="h-12 w-auto" />
|
||||
</div>
|
||||
|
||||
<!-- Menu Row -->
|
||||
<div class="px-8 pb-4">
|
||||
<div class="flex justify-around items-center gap-4">
|
||||
<template v-for="(item, index) in items" :key="index">
|
||||
|
||||
<div v-if="item.subItems" class="relative flex-1">
|
||||
<button @click="toggleDropdown(index)"
|
||||
class="w-full text-center text-lg text-D hover:underline cursor-pointer flex items-center justify-center gap-2 transition-colors duration-200 py-2">
|
||||
{{ item.label }}
|
||||
<svg :class="{ 'rotate-180': openDropdownIndex === index }"
|
||||
class="w-4 h-4 transition-transform duration-200" fill="none" stroke="currentColor"
|
||||
viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div v-if="openDropdownIndex === index"
|
||||
class="absolute mt-2 w-full mx-4 bg-white border rounded-md shadow-lg z-50">
|
||||
<ul>
|
||||
<li v-for="(sub, subIndex) in item.subItems" :key="subIndex"
|
||||
class="hover:bg-A transition-colors duration-200">
|
||||
<router-link :to="sub.route"
|
||||
@click="openDropdownIndex = null"
|
||||
class="block w-full h-full px-4 py-2 text-D">
|
||||
{{ sub.label }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<router-link v-else :to="item.route"
|
||||
class="flex-1 text-center text-lg text-D hover:underline cursor-pointer transition-colors duration-200 py-2">
|
||||
{{ item.label }}
|
||||
</router-link>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="absolute top-4 right-8">
|
||||
<button @click="logout"
|
||||
class="text-center font-bold text-lg text-red-400 hover:underline hover:text-red-600 cursor-pointer transition-colors duration-200">
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
94
resources/js/components/NavMobile.vue
Normal file
94
resources/js/components/NavMobile.vue
Normal file
@ -0,0 +1,94 @@
|
||||
<script setup>
|
||||
import { inject } from "vue";
|
||||
|
||||
// Mengambil data dan fungsi yang disediakan dari komponen induk
|
||||
const {
|
||||
logo,
|
||||
items,
|
||||
isMobileMenuOpen,
|
||||
openDropdownIndex,
|
||||
toggleDropdown,
|
||||
toggleMobileMenu,
|
||||
closeMobileMenu,
|
||||
logout
|
||||
} = inject('navigationData');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="md:hidden">
|
||||
<div class="bg-D h-5 shadow-lg"></div>
|
||||
<div class="px-4 fixed flex items-center mt-2">
|
||||
<button @click="toggleMobileMenu"
|
||||
class="text-D bg-C hover:bg-B transition-colors duration-200 p-0.5 rounded-sm z-50">
|
||||
<svg :class="{ 'hidden': isMobileMenuOpen, 'block': !isMobileMenuOpen }" class="w-7 h-7" fill="none"
|
||||
stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
|
||||
</svg>
|
||||
<svg :class="{ 'block': isMobileMenuOpen, 'hidden': !isMobileMenuOpen }" class="w-6 h-6" fill="none"
|
||||
stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div :class="{ 'translate-x-0': isMobileMenuOpen, '-translate-x-full': !isMobileMenuOpen }"
|
||||
class="fixed inset-y-0 left-0 w-64 bg-A transform transition-transform duration-300 ease-in-out z-50 shadow-xl">
|
||||
<div class="px-4 py-3 flex justify-between items-center border-b border-B">
|
||||
<img :src="logo" alt="Logo" class="h-8 w-auto" />
|
||||
<button @click="closeMobileMenu" class="text-D hover:text-red-500 transition-colors duration-200">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<nav class="py-4">
|
||||
<template v-for="(item, index) in items" :key="index">
|
||||
<div v-if="item.subItems" class="px-4 py-2">
|
||||
<button @click="toggleDropdown(index)"
|
||||
class="w-full flex justify-between items-center text-left text-lg text-D hover:bg-B rounded-md px-3 py-2 transition-colors duration-200">
|
||||
<span>{{ item.label }}</span>
|
||||
<svg :class="{ 'rotate-180': openDropdownIndex === index }" class="w-4 h-4 transition-transform duration-200"
|
||||
fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<transition
|
||||
enter-active-class="transition-all ease-in-out duration-300"
|
||||
enter-from-class="transform opacity-0 max-h-0"
|
||||
enter-to-class="transform opacity-100 max-h-96"
|
||||
leave-active-class="transition-all ease-in-out duration-200"
|
||||
leave-from-class="transform opacity-100 max-h-96"
|
||||
leave-to-class="transform opacity-0 max-h-0"
|
||||
>
|
||||
<div v-if="openDropdownIndex === index" class="mt-2 ml-4 space-y-1 overflow-hidden">
|
||||
<router-link v-for="(sub, subIndex) in item.subItems" :key="subIndex" :to="sub.route"
|
||||
@click="closeMobileMenu"
|
||||
class="block px-3 py-2 text-D hover:bg-B rounded-md transition-colors duration-200">
|
||||
{{ sub.label }}
|
||||
</router-link>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
|
||||
<div v-else class="px-4">
|
||||
<router-link :to="item.route" @click="closeMobileMenu"
|
||||
class="block px-3 py-2 text-lg text-D hover:bg-B rounded-md transition-colors duration-200">
|
||||
{{ item.label }}
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
</nav>
|
||||
|
||||
<div class="absolute bottom-0 w-full px-4 py-3 bg-A border-t border-B">
|
||||
<button @click="logout"
|
||||
class="block w-full text-left px-3 py-2 text-lg font-bold text-red-400 hover:text-white hover:bg-red-400 rounded-md transition-colors duration-200">
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isMobileMenuOpen" @click="closeMobileMenu" class="fixed inset-0 bg-black/75 z-40"></div>
|
||||
</div>
|
||||
</template>
|
78
resources/js/components/NavigationComponent.vue
Normal file
78
resources/js/components/NavigationComponent.vue
Normal file
@ -0,0 +1,78 @@
|
||||
<script setup>
|
||||
import { ref, provide } from "vue";
|
||||
import NavDesktop from "./NavDesktop.vue";
|
||||
import NavMobile from "./NavMobile.vue";
|
||||
import logo from "../../images/logo.png";
|
||||
|
||||
const isOpen = ref(false);
|
||||
const isMobileMenuOpen = ref(false);
|
||||
const openDropdownIndex = ref(null);
|
||||
|
||||
const items = [
|
||||
{ label: "Manajemen Produk", subItems: [
|
||||
{ label: "Brankas", route: "/brankas" },
|
||||
{ label: "Nampan", route: "/nampan" },
|
||||
{ label: "Produk", route: "/produk" },
|
||||
{ label: "Kategori", route: "/kategori" },
|
||||
{ label: "Sales", route: "/sales" },
|
||||
] },
|
||||
{ label: "Kasir", route: "/kasir" },
|
||||
{ label: "Laporan", route: "/laporan" },
|
||||
{ label: "Akun", route: "/akun" },
|
||||
];
|
||||
|
||||
const toggleDropdown = (index = null) => {
|
||||
if (index !== null) {
|
||||
openDropdownIndex.value = openDropdownIndex.value === index ? null : index;
|
||||
} else {
|
||||
isOpen.value = !isOpen.value;
|
||||
}
|
||||
};
|
||||
|
||||
const toggleMobileMenu = () => {
|
||||
isMobileMenuOpen.value = !isMobileMenuOpen.value;
|
||||
isOpen.value = false;
|
||||
openDropdownIndex.value = null;
|
||||
};
|
||||
|
||||
const closeMobileMenu = () => {
|
||||
isMobileMenuOpen.value = false;
|
||||
isOpen.value = false;
|
||||
openDropdownIndex.value = null;
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
console.log("Logout clicked");
|
||||
closeMobileMenu();
|
||||
};
|
||||
|
||||
// Provide shared data to child components
|
||||
provide('navigationData', {
|
||||
logo,
|
||||
items,
|
||||
isOpen,
|
||||
isMobileMenuOpen,
|
||||
openDropdownIndex,
|
||||
toggleDropdown,
|
||||
toggleMobileMenu,
|
||||
closeMobileMenu,
|
||||
logout
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative">
|
||||
<!-- Desktop Navigation -->
|
||||
<NavDesktop />
|
||||
|
||||
<!-- Mobile Navigation -->
|
||||
<NavMobile />
|
||||
|
||||
<!-- Click Outside Handler for Desktop Dropdown -->
|
||||
<div
|
||||
v-if="openDropdownIndex !== null && !isMobileMenuOpen"
|
||||
@click="openDropdownIndex = null"
|
||||
class="fixed inset-0 z-10"
|
||||
></div>
|
||||
</div>
|
||||
</template>
|
@ -1,15 +1,14 @@
|
||||
<template>
|
||||
<div class="min-h-screen max-w-screen">
|
||||
<Header />
|
||||
<div class="mx-2 md:mx-4 lg:mx-6 xl:mx-7 my-6 " >
|
||||
<slot />
|
||||
</div>
|
||||
<Footer class="w-full mt-10" />
|
||||
|
||||
<div class="min-h-screen max-w-screen">
|
||||
<NavigationComponent />
|
||||
<div class="mx-2 md:mx-4 lg:mx-6 xl:mx-7 my-6">
|
||||
<slot />
|
||||
</div>
|
||||
<Footer class="bottom-0 w-full" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Header from '../components/Header.vue'
|
||||
import Footer from '../components/Footer.vue'
|
||||
import NavigationComponent from '../components/NavigationComponent.vue';
|
||||
</script>
|
||||
|
168
resources/js/pages/Kategori.vue
Normal file
168
resources/js/pages/Kategori.vue
Normal file
@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<mainLayout>
|
||||
<CreateKategori :isOpen="creatingKategori" :product="detail" @close="closeKategori" />
|
||||
|
||||
<ConfirmDeleteModal :isOpen="confirmDeleteOpen" :item="kategoriToDelete" title="Hapus Kategori"
|
||||
message="Apakah Anda yakin ingin menghapus kategori ini?" @confirm="confirmDelete" @cancel="closeDeleteModal" />
|
||||
<div class="p-6">
|
||||
<!-- Header Section -->
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h1 class="text-2xl font-bold text-gray-800">Kategori</h1>
|
||||
<button @click="tambahKategori"
|
||||
class="px-4 py-2 bg-[#c6a77d] text-white rounded-md hover:bg-[#b09065] transition duration-200 flex items-center gap-2">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
</svg>
|
||||
Tambah Kategori
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Table Section -->
|
||||
<div class="bg-white rounded-lg shadow-md border border-gray-200 overflow-hidden">
|
||||
<table class="w-full">
|
||||
<thead>
|
||||
<tr class="bg-[#c6a77d] text-white">
|
||||
<th class="px-6 py-4 text-left font-semibold border-r border-[#b09065]">
|
||||
No
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left font-semibold border-r border-[#b09065]">
|
||||
Nama Kategori
|
||||
</th>
|
||||
<th class="px-6 py-4 text-center font-semibold">
|
||||
Aksi
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item, index) in kategori" :key="item.id"
|
||||
class="border-b border-gray-200 hover:bg-gray-50 transition duration-150"
|
||||
:class="{ 'bg-gray-50': index % 2 === 1 }">
|
||||
<td class="px-6 py-4 border-r border-gray-200 font-medium text-gray-900">
|
||||
{{ index + 1 }}
|
||||
</td>
|
||||
<td class="px-6 py-4 border-r border-gray-200 text-gray-800">
|
||||
{{ item.nama }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-center">
|
||||
<div class="flex justify-center gap-2">
|
||||
<button @click="ubahKategori(item)"
|
||||
class="px-3 py-1 bg-yellow-500 text-white text-sm rounded hover:bg-yellow-600 transition duration-200">
|
||||
Ubah
|
||||
</button>
|
||||
<button @click="hapusKategori(item)"
|
||||
class="px-3 py-1 bg-red-500 text-white text-sm rounded hover:bg-red-600 transition duration-200">
|
||||
Hapus
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Empty State -->
|
||||
<tr v-if="kategori.length === 0 && !loading">
|
||||
<td colspan="3" class="px-6 py-8 text-center text-gray-500">
|
||||
<div class="flex flex-col items-center">
|
||||
<svg class="w-12 h-12 text-gray-400 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2 2v-5m16 0h-2M4 13h2" />
|
||||
</svg>
|
||||
<p>Tidak ada data kategori</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div v-if="loading" class="flex justify-center items-center py-8">
|
||||
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-[#c6a77d]"></div>
|
||||
<span class="ml-2 text-gray-600">Memuat data...</span>
|
||||
</div>
|
||||
</div>
|
||||
</mainLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import axios from "axios";
|
||||
import mainLayout from "../layouts/mainLayout.vue";
|
||||
import CreateKategori from "../components/CreateKategori.vue";
|
||||
import ConfirmDeleteModal from "../components/ConfirmDeleteModal.vue";
|
||||
|
||||
// Reactive data
|
||||
const kategori = ref([]);
|
||||
const loading = ref(false);
|
||||
const creatingKategori = ref(false);
|
||||
const detail = ref(null);
|
||||
const confirmDeleteOpen = ref(false);
|
||||
const kategoriToDelete = ref(null);
|
||||
|
||||
// Fetch data kategori dari API
|
||||
const fetchKategoris = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const response = await axios.get("/api/kategori");
|
||||
kategori.value = response.data;
|
||||
console.log("Data kategori:", response.data);
|
||||
} catch (error) {
|
||||
console.error("Error fetching kategori:", error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Tambah kategori - open modal
|
||||
const tambahKategori = () => {
|
||||
detail.value = null; // Reset detail untuk mode create
|
||||
creatingKategori.value = true;
|
||||
};
|
||||
|
||||
// Close modal
|
||||
const closeKategori = () => {
|
||||
creatingKategori.value = false;
|
||||
fetchKategoris(); // Refresh data setelah modal ditutup
|
||||
};
|
||||
|
||||
// Ubah kategori
|
||||
const ubahKategori = (item) => {
|
||||
detail.value = item; // Set detail untuk mode edit
|
||||
creatingKategori.value = true;
|
||||
};
|
||||
|
||||
// Hapus kategori
|
||||
const hapusKategori = (item) => {
|
||||
kategoriToDelete.value = item;
|
||||
confirmDeleteOpen.value = true;
|
||||
};
|
||||
|
||||
// 🔵 Ditambahkan: aksi konfirmasi hapus
|
||||
const confirmDelete = async () => {
|
||||
try {
|
||||
await axios.delete(`/api/kategori/${kategoriToDelete.value.id}`);
|
||||
console.log("Kategori berhasil dihapus");
|
||||
fetchKategoris();
|
||||
} catch (error) {
|
||||
console.error("Error deleting kategori:", error);
|
||||
} finally {
|
||||
closeDeleteModal();
|
||||
}
|
||||
};
|
||||
|
||||
// 🔵 Ditambahkan: tutup modal hapus
|
||||
const closeDeleteModal = () => {
|
||||
confirmDeleteOpen.value = false;
|
||||
kategoriToDelete.value = null;
|
||||
};
|
||||
|
||||
// Lifecycle
|
||||
onMounted(() => {
|
||||
fetchKategoris();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* Custom styles jika diperlukan */
|
||||
.table-hover-row:hover {
|
||||
background-color: #f9fafb;
|
||||
}
|
||||
</style>
|
@ -12,6 +12,8 @@
|
||||
:isOpen="deleting"
|
||||
@cancel="deleting = false"
|
||||
@confirm="deleteProduk"
|
||||
title="Hapus Produk"
|
||||
message="Apakah Anda yakin ingin menghapus produk ini?"
|
||||
/>
|
||||
|
||||
<div class="p-6">
|
||||
@ -51,7 +53,7 @@
|
||||
<!-- Overlay Detail Produk -->
|
||||
<div
|
||||
v-if="showOverlay"
|
||||
class="fixed inset-0 bg-black/30 flex justify-center items-center z-50"
|
||||
class="fixed inset-0 bg-black/30 flex justify-center items-center"
|
||||
@click.self="closeOverlay"
|
||||
>
|
||||
<div
|
||||
|
@ -5,6 +5,7 @@ import Brankas from '../pages/Brankas.vue'
|
||||
import Tray from '../pages/Tray.vue'
|
||||
import Kasir from '../pages/Kasir.vue'
|
||||
import InputProduk from '../pages/InputProduk.vue'
|
||||
import Kategori from '../pages/Kategori.vue'
|
||||
|
||||
|
||||
const routes = [
|
||||
@ -38,6 +39,11 @@ const routes = [
|
||||
name: 'Kasir',
|
||||
component: Kasir
|
||||
},
|
||||
{
|
||||
path: '/kategori',
|
||||
name: 'Kategori',
|
||||
component: Kategori
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable-no" />
|
||||
<title>Abbauf App</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@ -10,7 +11,8 @@ export default defineConfig({
|
||||
refresh: true,
|
||||
}),
|
||||
tailwindcss(),
|
||||
vue()
|
||||
vue(),
|
||||
vueDevTools(),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
|
Loading…
Reference in New Issue
Block a user