Compare commits
No commits in common. "15917b4c52d19c29ff67e22337f0765ca886c489" and "fc5541b8b0eddfbfb477295fe2e1ac2bbf6b6b17" have entirely different histories.
15917b4c52
...
fc5541b8b0
@ -11,7 +11,7 @@ class FotoSementaraController extends Controller
|
|||||||
public function upload(Request $request)
|
public function upload(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'id_user' => 'required|exists:users,id',
|
'id_produk' => 'required|exists:produk,id',
|
||||||
'foto' => 'required|image|mimes:jpg,jpeg,png|max:2048',
|
'foto' => 'required|image|mimes:jpg,jpeg,png|max:2048',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -19,11 +19,11 @@ class FotoSementaraController extends Controller
|
|||||||
$url = asset('storage/' . $path);
|
$url = asset('storage/' . $path);
|
||||||
|
|
||||||
$foto = FotoSementara::create([
|
$foto = FotoSementara::create([
|
||||||
'id_user' => $request->id_user,
|
'id_produk' => $request->id_produk,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json($foto, 201);
|
return response()->json(['message' => 'Foto berhasil disimpan'], 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hapus($id)
|
public function hapus($id)
|
||||||
@ -45,9 +45,6 @@ class FotoSementaraController extends Controller
|
|||||||
public function getAll($user_id)
|
public function getAll($user_id)
|
||||||
{
|
{
|
||||||
$data = FotoSementara::where('id_user', $user_id);
|
$data = FotoSementara::where('id_user', $user_id);
|
||||||
if (!$data->exists()) {
|
|
||||||
return response()->json(['message' => 'Tidak ada foto ditemukan'], 404);
|
|
||||||
}
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class NampanController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
return response()->json(
|
return response()->json(
|
||||||
Nampan::with('items.produk.foto')->withCount('items')->get()
|
Nampan::withCount('items')->get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class NampanController extends Controller
|
|||||||
public function show(int $id)
|
public function show(int $id)
|
||||||
{
|
{
|
||||||
return response()->json(
|
return response()->json(
|
||||||
Nampan::with('items.produk.foto')->find($id)
|
Nampan::with('items')->find($id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,20 +13,14 @@ class TransaksiController extends Controller
|
|||||||
// List semua transaksi
|
// List semua transaksi
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$limit = request()->query('limit', null);
|
$transaksi = Transaksi::with(['kasir', 'sales', 'items.item.produk'])->get();
|
||||||
$query = Transaksi::with(['kasir', 'sales', 'items.item.produk'])->latest();
|
|
||||||
if ($limit) {
|
|
||||||
$query->limit((int)$limit);
|
|
||||||
}
|
|
||||||
$transaksi = $query->get();
|
|
||||||
$transaksi = Transaksi::with(['kasir', 'sales', 'items.item.produk'])->latest()->limit(100)->get();
|
|
||||||
return response()->json($transaksi);
|
return response()->json($transaksi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detail transaksi by ID
|
// Detail transaksi by ID
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$transaksi = Transaksi::with(['kasir', 'sales', 'items.item.produk.foto'])->findOrFail($id);
|
$transaksi = Transaksi::with(['kasir', 'sales', 'items.item.produk'])->findOrFail($id);
|
||||||
return response()->json($transaksi);
|
return response()->json($transaksi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,18 +13,9 @@ class Nampan extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'nama'
|
'nama'
|
||||||
];
|
];
|
||||||
protected $appends = ['berat_total'];
|
|
||||||
|
|
||||||
|
|
||||||
public function items()
|
public function items()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Item::class, 'id_nampan');
|
return $this->hasMany(Item::class, 'id_nampan');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBeratTotalAttribute()
|
|
||||||
{
|
|
||||||
return $this->items()
|
|
||||||
->join('produks', 'items.id_produk', '=', 'produks.id')
|
|
||||||
->sum('produks.berat');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
<template>
|
|
||||||
<input
|
|
||||||
:type="type"
|
|
||||||
:value="modelValue"
|
|
||||||
@input="$emit('update:modelValue', $event.target.value)"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
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"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const props = defineProps({
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'text',
|
|
||||||
},
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
|
||||||
</script>
|
|
@ -1,31 +0,0 @@
|
|||||||
<template>
|
|
||||||
<select
|
|
||||||
:value="modelValue"
|
|
||||||
@change="$emit('update:modelValue', $event.target.value)"
|
|
||||||
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"
|
|
||||||
>
|
|
||||||
<option value="" :disabled="!modelValue && placeholder" v-if="placeholder" class="hover:bg-C text-D">{{ placeholder }}</option>
|
|
||||||
<option v-for="option in options" :key="option.value" :selected="option.selected" :value="option.value" class="hover:bg-C text-D">
|
|
||||||
{{ option.label }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const props = defineProps({
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
type: Array,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue']);
|
|
||||||
</script>
|
|
@ -1,384 +0,0 @@
|
|||||||
<template>
|
|
||||||
<mainLayout>
|
|
||||||
<div class="p-6">
|
|
||||||
<p class="font-serif italic text-[25px] text-D">Produk Baru</p>
|
|
||||||
|
|
||||||
<div class="flex flex-col md:flex-row mt-5 gap-6">
|
|
||||||
<!-- Form Section -->
|
|
||||||
<div class="flex-1">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="block text-D mb-1">Nama Produk</label>
|
|
||||||
<InputField
|
|
||||||
v-model="form.nama"
|
|
||||||
type="text"
|
|
||||||
placeholder="Masukkan nama produk"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="block text-D mb-1">Kategori</label>
|
|
||||||
<InputSelect
|
|
||||||
v-model="form.kategori"
|
|
||||||
:options="category"
|
|
||||||
placeholder="Pilih kategori"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3 flex flex-row w-full gap-3">
|
|
||||||
<div class="flex-1">
|
|
||||||
<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"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1">
|
|
||||||
<label class="block text-D mb-1">Kadar (K)</label>
|
|
||||||
<InputField
|
|
||||||
v-model="form.kadar"
|
|
||||||
type="number"
|
|
||||||
placeholder="Masukkan kadar"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3 flex flex-row w-full gap-3">
|
|
||||||
<div class="flex-1">
|
|
||||||
<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"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1">
|
|
||||||
<label class="block text-D mb-1">Harga Jual</label>
|
|
||||||
<InputField
|
|
||||||
v-model="form.harga_jual"
|
|
||||||
type="number"
|
|
||||||
step="0.01"
|
|
||||||
placeholder="Masukkan harga jual"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-6">
|
|
||||||
<button
|
|
||||||
@click="submitForm"
|
|
||||||
:disabled="loading || !isFormValid"
|
|
||||||
class="bg-blue-600 text-white px-6 py-2 rounded-md hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed"
|
|
||||||
>
|
|
||||||
{{ loading ? 'Menyimpan...' : 'Simpan Produk' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Image Upload Section -->
|
|
||||||
<div class="flex-1">
|
|
||||||
<label class="block text-D mb-1">Foto</label>
|
|
||||||
|
|
||||||
<!-- Image Grid -->
|
|
||||||
<div class="grid grid-cols-3 gap-3">
|
|
||||||
<!-- Uploaded Images -->
|
|
||||||
<div
|
|
||||||
v-for="(image, index) in uploadedImages"
|
|
||||||
:key="`img-${image.id}`"
|
|
||||||
class="relative group aspect-square"
|
|
||||||
>
|
|
||||||
<div class="w-full h-full bg-gray-100 rounded-lg border-2 border-gray-200 overflow-hidden">
|
|
||||||
<img
|
|
||||||
:src="image.url"
|
|
||||||
:alt="`Foto ${index + 1}`"
|
|
||||||
class="w-full h-full object-cover"
|
|
||||||
/>
|
|
||||||
<!-- Delete Button -->
|
|
||||||
<button
|
|
||||||
@click="removeImage(image.id)"
|
|
||||||
:disabled="uploadLoading"
|
|
||||||
class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-sm font-bold shadow-lg hover:bg-red-600 transition-colors disabled:bg-gray-400"
|
|
||||||
>
|
|
||||||
×
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Upload Button -->
|
|
||||||
<div
|
|
||||||
v-if="uploadedImages.length < 6"
|
|
||||||
@drop="handleDrop"
|
|
||||||
@dragover.prevent
|
|
||||||
@dragenter.prevent="isDragging = true"
|
|
||||||
@dragleave.prevent="isDragging = false"
|
|
||||||
@click="triggerFileInput"
|
|
||||||
class="aspect-square bg-gray-50 border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center cursor-pointer hover:border-blue-400 hover:bg-blue-50 transition-colors group"
|
|
||||||
:class="{
|
|
||||||
'border-blue-400 bg-blue-50': isDragging,
|
|
||||||
'cursor-not-allowed opacity-50': uploadLoading
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div class="text-center">
|
|
||||||
<!-- Upload Icon or Loading -->
|
|
||||||
<div v-if="!uploadLoading" class="w-12 h-12 bg-blue-600 rounded-lg flex items-center justify-center mx-auto mb-2 group-hover:bg-blue-700 transition-colors">
|
|
||||||
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div v-else class="w-12 h-12 bg-blue-600 rounded-lg flex items-center justify-center mx-auto mb-2">
|
|
||||||
<svg class="animate-spin w-6 h-6 text-white" fill="none" viewBox="0 0 24 24">
|
|
||||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
||||||
<path class="opacity-75" fill="currentColor" d="m4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<p class="text-xs text-gray-600 font-medium" v-html="uploadLoading ? 'Uploading...' : 'Unggah<br/>Foto'"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Hidden File Input -->
|
|
||||||
<input
|
|
||||||
ref="fileInput"
|
|
||||||
type="file"
|
|
||||||
multiple
|
|
||||||
accept="image/jpeg,image/jpg,image/png"
|
|
||||||
@change="handleFileSelect"
|
|
||||||
class="hidden"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- Upload Info -->
|
|
||||||
<p class="text-xs text-gray-500 mt-2">Format: JPG, JPEG, PNG (Max: 2MB per file, Max: 6 foto)</p>
|
|
||||||
|
|
||||||
<!-- Error Message -->
|
|
||||||
<div v-if="uploadError" class="mt-2 p-2 bg-red-50 border border-red-200 rounded text-sm text-red-600">
|
|
||||||
{{ uploadError }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mainLayout>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref, computed, onMounted, onUnmounted } from "vue";
|
|
||||||
import axios from "axios";
|
|
||||||
import mainLayout from "../layouts/mainLayout.vue";
|
|
||||||
import InputField from "../components/InputField.vue";
|
|
||||||
import InputSelect from "../components/InputSelect.vue";
|
|
||||||
|
|
||||||
const form = ref({
|
|
||||||
nama: '',
|
|
||||||
kategori: '',
|
|
||||||
berat: 0,
|
|
||||||
kadar: 0,
|
|
||||||
harga_per_gram: 0,
|
|
||||||
harga_jual: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const category = ref([
|
|
||||||
{ value: "cincin", label: "Cincin" },
|
|
||||||
{ value: "gelang", label: "Gelang" },
|
|
||||||
{ value: "kalung", label: "Kalung" },
|
|
||||||
{ value: "anting", label: "Anting" },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const uploadLoading = ref(false);
|
|
||||||
const uploadedImages = ref([]);
|
|
||||||
const isDragging = ref(false);
|
|
||||||
const uploadError = ref('');
|
|
||||||
const fileInput = ref(null);
|
|
||||||
const userId = ref(1); // Sesuaikan dengan user yang login
|
|
||||||
|
|
||||||
const isFormValid = computed(() => {
|
|
||||||
return form.value.nama &&
|
|
||||||
form.value.kategori &&
|
|
||||||
form.value.berat > 0 &&
|
|
||||||
form.value.kadar > 0 &&
|
|
||||||
form.value.harga_per_gram > 0 &&
|
|
||||||
form.value.harga_jual > 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
const calculateHargaJual = () => {
|
|
||||||
const berat = parseFloat(form.value.berat) || 0;
|
|
||||||
const hargaPerGram = parseFloat(form.value.harga_per_gram) || 0;
|
|
||||||
if (berat > 0 && hargaPerGram > 0) {
|
|
||||||
form.value.harga_jual = berat * hargaPerGram;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadExistingPhotos = async () => {
|
|
||||||
try {
|
|
||||||
const response = await axios.get(`/api/foto/${userId.value}`);
|
|
||||||
if (response.data && Array.isArray(response.data)) {
|
|
||||||
uploadedImages.value = response.data;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.response?.status !== 404) {
|
|
||||||
console.error('Error loading existing photos:', error);
|
|
||||||
}
|
|
||||||
// 404 is expected when no photos exist yet
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const triggerFileInput = () => {
|
|
||||||
if (!uploadLoading.value && uploadedImages.value.length < 6) {
|
|
||||||
fileInput.value?.click();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleFileSelect = (event) => {
|
|
||||||
const files = Array.from(event.target.files);
|
|
||||||
uploadFiles(files);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDrop = (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
isDragging.value = false;
|
|
||||||
|
|
||||||
if (uploadLoading.value || uploadedImages.value.length >= 6) return;
|
|
||||||
|
|
||||||
const files = Array.from(event.dataTransfer.files);
|
|
||||||
uploadFiles(files);
|
|
||||||
};
|
|
||||||
|
|
||||||
const uploadFiles = async (files) => {
|
|
||||||
uploadError.value = '';
|
|
||||||
|
|
||||||
// Validate file count
|
|
||||||
if (uploadedImages.value.length + files.length > 6) {
|
|
||||||
uploadError.value = 'Maksimal 6 foto yang dapat diupload';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate file types and sizes
|
|
||||||
const validFiles = files.filter(file => {
|
|
||||||
const isValidType = ['image/jpeg', 'image/jpg', 'image/png'].includes(file.type);
|
|
||||||
const isValidSize = file.size <= 2 * 1024 * 1024; // 2MB
|
|
||||||
|
|
||||||
if (!isValidType) {
|
|
||||||
uploadError.value = 'Format file harus JPG, JPEG, atau PNG';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isValidSize) {
|
|
||||||
uploadError.value = 'Ukuran file maksimal 2MB';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (validFiles.length === 0) return;
|
|
||||||
|
|
||||||
uploadLoading.value = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (const file of validFiles) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('foto', file);
|
|
||||||
formData.append('id_user', userId.value);
|
|
||||||
|
|
||||||
const response = await axios.post('/api/foto/upload', formData, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
uploadedImages.value.push(response.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear file input
|
|
||||||
if (fileInput.value) {
|
|
||||||
fileInput.value.value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Upload error:', error);
|
|
||||||
uploadError.value = error.response?.data?.message || 'Gagal mengupload foto';
|
|
||||||
} finally {
|
|
||||||
uploadLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeImage = async (imageId) => {
|
|
||||||
try {
|
|
||||||
await axios.delete(`/api/foto/hapus/${imageId}`);
|
|
||||||
uploadedImages.value = uploadedImages.value.filter(img => img.id !== imageId);
|
|
||||||
uploadError.value = '';
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Delete error:', error);
|
|
||||||
uploadError.value = 'Gagal menghapus foto';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const submitForm = async () => {
|
|
||||||
if (!isFormValid.value) {
|
|
||||||
alert('Mohon lengkapi semua field yang diperlukan');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loading.value = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await axios.post('/api/produk', {
|
|
||||||
...form.value,
|
|
||||||
id_user: userId.value
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reset form
|
|
||||||
form.value = {
|
|
||||||
nama: '',
|
|
||||||
kategori: '',
|
|
||||||
berat: 0,
|
|
||||||
kadar: 0,
|
|
||||||
harga_per_gram: 0,
|
|
||||||
harga_jual: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
uploadedImages.value = [];
|
|
||||||
uploadError.value = '';
|
|
||||||
|
|
||||||
if (fileInput.value) {
|
|
||||||
fileInput.value.value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
alert('Produk berhasil disimpan!');
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Submit error:', error);
|
|
||||||
|
|
||||||
if (error.response?.data?.errors) {
|
|
||||||
const errors = Object.values(error.response.data.errors).flat();
|
|
||||||
alert('Error: ' + errors.join(', '));
|
|
||||||
} else {
|
|
||||||
alert('Gagal menyimpan produk: ' + (error.response?.data?.message || error.message));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const resetPhotos = async () => {
|
|
||||||
try {
|
|
||||||
await axios.delete(`/api/foto/reset/${userId.value}`);
|
|
||||||
uploadedImages.value = [];
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error resetting photos:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load existing photos on component mount
|
|
||||||
onMounted(() => {
|
|
||||||
loadExistingPhotos();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clean up photos if user leaves without saving
|
|
||||||
onUnmounted(() => {
|
|
||||||
// Optional: You might want to clean up temporary photos here
|
|
||||||
// resetPhotos();
|
|
||||||
});
|
|
||||||
</script>
|
|
@ -3,7 +3,6 @@ import Home from '../pages/Home.vue'
|
|||||||
import Produk from '../pages/Produk.vue'
|
import Produk from '../pages/Produk.vue'
|
||||||
import Brankas from '../pages/Brankas.vue'
|
import Brankas from '../pages/Brankas.vue'
|
||||||
import Tray from '../pages/Tray.vue'
|
import Tray from '../pages/Tray.vue'
|
||||||
import InputProduk from '../pages/InputProduk.vue'
|
|
||||||
|
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
@ -17,11 +16,6 @@ const routes = [
|
|||||||
name: 'Produk',
|
name: 'Produk',
|
||||||
component: Produk
|
component: Produk
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/produk/baru',
|
|
||||||
name: 'Produk',
|
|
||||||
component: InputProduk
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/brankas',
|
path: '/brankas',
|
||||||
name: 'Brankas',
|
name: 'Brankas',
|
||||||
|
@ -19,12 +19,10 @@ Route::prefix('api')->group(function () {
|
|||||||
Route::apiResource('transaksi', TransaksiController::class);
|
Route::apiResource('transaksi', TransaksiController::class);
|
||||||
|
|
||||||
Route::get('brankas', [ItemController::class, 'brankasItem']);
|
Route::get('brankas', [ItemController::class, 'brankasItem']);
|
||||||
|
|
||||||
// Foto Sementara
|
|
||||||
Route::post('foto/upload', [FotoSementaraController::class, 'upload']);
|
Route::post('foto/upload', [FotoSementaraController::class, 'upload']);
|
||||||
Route::delete('foto/hapus/{id}', [FotoSementaraController::class, 'hapus']);
|
Route::delete('foto/hapus/<id>', [FotoSementaraController::class, 'hapus']);
|
||||||
Route::get('foto/{user_id}', [FotoSementaraController::class, 'getAll']);
|
Route::get('foto/<user_id>', [FotoSementaraController::class, 'getAll']);
|
||||||
Route::delete('foto/reset/{user_id}', [FotoSementaraController::class, 'reset']);
|
Route::delete('foto/reset/<user_id>', [FotoSementaraController::class, 'reset']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Frontend SPA
|
// Frontend SPA
|
||||||
|
Loading…
Reference in New Issue
Block a user