Merge branch 'production' of https://git.abbauf.com/Magang-2025/Kasir into production

This commit is contained in:
adityaalfarison 2025-09-03 11:49:20 +07:00
commit d58368389e
10 changed files with 198 additions and 160 deletions

View File

@ -26,7 +26,7 @@ class UserController extends Controller
User::create([ User::create([
'nama' => $request->nama, 'nama' => $request->nama,
'password' => bcrypt($request->password), 'password' => $request->password,
'role' => $request->role, 'role' => $request->role,
]); ]);
@ -43,7 +43,7 @@ class UserController extends Controller
$request->validate([ $request->validate([
'nama' => 'required|nama|unique:users,nama,' . $id, 'nama' => 'required|nama|unique:users,nama,' . $id,
'password' => 'required|min:6', 'password' => 'required|min:6',
'role' => 'required|in:owner, kasir', 'role' => 'required|in:owner,kasir',
]); ]);
$user->update([ $user->update([

View File

@ -1,44 +1,39 @@
<template> <template>
<div class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50"> <div
class="fixed inset-0 flex items-center justify-center bg-black/65 z-50"
>
<div class="bg-white rounded-lg p-6 w-96 shadow-lg"> <div class="bg-white rounded-lg p-6 w-96 shadow-lg">
<h2 class="text-lg font-bold mb-4">Tambah Akun</h2> <h2 class="text-lg font-bold mb-4">Tambah Akun</h2>
<form @submit.prevent="createAkun"> <form @submit.prevent="createAkun" class="space-y-3">
<!-- Nama --> <!-- Nama -->
<div class="mb-3"> <label for="nama">Nama</label>
<label class="block font-medium mb-1">Nama</label> <InputField
<input v-model="form.nama"
v-model.trim="form.nama" id="nama"
type="text" type="text"
class="border rounded w-full p-2 focus:ring focus:ring-blue-300" :required="true"
required
/> />
</div>
<!-- Password --> <div>
<div class="mb-3"> <label for="password">Password</label>
<label class="block font-medium mb-1">Password</label> <InputField
<input
v-model="form.password" v-model="form.password"
id="password"
type="password" type="password"
class="border rounded w-full p-2 focus:ring focus:ring-blue-300" :required="true"
required
/> />
</div> </div>
<!-- Peran --> <label for="peran">Peran</label>
<div class="mb-3"> <InputSelect
<label class="block font-medium mb-1">Peran</label>
<select
v-model="form.role" v-model="form.role"
class="border rounded w-full p-2 focus:ring focus:ring-blue-300" :options="[
required { value: 'owner', label: 'Owner' },
> { value: 'kasir', label: 'Kasir' },
<option disabled value="">-- Pilih Peran --</option> ]"
<option value="owner">Owner</option> placeholder="-- Pilih Peran --"
<option value="kasir">Kasir</option> />
</select>
</div>
<!-- Tombol --> <!-- Tombol -->
<div class="flex justify-end gap-2 mt-4"> <div class="flex justify-end gap-2 mt-4">
@ -64,20 +59,19 @@
</p> </p>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import axios from "axios"; import axios from "axios";
import InputField from "@/components/InputField.vue";
import InputSelect from "@/components/InputSelect.vue";
export default { export default {
name: "CreateAkun", name: "CreateAkun",
components: { InputField, InputSelect },
data() { data() {
return { return {
form: { form: { nama: "", password: "", role: "" },
nama: "",
password: "",
role: "",
},
errorMessage: "", errorMessage: "",
}; };
}, },
@ -85,11 +79,7 @@
async createAkun() { async createAkun() {
try { try {
await axios.post("api/user", this.form); await axios.post("api/user", this.form);
// reset form
this.form = { nama: "", password: "", role: "" }; this.form = { nama: "", password: "", role: "" };
// tutup modal dan refresh data
this.$emit("refresh"); this.$emit("refresh");
this.$emit("close"); this.$emit("close");
} catch (err) { } catch (err) {
@ -99,5 +89,5 @@
} }
}, },
}, },
}; };
</script> </script>

View File

@ -11,18 +11,17 @@
</div> </div>
<!-- Form --> <!-- Form -->
<div class="mb-4"> <div>
<label class="block text-sm font-medium text-gray-700">Nama Kategori</label> <label class="block text-sm font-medium text-gray-700">Nama Kategori</label>
<input <InputField
v-model="form.nama" v-model="form.nama"
type="text" type="text"
placeholder="Masukkan nama kategori" placeholder="Masukkan nama kategori"
class="mt-1 block w-full border border-gray-300 rounded-md px-3 py-2 focus:ring focus:ring-C"
/> />
</div> </div>
<!-- Buttons --> <!-- Buttons -->
<div class="flex justify-end gap-2"> <div class="flex justify-end gap-2 mt-4">
<button <button
@click="emit('close')" @click="emit('close')"
class="px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300" class="px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300"
@ -44,6 +43,7 @@
<script setup> <script setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import axios from 'axios' import axios from 'axios'
import InputField from './InputField.vue'
const props = defineProps({ const props = defineProps({
isOpen: Boolean, isOpen: Boolean,

View File

@ -7,24 +7,41 @@
<h2 class="text-xl font-bold mb-4">Tambah Sales</h2> <h2 class="text-xl font-bold mb-4">Tambah Sales</h2>
<form @submit.prevent="handleSubmit" class="space-y-4"> <form @submit.prevent="handleSubmit" class="space-y-4">
<!-- Nama -->
<div> <div>
<label class="block text-sm font-medium text-gray-700">Nama Sales</label> <label class="block text-sm font-medium text-gray-700">Nama Sales</label>
<input v-model="form.nama" type="text" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required /> <InputField v-model="form.nama" type="text" placeholder="Masukkan nama sales" required />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700">No HP</label> <label class="block text-sm font-medium text-gray-700">No HP</label>
<input v-model="form.no_hp" type="text" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required /> <InputField v-model="form.no_hp" type="text" placeholder="Masukkan nomor HP" required />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700">Alamat</label> <label class="block text-sm font-medium text-gray-700">Alamat</label>
<textarea v-model="form.alamat" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required></textarea> <textarea
v-model="form.alamat"
placeholder="Masukkan alamat"
class="mt-1 block w-full rounded-md shadow-sm sm:text-sm bg-A text-D border-B focus:border-C focus:ring focus:ring-D focus:ring-opacity-50 p-2"
required
></textarea>
</div> </div>
<div class="flex justify-end gap-2 mt-6"> <div class="flex justify-end gap-2 mt-6">
<button type="button" @click="$emit('close')" class="px-4 py-2 bg-gray-300 rounded hover:bg-gray-400">Batal</button> <button
<button type="submit" class="px-4 py-2 bg-C text-D rounded hover:bg-C/80">Simpan</button> type="button"
@click="$emit('close')"
class="px-4 py-2 bg-gray-300 rounded hover:bg-gray-400"
>
Batal
</button>
<button
type="submit"
class="px-4 py-2 bg-C text-D rounded hover:bg-C/80"
>
Simpan
</button>
</div> </div>
</form> </form>
</div> </div>
@ -32,27 +49,34 @@
</template> </template>
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue"
import axios from "axios"; import axios from "axios"
import InputField from "./InputField.vue"
const props = defineProps({ const props = defineProps({
isOpen: Boolean, isOpen: Boolean,
}); })
const emit = defineEmits(["close"]); const emit = defineEmits(["close", "saved"])
const form = ref({ const form = ref({
nama: "", nama: "",
no_hp: "", no_hp: "",
alamat: "", alamat: "",
}); })
const resetForm = () => {
form.value = { nama: "", no_hp: "", alamat: "" }
}
const handleSubmit = async () => { const handleSubmit = async () => {
try { try {
await axios.post("/api/sales", form.value); await axios.post("/api/sales", form.value)
emit("close"); resetForm()
emit("saved")
emit("close")
} catch (error) { } catch (error) {
console.error("Error creating sales:", error); console.error("Error creating sales:", error)
}
} }
};
</script> </script>

View File

@ -1,38 +1,54 @@
<template> <template>
<div class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50"> <div class="fixed inset-0 flex items-center justify-center bg-black/65">
<div class="bg-white rounded-lg p-6 w-96"> <div class="bg-white rounded-lg p-6 w-96">
<h2 class="text-lg font-bold mb-4">Edit Akun</h2> <h2 class="text-lg font-bold mb-4">Edit Akun</h2>
<form @submit.prevent="updateAkun"> <form @submit.prevent="updateAkun" class="space-y-3">
<!-- Nama --> <label for="nama">Nama</label>
<div class="mb-3"> <InputField
<label class="block font-medium">Nama</label> v-model="form.nama"
<input v-model="form.nama" type="text" class="border rounded w-full p-2" required /> label="nama"
type="text"
:required="true"
class="mb-3"
/>
<div>
<label for="password">Password</label>
<InputField
v-model="form.password"
label="password"
type="password"
:required="false"
class="mb-1"
/>
<p class="text-sm">Kosongkan jika tidak ingin ubah password</p>
</div> </div>
<!-- Password --> <label for="peran">Peran</label>
<div class="mb-3"> <InputSelect
<label class="block font-medium">Password</label> v-model="form.role"
<input v-model="form.password" type="password" class="border rounded w-full p-2" /> label="peran"
<small class="text-gray-500">Kosongkan jika tidak ingin mengubah password</small> :options="[
</div> { value: 'owner', label: 'Owner' },
{ value: 'kasir', label: 'Kasir' }
]"
:required="true"
class="mb-3"
/>
<!-- Peran -->
<div class="mb-3">
<label class="block font-medium">Peran</label>
<select v-model="form.role" class="border rounded w-full p-2" required>
<option value="">-- Pilih Peran --</option>
<option value="owner">Owner</option>
<option value="kasir">Kasir</option>
</select>
</div>
<!-- Tombol -->
<div class="flex justify-end gap-2 mt-4"> <div class="flex justify-end gap-2 mt-4">
<button type="button" @click="$emit('close')" class="bg-gray-300 px-4 py-2 rounded"> <button
type="button"
@click="$emit('close')"
class="bg-gray-300 px-4 py-2 rounded"
>
Batal Batal
</button> </button>
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded"> <button
type="submit"
class="bg-blue-500 text-white px-4 py-2 rounded"
>
Ubah Ubah
</button> </button>
</div> </div>
@ -43,6 +59,8 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import InputField from "@/components/InputField.vue";
import InputSelect from "@/components/InputSelect.vue";
export default { export default {
props: { props: {
@ -51,12 +69,14 @@
required: true, required: true,
}, },
}, },
components: { InputField, InputSelect },
data() { data() {
return { return {
form: { form: {
nama: this.akun.nama || "", nama: this.akun.nama || "",
password: "", password: "",
role: this.akun.role || "", // gunakan "role" bukan "peran" role: this.akun.role || "",
}, },
}; };
}, },
@ -87,7 +107,6 @@
this.$emit("close"); this.$emit("close");
} catch (err) { } catch (err) {
console.error("Gagal update akun:", err.response?.data || err.message); console.error("Gagal update akun:", err.response?.data || err.message);
alert("Update akun gagal. Silakan cek kembali inputan.");
} }
}, },
}, },

View File

@ -11,14 +11,13 @@
<h2 class="text-xl font-bold text-center text-D mb-4">Edit Kategori</h2> <h2 class="text-xl font-bold text-center text-D mb-4">Edit Kategori</h2>
<!-- Input Nama Kategori --> <!-- Input Nama Kategori -->
<div class="mb-4"> <div>
<label for="editKategori" class="block text-sm font-medium text-D mb-1">Nama Kategori</label> <label for="editKategori" class="block text-sm font-medium text-D mb-1">Nama Kategori</label>
<input <InputField
v-model="editNamaKategori" v-model="editNamaKategori"
type="text" type="text"
id="editKategori" id="editKategori"
placeholder="Masukkan nama kategori" placeholder="Masukkan nama kategori"
class="w-full p-2 border rounded-md bg-Focus outline-none"
/> />
</div> </div>
@ -37,6 +36,7 @@
<script setup> <script setup>
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import InputField from "./InputField.vue";
const props = defineProps({ const props = defineProps({
kategori: { type: Object, required: true }, kategori: { type: Object, required: true },

View File

@ -9,17 +9,21 @@
<form @submit.prevent="handleSubmit" class="space-y-4"> <form @submit.prevent="handleSubmit" class="space-y-4">
<div> <div>
<label class="block text-sm font-medium text-gray-700">Nama Sales</label> <label class="block text-sm font-medium text-gray-700">Nama Sales</label>
<input v-model="form.nama" type="text" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required /> <InputField v-model="form.nama" type="text" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700">No HP</label> <label class="block text-sm font-medium text-gray-700">No HP</label>
<input v-model="form.no_hp" type="text" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required /> <InputField v-model="form.no_hp" type="text" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required />
</div> </div>
<div> <div>
<label class="block text-sm font-medium text-gray-700">Alamat</label> <label class="block text-sm font-medium text-gray-700">Alamat</label>
<textarea v-model="form.alamat" class="w-full px-3 py-2 border rounded-md focus:ring-2 focus:ring-[#c6a77d] focus:outline-none" required></textarea> <textarea
v-model="form.alamat"
class="mt-1 block w-full rounded-md shadow-sm sm:text-sm bg-A text-D border-B focus:border-C focus:ring focus:ring-D focus:ring-opacity-50 p-2"
required
></textarea>
</div> </div>
<div class="flex justify-end gap-2 mt-6"> <div class="flex justify-end gap-2 mt-6">
@ -34,6 +38,7 @@
<script setup> <script setup>
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import axios from "axios"; import axios from "axios";
import InputField from "./InputField.vue";
const props = defineProps({ const props = defineProps({
isOpen: Boolean, isOpen: Boolean,

View File

@ -51,14 +51,14 @@
<!-- Table Section --> <!-- Table Section -->
<div <div
class="bg-white rounded-lg shadow-md border border-gray-200 overflow-hidden" class="bg-white rounded-lg shadow-md border border-C overflow-hidden"
> >
<table class="w-full"> <table class="w-full">
<thead> <thead>
<tr class="bg-C text-white"> <tr class="bg-C text-white">
<th class="px-6 py-4 text-center text-D border-r border-[#b09065]">No</th> <th class="px-6 py-4 text-center text-D border-r border-C">No</th>
<th class="px-6 py-4 text-center text-D border-r border-[#b09065]">Nama</th> <th class="px-6 py-4 text-center text-D border-r border-C">Nama</th>
<th class="px-6 py-4 text-center text-D border-r border-[#b09065]">Role</th> <th class="px-6 py-4 text-center text-D border-r border-C">Peran</th>
<th class="px-6 py-4 text-center text-D">Aksi</th> <th class="px-6 py-4 text-center text-D">Aksi</th>
</tr> </tr>
</thead> </thead>
@ -66,16 +66,16 @@
<tr <tr
v-for="(item, index) in akun" v-for="(item, index) in akun"
:key="item.id" :key="item.id"
class="border-b border-gray-200 hover:bg-gray-50 transition duration-150" class="border-b border-C hover:bg-gray-50 transition duration-150"
:class="{ 'bg-gray-50': index % 2 === 1 }" :class="{ 'bg-gray-50': index % 2 === 1 }"
> >
<td class="px-6 py-4 border-r border-gray-200 text-center font-medium text-gray-900"> <td class="px-6 py-4 border-r border-C text-center font-medium text-gray-900">
{{ index + 1 }} {{ index + 1 }}
</td> </td>
<td class="px-6 py-4 border-r border-gray-200 text-D"> <td class="px-6 py-4 border-r border-C text-D">
{{ item.nama }} {{ item.nama }}
</td> </td>
<td class="px-6 py-4 border-r border-gray-200 text-gray-800"> <td class="px-6 py-4 border-r border-C text-gray-800">
{{ item.role }} {{ item.role }}
</td> </td>
<td class="px-6 py-4 text-center"> <td class="px-6 py-4 text-center">

View File

@ -18,7 +18,7 @@
</div> </div>
<!-- Table Section --> <!-- Table Section -->
<div class="bg-white rounded-lg shadow-md border border-gray-200 overflow-hidden"> <div class="bg-white rounded-lg shadow-md border border-C overflow-hidden">
<table class="w-full"> <table class="w-full">
<thead> <thead>
<tr class="bg-C text-black"> <tr class="bg-C text-black">
@ -35,12 +35,12 @@
</thead> </thead>
<tbody> <tbody>
<tr v-for="(item, index) in kategori" :key="item.id" <tr v-for="(item, index) in kategori" :key="item.id"
class="border-b border-gray-200 hover:bg-A transition duration-150" class="border-b border-C hover:bg-A transition duration-150"
:class="{ 'bg-gray-50': index % 2 === 1 }"> :class="{ 'bg-gray-50': index % 2 === 1 }">
<td class="px-6 py-4 border-r border-gray-200 font-medium text-center text-gray-900"> <td class="px-6 py-4 border-r border-C font-medium text-center text-gray-900">
{{ index + 1 }} {{ index + 1 }}
</td> </td>
<td class="px-6 py-4 border-r border-gray-200 text-center text-gray-800"> <td class="px-6 py-4 border-r border-C text-center text-gray-800">
{{ item.nama }} {{ item.nama }}
</td> </td>
<td class="px-6 py-4 text-center"> <td class="px-6 py-4 text-center">

View File

@ -51,7 +51,7 @@
<!-- Table Section --> <!-- Table Section -->
<div <div
class="bg-white rounded-lg shadow-md border border-gray-200 overflow-hidden" class="bg-white rounded-lg shadow-md border border-C overflow-hidden"
> >
<table class="w-full"> <table class="w-full">
<thead class=""> <thead class="">
@ -85,26 +85,26 @@
<tr <tr
v-for="(item, index) in sales" v-for="(item, index) in sales"
:key="item.id" :key="item.id"
class="border-b border-gray-200 hover:bg-gray-50 transition duration-150" class="border-b border-C hover:bg-gray-50 transition duration-150"
:class="{ 'bg-gray-50': index % 2 === 1 }" :class="{ 'bg-gray-50': index % 2 === 1 }"
> >
<td <td
class="px-6 py-4 border-r border-gray-200 text-center font-medium text-gray-900" class="px-6 py-4 border-r border-C text-center font-medium text-gray-900"
> >
{{ index + 1 }} {{ index + 1 }}
</td> </td>
<td <td
class="px-6 py-4 border-r border-gray-200 text-D" class="px-6 py-4 border-r border-C text-D"
> >
{{ item.nama }} {{ item.nama }}
</td> </td>
<td <td
class="px-6 py-4 border-r border-gray-200 text-gray-800" class="px-6 py-4 border-r border-C text-gray-800"
> >
{{ item.no_hp }} {{ item.no_hp }}
</td> </td>
<td <td
class="px-6 py-4 border-r border-gray-200 text-gray-800" class="px-6 py-4 border-r border-C text-gray-800"
> >
{{ item.alamat }} {{ item.alamat }}
</td> </td>