[update] Tutor buat monti
This commit is contained in:
parent
600c87d9ca
commit
ae4b8a3449
@ -20,9 +20,9 @@ class DatabaseSeeder extends Seeder
|
|||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::factory()->create([
|
User::factory()->create([
|
||||||
'nama' => 'Test User',
|
'nama' => 'Test',
|
||||||
'role' => 'owner',
|
'role' => 'owner',
|
||||||
'password' => bcrypt('123123123'),
|
'password' => bcrypt('123123'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
User::factory(2)->create();
|
User::factory(2)->create();
|
||||||
|
@ -144,7 +144,7 @@ const saveMove = async () => {
|
|||||||
},
|
},
|
||||||
body:{
|
body:{
|
||||||
id_nampan: selectedTrayId.value,
|
id_nampan: selectedTrayId.value,
|
||||||
id_produk: selectedItem.value.id_produk, // ikutkan id_produk karena API minta
|
id_produk: selectedItem.value.id_produk,
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -151,7 +151,11 @@ const akunToDelete = ref(null);
|
|||||||
const fetchAkun = async () => {
|
const fetchAkun = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("/api/user");
|
const response = await axios.get("/api/user", {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
akun.value = response.data;
|
akun.value = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching akun:", error);
|
console.error("Error fetching akun:", error);
|
||||||
@ -180,7 +184,11 @@ const hapusAkun = (item) => {
|
|||||||
|
|
||||||
const confirmDelete = async () => {
|
const confirmDelete = async () => {
|
||||||
try {
|
try {
|
||||||
await axios.delete(`/api/user/${akunToDelete.value.id}`);
|
await axios.delete(`/api/user/${akunToDelete.value.id}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
fetchAkun();
|
fetchAkun();
|
||||||
confirmDeleteOpen.value = false;
|
confirmDeleteOpen.value = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<mainLayout>
|
<mainLayout>
|
||||||
<!-- Modal Buat Item -->
|
<!-- Modal Buat Item -->
|
||||||
<CreateItemModal
|
<CreateItemModal :isOpen="openItemModal" :product="editedProduct" @close="closeItemModal" />
|
||||||
:isOpen="openItemModal"
|
|
||||||
:product="editedProduct"
|
|
||||||
@close="closeItemModal"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
<p class="font-serif italic text-[25px] text-D">Edit Produk</p>
|
<p class="font-serif italic text-[25px] text-D">Edit Produk</p>
|
||||||
@ -26,7 +22,8 @@
|
|||||||
<div class="mb-3 flex flex-row w-full gap-3">
|
<div class="mb-3 flex flex-row w-full gap-3">
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<label class="block text-D mb-1">Berat (g)</label>
|
<label class="block text-D mb-1">Berat (g)</label>
|
||||||
<InputField v-model="form.berat" type="number" step="0.01" placeholder="Masukkan berat" @input="calculateHargaJual" />
|
<InputField v-model="form.berat" type="number" step="0.01" placeholder="Masukkan berat"
|
||||||
|
@input="calculateHargaJual" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<label class="block text-D mb-1">Kadar (K)</label>
|
<label class="block text-D mb-1">Kadar (K)</label>
|
||||||
@ -37,7 +34,8 @@
|
|||||||
<div class="mb-3 flex flex-row w-full gap-3">
|
<div class="mb-3 flex flex-row w-full gap-3">
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<label class="block text-D mb-1">Harga per Gram</label>
|
<label class="block text-D mb-1">Harga per Gram</label>
|
||||||
<InputField v-model="form.harga_per_gram" type="number" step="0.01" placeholder="Masukkan harga per gram" @input="calculateHargaJual" />
|
<InputField v-model="form.harga_per_gram" type="number" step="0.01" placeholder="Masukkan harga per gram"
|
||||||
|
@input="calculateHargaJual" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<label class="block text-D mb-1">Harga Jual</label>
|
<label class="block text-D mb-1">Harga Jual</label>
|
||||||
@ -83,12 +81,14 @@
|
|||||||
</path>
|
</path>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-gray-600 font-medium" v-html="uploadLoading ? 'Uploading...' : 'Unggah<br/>Foto'"></p>
|
<p class="text-xs text-gray-600 font-medium"
|
||||||
|
v-html="uploadLoading ? 'Uploading...' : 'Unggah<br/>Foto'"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input ref="fileInput" type="file" multiple accept="image/jpeg,image/jpg,image/png" @change="handleFileSelect" class="hidden" />
|
<input ref="fileInput" type="file" multiple accept="image/jpeg,image/jpg,image/png" @change="handleFileSelect"
|
||||||
|
class="hidden" />
|
||||||
|
|
||||||
<p class="text-xs text-gray-500 mt-2">Format: JPG, JPEG, PNG (Max: 2MB per file, Max: 6 foto)</p>
|
<p class="text-xs text-gray-500 mt-2">Format: JPG, JPEG, PNG (Max: 2MB per file, Max: 6 foto)</p>
|
||||||
|
|
||||||
@ -164,12 +164,20 @@ const calculateHargaJual = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadKategori = async () => {
|
const loadKategori = async () => {
|
||||||
const response = await axios.get("/api/kategori");
|
const response = await axios.get("/api/kategori", {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
category.value = response.data.map((c) => ({ value: c.id, label: c.nama }));
|
category.value = response.data.map((c) => ({ value: c.id, label: c.nama }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadProduk = async () => {
|
const loadProduk = async () => {
|
||||||
const response = await axios.get(`/api/produk/${productId}`);
|
const response = await axios.get(`/api/produk/${productId}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
const produk = response.data;
|
const produk = response.data;
|
||||||
form.value = {
|
form.value = {
|
||||||
nama: produk.nama,
|
nama: produk.nama,
|
||||||
@ -216,7 +224,10 @@ const uploadFiles = async (files) => {
|
|||||||
formData.append("foto", file);
|
formData.append("foto", file);
|
||||||
formData.append("id_user", userId.value);
|
formData.append("id_user", userId.value);
|
||||||
const res = await axios.post("/api/foto/upload", formData, {
|
const res = await axios.post("/api/foto/upload", formData, {
|
||||||
headers: { "Content-Type": "multipart/form-data" },
|
headers: {
|
||||||
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
});
|
});
|
||||||
uploadedImages.value.push(res.data);
|
uploadedImages.value.push(res.data);
|
||||||
}
|
}
|
||||||
@ -227,7 +238,11 @@ const uploadFiles = async (files) => {
|
|||||||
|
|
||||||
const removeImage = async (id) => {
|
const removeImage = async (id) => {
|
||||||
try {
|
try {
|
||||||
await axios.delete(`/api/foto/hapus/${id}`);
|
await axios.delete(`/api/foto/hapus/${id}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
uploadedImages.value = uploadedImages.value.filter((i) => i.id !== id);
|
uploadedImages.value = uploadedImages.value.filter((i) => i.id !== id);
|
||||||
} catch {
|
} catch {
|
||||||
uploadError.value = "Gagal menghapus foto";
|
uploadError.value = "Gagal menghapus foto";
|
||||||
|
Loading…
Reference in New Issue
Block a user