[update] undangan ulang tahun premium
This commit is contained in:
parent
4ce07faf34
commit
ec192c588a
@ -1,434 +1,174 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="max-w-4xl mx-auto p-6">
|
<div class="min-h-screen bg-gray-50 py-10 px-6">
|
||||||
<div class="bg-white rounded-lg shadow-lg p-8">
|
<div class="max-w-5xl mx-auto bg-white rounded-2xl shadow-lg p-8">
|
||||||
<h2 class="text-3xl font-bold text-gray-800 mb-2">
|
<h1 class="text-2xl font-bold text-center text-gray-800">
|
||||||
Undangan Ulang Tahun Premium
|
Form Undangan Ulang Tahun Premium
|
||||||
</h2>
|
</h1>
|
||||||
<p class="text-gray-600 mb-6">Harga: Rp 200.000</p>
|
<p class="text-center text-gray-500 text-sm mb-8">
|
||||||
|
Isi semua data berikut dengan lengkap dan benar.
|
||||||
|
</p>
|
||||||
|
|
||||||
<form @submit.prevent="submitForm" class="space-y-6">
|
|
||||||
<!-- Data Pemesan -->
|
<!-- Data Pemesan -->
|
||||||
<div class="border-b pb-6">
|
<section class="mb-8">
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Data Pemesan</h3>
|
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">📋 Data Pemesan</h2>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<input v-model="form.nama_pemesan" type="text" placeholder="Nama Pemesan"
|
||||||
<div>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
<input v-model="form.email" type="email" placeholder="Email"
|
||||||
Nama Pemesan <span class="text-red-500">*</span>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
</label>
|
<input v-model="form.no_tlpn" type="text" placeholder="No Telepon"
|
||||||
<input
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
v-model="formData.nama_pemesan"
|
</div>
|
||||||
type="text"
|
</section>
|
||||||
required
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Masukkan nama pemesan"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<!-- Data Anak -->
|
||||||
|
<section class="mb-8">
|
||||||
|
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">🎉 Data Anak</h2>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
<div class="grid gap-2">
|
||||||
Email <span class="text-red-500">*</span>
|
<input v-model="form.form.nama_lengkap" placeholder="Nama Lengkap"
|
||||||
</label>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
<input
|
<input v-model="form.form.nama_panggilan" placeholder="Nama Panggilan"
|
||||||
v-model="formData.email"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
type="email"
|
<input v-model="form.form.nama_bapak" placeholder="Nama Bapak"
|
||||||
required
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
<input v-model="form.form.nama_ibu" placeholder="Nama Ibu"
|
||||||
placeholder="contoh@email.com"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
/>
|
<input v-model="form.form.umur_yang_dirayakan" type="number" placeholder="Umur Yang Dirayakan"
|
||||||
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<input v-model="form.form.anak_ke" type="number" placeholder="Anak Ke"
|
||||||
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
<div class="grid gap-2">
|
||||||
No Telepon
|
<input v-model="form.form.instagram" placeholder="Link Instagram"
|
||||||
</label>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
<input
|
<input v-model="form.form.facebook" placeholder="Link Facebook"
|
||||||
v-model="formData.no_telepon"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
type="text"
|
<input v-model="form.form.twitter" placeholder="Link Twitter"
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
placeholder="08xxxxxxxxxx"
|
</div>
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
<!-- Data Yang Berulang Tahun -->
|
|
||||||
<div class="border-b pb-6">
|
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Data Yang Berulang Tahun</h3>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Nama Lengkap
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.nama_lengkap"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Nama lengkap"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Nama Panggilan
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.nama_panggilan"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Nama panggilan"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Nama Bapak
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.nama_bapak"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Nama bapak"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Nama Ibu
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.nama_ibu"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Nama ibu"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Umur Yang Dirayakan
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model.number="formData.umur_yang_dirayakan"
|
|
||||||
type="number"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Contoh: 7"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Anak Ke
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model.number="formData.anak_ke"
|
|
||||||
type="number"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Contoh: 1"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Media Sosial -->
|
|
||||||
<div class="border-b pb-6">
|
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Media Sosial</h3>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-4">
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Link Instagram
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.instagram"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="https://instagram.com/username"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Link Facebook
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.facebook"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="https://facebook.com/username"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Link Twitter
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.twitter"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="https://twitter.com/username"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Detail Acara -->
|
<!-- Detail Acara -->
|
||||||
<div class="border-b pb-6">
|
<section class="mb-8">
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Detail Acara</h3>
|
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">📅 Detail Acara</h2>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<div>
|
<input v-model="form.form.hari_tanggal_acara" type="date" placeholder="Hari & Tanggal Acara"
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
Hari & Tanggal Acara
|
<input v-model="form.form.waktu" type="text" placeholder="Waktu"
|
||||||
</label>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
<input
|
<textarea v-model="form.form.alamat" rows="4" placeholder="Alamat"
|
||||||
v-model="formData.hari_tanggal_acara"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition resize-none"></textarea>
|
||||||
type="date"
|
<input v-model="form.form.link_gmaps" type="text" placeholder="Link Gmaps"
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
/>
|
<input v-model="form.form.hitung_mundur" type="datetime-local" placeholder="Hitung Mundur Waktu Acara"
|
||||||
</div>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<input v-model="form.form.link_live_streaming" type="text" placeholder="Link Live Streaming"
|
||||||
<div>
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Waktu
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.waktu"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Contoh: 14.00 - 16.00 WIB"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md:col-span-2">
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Alamat
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.alamat"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Alamat lengkap acara"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md:col-span-2">
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Link Google Maps
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.link_gmaps"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="https://maps.google.com/..."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md:col-span-2">
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Say Something
|
|
||||||
</label>
|
|
||||||
<textarea
|
|
||||||
v-model="formData.say_something"
|
|
||||||
rows="4"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Pesan atau kata-kata untuk undangan"
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
<!-- Rekening -->
|
<!-- Pesan & Rekening -->
|
||||||
<div class="border-b pb-6">
|
<section class="mb-8">
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Rekening (Opsional)</h3>
|
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">💌 Pesan & Rekening</h2>
|
||||||
|
<textarea v-model="form.form.say_something" rows="4" placeholder="Say Something..."
|
||||||
<div class="grid grid-cols-1 gap-4">
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition resize-none"></textarea>
|
||||||
<div>
|
<div class="grid md:grid-cols-3 gap-4 mt-4">
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
<input v-model="form.form.rekening_1" placeholder="Rekening 1"
|
||||||
Rekening 1
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
</label>
|
<input v-model="form.form.rekening_2" placeholder="Rekening 2"
|
||||||
<input
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
v-model="formData.rekening_1"
|
<input v-model="form.form.rekening_3" placeholder="Rekening 3"
|
||||||
type="text"
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Contoh: BCA - 1234567890 - Nama Pemilik"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Rekening 2
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.rekening_2"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Contoh: Mandiri - 9876543210 - Nama Pemilik"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Rekening 3
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
v-model="formData.rekening_3"
|
|
||||||
type="text"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
placeholder="Contoh: BNI - 5555555555 - Nama Pemilik"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<input v-model="form.form.link_music" placeholder="Link Music (opsional)"
|
||||||
|
class="w-full border border-gray-300 rounded-lg px-3 py-2 mt-4 focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Upload Foto -->
|
<!-- Foto Upload -->
|
||||||
<div class="border-b pb-6">
|
<section class="mb-8">
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Upload Foto</h3>
|
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">🖼️ Galeri Foto</h2>
|
||||||
|
<div
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
class="border-2 border-dashed border-gray-300 rounded-xl p-8 flex flex-col justify-center items-center text-gray-400 hover:border-blue-400 hover:text-blue-500 transition"
|
||||||
<div v-for="i in 5" :key="i">
|
>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Foto {{ i }}
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
accept="image/*"
|
|
||||||
@change="handleFileUpload($event, `foto_${i}`)"
|
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
|
||||||
/>
|
|
||||||
<p v-if="formData[`foto_${i}`]" class="text-sm text-green-600 mt-1">
|
|
||||||
✓ File dipilih: {{ formData[`foto_${i}`].name }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Link Music -->
|
|
||||||
<div class="pb-6">
|
|
||||||
<h3 class="text-xl font-semibold text-gray-700 mb-4">Background Music</h3>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
|
||||||
Link Music
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
v-model="formData.link_music"
|
id="gallery"
|
||||||
type="text"
|
type="file"
|
||||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
multiple
|
||||||
placeholder="Link YouTube atau file musik"
|
accept="image/*"
|
||||||
|
class="hidden"
|
||||||
|
@change="handleFileChange"
|
||||||
/>
|
/>
|
||||||
|
<label v-if="!previews.length" for="gallery" class="cursor-pointer flex flex-col items-center">
|
||||||
|
<span class="text-4xl font-bold">+</span>
|
||||||
|
<span class="text-sm mt-2">Pilih Foto (maks. 8, JPEG/PNG, maks. 2MB)</span>
|
||||||
|
</label>
|
||||||
|
<div v-else class="grid grid-cols-3 sm:grid-cols-4 gap-4">
|
||||||
|
<div
|
||||||
|
v-for="(src, i) in previews"
|
||||||
|
:key="i"
|
||||||
|
class="relative group"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="src"
|
||||||
|
class="w-24 h-24 object-cover rounded-lg border shadow"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
@click="removeFile(i)"
|
||||||
|
class="absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs opacity-0 group-hover:opacity-100 transition"
|
||||||
|
title="Hapus foto"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<label
|
||||||
|
v-if="previews.length < 8"
|
||||||
|
for="gallery"
|
||||||
|
class="cursor-pointer flex flex-col items-center justify-center w-24 h-24 border-2 border-dashed border-gray-300 rounded-lg text-gray-400 hover:border-blue-400 hover:text-blue-500 transition"
|
||||||
|
>
|
||||||
|
<span class="text-3xl font-bold">+</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
<!-- Submit Button -->
|
<!-- Tombol -->
|
||||||
<div class="flex gap-4">
|
<div class="text-end mt-6">
|
||||||
<button
|
<button @click="batal"
|
||||||
type="submit"
|
class="bg-gray-600 text-white font-semibold px-6 py-2 rounded-lg transition mr-2">
|
||||||
:disabled="loading"
|
Batal
|
||||||
class="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 px-6 rounded-lg transition duration-200 disabled:bg-gray-400 disabled:cursor-not-allowed"
|
|
||||||
>
|
|
||||||
{{ loading ? 'Mengirim...' : 'Kirim Pesanan' }}
|
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button @click="konfirmasi"
|
||||||
type="button"
|
class="bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg transition">
|
||||||
@click="resetForm"
|
Konfirmasi
|
||||||
class="px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-lg hover:bg-gray-50 transition duration-200"
|
|
||||||
>
|
|
||||||
Reset
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const formData = ref({
|
const router = useRouter()
|
||||||
|
|
||||||
|
const form = ref({
|
||||||
nama_pemesan: '',
|
nama_pemesan: '',
|
||||||
email: '',
|
email: '',
|
||||||
no_telepon: '',
|
no_tlpn: '',
|
||||||
nama_lengkap: '',
|
form: {
|
||||||
nama_panggilan: '',
|
|
||||||
nama_bapak: '',
|
|
||||||
nama_ibu: '',
|
|
||||||
umur_yang_dirayakan: null,
|
|
||||||
anak_ke: null,
|
|
||||||
instagram: '',
|
|
||||||
facebook: '',
|
|
||||||
twitter: '',
|
|
||||||
hari_tanggal_acara: '',
|
|
||||||
waktu: '',
|
|
||||||
alamat: '',
|
|
||||||
link_gmaps: '',
|
|
||||||
say_something: '',
|
|
||||||
rekening_1: '',
|
|
||||||
rekening_2: '',
|
|
||||||
rekening_3: '',
|
|
||||||
foto_1: null,
|
|
||||||
foto_2: null,
|
|
||||||
foto_3: null,
|
|
||||||
foto_4: null,
|
|
||||||
foto_5: null,
|
|
||||||
link_music: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
|
|
||||||
const handleFileUpload = (event, fieldName) => {
|
|
||||||
const file = event.target.files[0]
|
|
||||||
if (file) {
|
|
||||||
formData.value[fieldName] = file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitForm = async () => {
|
|
||||||
loading.value = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
const formDataToSend = new FormData()
|
|
||||||
|
|
||||||
// Append semua data ke FormData
|
|
||||||
Object.keys(formData.value).forEach(key => {
|
|
||||||
if (formData.value[key] !== null && formData.value[key] !== '') {
|
|
||||||
formDataToSend.append(key, formData.value[key])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Kirim ke API Laravel
|
|
||||||
const response = await $fetch('/api/orders/ulang-tahun-premium', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formDataToSend
|
|
||||||
})
|
|
||||||
|
|
||||||
alert('Pesanan berhasil dikirim!')
|
|
||||||
resetForm()
|
|
||||||
|
|
||||||
// Redirect atau tindakan lainnya
|
|
||||||
// navigateTo('/success')
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error:', error)
|
|
||||||
alert('Terjadi kesalahan saat mengirim pesanan')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const resetForm = () => {
|
|
||||||
formData.value = {
|
|
||||||
nama_pemesan: '',
|
|
||||||
email: '',
|
|
||||||
no_telepon: '',
|
|
||||||
nama_lengkap: '',
|
nama_lengkap: '',
|
||||||
nama_panggilan: '',
|
nama_panggilan: '',
|
||||||
nama_bapak: '',
|
nama_bapak: '',
|
||||||
nama_ibu: '',
|
nama_ibu: '',
|
||||||
umur_yang_dirayakan: null,
|
umur_yang_dirayakan: '',
|
||||||
anak_ke: null,
|
anak_ke: '',
|
||||||
instagram: '',
|
instagram: '',
|
||||||
facebook: '',
|
facebook: '',
|
||||||
twitter: '',
|
twitter: '',
|
||||||
@ -436,29 +176,102 @@ const resetForm = () => {
|
|||||||
waktu: '',
|
waktu: '',
|
||||||
alamat: '',
|
alamat: '',
|
||||||
link_gmaps: '',
|
link_gmaps: '',
|
||||||
|
hitung_mundur: '',
|
||||||
|
link_live_streaming: '',
|
||||||
say_something: '',
|
say_something: '',
|
||||||
rekening_1: '',
|
rekening_1: '',
|
||||||
rekening_2: '',
|
rekening_2: '',
|
||||||
rekening_3: '',
|
rekening_3: '',
|
||||||
foto_1: null,
|
|
||||||
foto_2: null,
|
|
||||||
foto_3: null,
|
|
||||||
foto_4: null,
|
|
||||||
foto_5: null,
|
|
||||||
link_music: ''
|
link_music: ''
|
||||||
}
|
},
|
||||||
|
foto: []
|
||||||
// Reset file inputs
|
})
|
||||||
const fileInputs = document.querySelectorAll('input[type="file"]')
|
|
||||||
fileInputs.forEach(input => {
|
|
||||||
input.value = ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
const previews = ref([])
|
||||||
input:focus,
|
|
||||||
textarea:focus {
|
const handleFileChange = (e) => {
|
||||||
outline: none;
|
const files = Array.from(e.target.files)
|
||||||
|
const totalFiles = form.value.foto.length + files.length
|
||||||
|
|
||||||
|
if (totalFiles > 8) {
|
||||||
|
alert('Maksimal 8 foto!')
|
||||||
|
e.target.value = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
files.forEach(file => {
|
||||||
|
// Validate file size (2MB) and type
|
||||||
|
if (file.size > 2 * 1024 * 1024) {
|
||||||
|
alert(`File ${file.name} terlalu besar! Maksimal 2MB.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!['image/jpeg', 'image/png', 'image/jpg'].includes(file.type)) {
|
||||||
|
alert(`File ${file.name} harus berupa JPEG atau PNG!`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
form.value.foto.push(file)
|
||||||
|
previews.value.push(URL.createObjectURL(file))
|
||||||
|
})
|
||||||
|
|
||||||
|
e.target.value = ''
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
const removeFile = (index) => {
|
||||||
|
form.value.foto.splice(index, 1)
|
||||||
|
previews.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const konfirmasi = async () => {
|
||||||
|
try {
|
||||||
|
// Basic client-side validation
|
||||||
|
if (!form.value.nama_pemesan || !form.value.email) {
|
||||||
|
alert('Harap isi kolom wajib (Nama Pemesan, Email)!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = new FormData()
|
||||||
|
data.append('nama_pemesan', form.value.nama_pemesan)
|
||||||
|
data.append('email', form.value.email)
|
||||||
|
data.append('no_tlpn', form.value.no_tlpn)
|
||||||
|
data.append('template_slug', 'undangan-ulang-tahun-premium')
|
||||||
|
|
||||||
|
// Append form fields individually to ensure Laravel receives them as an array
|
||||||
|
for (const [key, value] of Object.entries(form.value.form)) {
|
||||||
|
data.append(`form[${key}]`, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
form.value.foto.forEach((file, index) => {
|
||||||
|
data.append(`foto[${index}]`, file)
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log([...data]) // untuk debugging
|
||||||
|
|
||||||
|
const res = await fetch('http://localhost:8000/api/pelanggans', {
|
||||||
|
method: 'POST',
|
||||||
|
body: data
|
||||||
|
})
|
||||||
|
|
||||||
|
const result = await res.json()
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
if (res.status === 422) {
|
||||||
|
const errors = result.errors || {}
|
||||||
|
const errorMessages = Object.values(errors).flat().join('\n')
|
||||||
|
throw new Error(errorMessages || result.message || 'Validasi gagal')
|
||||||
|
}
|
||||||
|
if (res.status === 404) {
|
||||||
|
throw new Error(result.message || 'Template tidak ditemukan')
|
||||||
|
}
|
||||||
|
throw new Error(result.message || 'Gagal mengirim data')
|
||||||
|
}
|
||||||
|
|
||||||
|
alert(result.message || 'Data berhasil disimpan!')
|
||||||
|
router.push('/')
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
alert('Terjadi kesalahan: ' + err.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const batal = () => router.back()
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user