Compare commits
2 Commits
f76c9a4987
...
024c9b243f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024c9b243f | ||
|
|
d68f171acf |
@ -16,7 +16,7 @@
|
|||||||
<div class="text-3xl">📅</div>
|
<div class="text-3xl">📅</div>
|
||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<h2 class="font-semibold text-red-400">Hari & Tanggal</h2>
|
<h2 class="font-semibold text-red-400">Hari & Tanggal</h2>
|
||||||
<p class="text-white font-medium">Rabu, 22 Oktober 2025</p>
|
<p class="text-white font-medium">{{ hari_tanggal_acara }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<div class="text-3xl">⏰</div>
|
<div class="text-3xl">⏰</div>
|
||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<h2 class="font-semibold text-blue-400">Waktu Acara</h2>
|
<h2 class="font-semibold text-blue-400">Waktu Acara</h2>
|
||||||
<p class="text-white font-medium">18.00</p>
|
<p class="text-white font-medium">{{ waktu }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -34,16 +34,18 @@
|
|||||||
<div class="text-3xl">📍</div>
|
<div class="text-3xl">📍</div>
|
||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<h2 class="font-semibold text-yellow-400">Lokasi Petualangan</h2>
|
<h2 class="font-semibold text-yellow-400">Lokasi Petualangan</h2>
|
||||||
<p class="text-white font-medium">jkbjkb</p>
|
<p class="text-white font-medium">{{ alamat }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tombol Maps -->
|
<!-- Tombol Maps -->
|
||||||
<button
|
<a
|
||||||
class="mt-4 bg-gray-800 text-white px-6 py-3 rounded-full font-semibold hover:bg-gray-700 transition-all duration-300 mx-auto flex items-center gap-2"
|
:href="link_gmaps"
|
||||||
|
target="_blank"
|
||||||
|
class="mt-4 bg-gradient-to-r from-green-600 to-green-700 text-white px-6 py-3 rounded-full font-semibold hover:from-green-700 hover:to-green-800 transition-all duration-300 mx-auto flex items-center gap-2 justify-center"
|
||||||
>
|
>
|
||||||
🗺️ Link Maps Menyusul
|
🗺️ Buka Google Maps
|
||||||
</button>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Catatan -->
|
<!-- Catatan -->
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
<p
|
<p
|
||||||
class="text-2xl font-bold mb-10 text-yellow-100 drop-shadow-md animate-fade-up-delay"
|
class="text-2xl font-bold mb-10 text-yellow-100 drop-shadow-md animate-fade-up-delay"
|
||||||
>
|
>
|
||||||
Bergabunglah dalam petualangan ulang tahun {{ childName }}! 🎭
|
Bergabunglah dalam petualangan ulang tahun ! 🎭
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- 🔘 BUTTON -->
|
<!-- 🔘 BUTTON -->
|
||||||
|
|||||||
@ -51,10 +51,8 @@
|
|||||||
Atas kehadiran dan doa <span class="text-yellow-300 font-semibold">spider-power</span> untuk
|
Atas kehadiran dan doa <span class="text-yellow-300 font-semibold">spider-power</span> untuk
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p
|
<p class="text-2xl sm:text-4xl font-bold text-yellow-300 bg-black/40 py-3 sm:py-4 px-6 sm:px-8 rounded-2xl border border-yellow-500/50">
|
||||||
class="text-2xl sm:text-4xl font-bold text-yellow-300 bg-black/40 py-3 sm:py-4 px-6 sm:px-8 rounded-2xl border border-yellow-500/50"
|
{{ childName }}
|
||||||
>
|
|
||||||
{{ childName || 'Spider-Kid' }}
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="bg-black/50 backdrop-blur-lg rounded-2xl p-6 border border-red-500/50">
|
<div class="bg-black/50 backdrop-blur-lg rounded-2xl p-6 border border-red-500/50">
|
||||||
|
|||||||
@ -89,7 +89,7 @@ import ThankYou from '~/components/templates/UltahStarter/ThankYou.vue'
|
|||||||
// Props dari induk
|
// Props dari induk
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: { type: Object, required: true },
|
data: { type: Object, required: true },
|
||||||
tamu: { type: Object, required: true } // Tambahkan props tamu
|
tamu: { type: Object, required: true }
|
||||||
})
|
})
|
||||||
|
|
||||||
// URL backend
|
// URL backend
|
||||||
@ -103,10 +103,10 @@ const messages = computed(() => props.data.rsvp || [])
|
|||||||
|
|
||||||
// ✅ Gambar galeri
|
// ✅ Gambar galeri
|
||||||
const galleryImages = computed(() => {
|
const galleryImages = computed(() => {
|
||||||
const f = formData.value
|
const fotos = formData.value.foto || []
|
||||||
return [f.foto_1, f.foto_2, f.foto_3, f.foto_4, f.foto_5]
|
return fotos
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.map(img => `${backendUrl}/storage/${img.replace(/^public\//, '')}`)
|
.map(img => `${backendUrl}/storage/${img}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 🌍 Navigasi section
|
// 🌍 Navigasi section
|
||||||
@ -139,25 +139,53 @@ const currentComponent = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 🎁 Props untuk tiap komponen
|
// Props untuk tiap komponen
|
||||||
const componentProps = computed(() => ({
|
const componentProps = computed(() => {
|
||||||
childName: formData.value.nama_panggilan,
|
const f = formData.value
|
||||||
guestName: route.query.guest || props.tamu.nama_tamu || 'Tamu Undangan',
|
|
||||||
age: formData.value.umur_yang_dirayakan,
|
// Foto anak (untuk Introduction & ThankYou)
|
||||||
childOrder: formData.value.anak_ke,
|
const childPhoto = f.foto?.[0]
|
||||||
parentsName: `${formData.value.nama_bapak} & ${formData.value.nama_ibu}`,
|
? `${backendUrl}/storage/${f.foto[0].replace(/^public\//, '')}`
|
||||||
childPhoto: formData.value.foto?.length
|
: null
|
||||||
? `${backendUrl}/storage/${formData.value.foto[0]}`
|
|
||||||
: null,
|
// Format tanggal: 2025-10-24 → Jumat, 24 Oktober 2025
|
||||||
hari_tanggal_acara: formData.value.hari_tanggal_acara,
|
const formatDate = (dateStr) => {
|
||||||
waktu: formData.value.waktu,
|
if (!dateStr) return 'Akan diumumkan'
|
||||||
alamat: formData.value.alamat,
|
try {
|
||||||
link_gmaps: formData.value.link_gmaps,
|
const d = new Date(dateStr)
|
||||||
hitung_mundur: formData.value.hitung_mundur,
|
return d.toLocaleDateString('id-ID', {
|
||||||
images: galleryImages.value,
|
weekday: 'long',
|
||||||
messages: messages.value,
|
day: 'numeric',
|
||||||
jsonData: formData.value
|
month: 'long',
|
||||||
}))
|
year: 'numeric'
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return dateStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
// === Introduction & ThankYou ===
|
||||||
|
childName: f.nama_lengkap || 'Spider Kid',
|
||||||
|
guestName: route.query.guest || props.tamu.nama_tamu || 'Tamu Undangan',
|
||||||
|
age: f.umur_yang_dirayakan,
|
||||||
|
childOrder: f.anak_ke,
|
||||||
|
parentsName: `${f.nama_bapak || 'Bapak'} & ${f.nama_ibu || 'Ibu'}`,
|
||||||
|
childPhoto,
|
||||||
|
|
||||||
|
// === Event ===
|
||||||
|
hari_tanggal_acara: formatDate(f.hari_tanggal_acara),
|
||||||
|
waktu: f.waktu,
|
||||||
|
alamat: f.alamat,
|
||||||
|
link_gmaps: f.link_gmaps || '#',
|
||||||
|
|
||||||
|
// === Gallery ===
|
||||||
|
images: galleryImages.value,
|
||||||
|
|
||||||
|
// === ThankYou ===
|
||||||
|
jsonData: f
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Debug log
|
// Debug log
|
||||||
import { watchEffect } from 'vue'
|
import { watchEffect } from 'vue'
|
||||||
|
|||||||
@ -1,121 +1,179 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="min-h-screen bg-gray-50 py-10 px-6">
|
<div class="min-h-screen bg-gray-50 py-10 px-6">
|
||||||
<div class="max-w-5xl mx-auto bg-white rounded-2xl shadow-lg p-8">
|
<div class="max-w-5xl mx-auto bg-white rounded-2xl shadow-lg p-8">
|
||||||
<h1 class="text-2xl font-bold text-center text-gray-800">
|
<h1 class="text-2xl font-bold text-center text-gray-800">
|
||||||
Form Undangan Ulang Tahun Starter
|
Form Undangan Ulang Tahun Starter
|
||||||
</h1>
|
</h1>
|
||||||
<p class="text-center text-gray-500 text-sm mb-8">
|
<p class="text-center text-gray-500 text-sm mb-8">
|
||||||
Isi semua data berikut dengan lengkap dan benar.
|
Isi semua data berikut dengan lengkap dan benar.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Data Pemesan -->
|
<!-- Data Pemesan -->
|
||||||
<section class="mb-8">
|
<section class="mb-8">
|
||||||
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">📋 Data Pemesan</h2>
|
<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-3 gap-4">
|
||||||
<input v-model="form.nama_pemesan" type="text" placeholder="Nama Pemesan"
|
<!-- Nama Pemesan -->
|
||||||
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 class="relative">
|
||||||
<input v-model="form.email" type="email" placeholder="Email"
|
<input v-model="form.nama_pemesan" type="text" placeholder=" " 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="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
<input v-model="form.no_tlpn" type="text" placeholder="No Telepon"
|
<label class="absolute left-1 top-0 text-gray-400 text-xs transition-all
|
||||||
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" />
|
peer-placeholder-shown:top-4 peer-placeholder-shown:left-2 peer-placeholder-shown:text-gray-400 peer-placeholder-shown:text-sm
|
||||||
</div>
|
peer-focus:top-0 peer-focus:left-1 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
</section>
|
peer-valid:top-0 peer-valid:left-1 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
Nama Pemesan
|
||||||
<!-- 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 class="grid gap-2">
|
|
||||||
<input v-model="form.form.nama_lengkap" placeholder="Nama Lengkap"
|
|
||||||
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" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Detail Acara -->
|
|
||||||
<section class="mb-8">
|
|
||||||
<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">
|
|
||||||
<input v-model="form.form.hari_tanggal_acara" type="date" placeholder="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" />
|
|
||||||
<input v-model="form.form.waktu" type="text" placeholder="Waktu"
|
|
||||||
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" />
|
|
||||||
<textarea v-model="form.form.alamat" rows="4" placeholder="Alamat"
|
|
||||||
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>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Foto Upload -->
|
|
||||||
<section class="mb-8">
|
|
||||||
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">🖼️ Galeri Foto</h2>
|
|
||||||
<div
|
|
||||||
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"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
id="gallery"
|
|
||||||
type="file"
|
|
||||||
multiple
|
|
||||||
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. 2, JPEG/PNG, maks. 2MB)</span>
|
|
||||||
</label>
|
</label>
|
||||||
<div v-else class="grid grid-cols-2 sm:grid-cols-2 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 < 2"
|
|
||||||
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>
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Tombol -->
|
<!-- Email -->
|
||||||
<div class="text-end mt-6">
|
<div class="relative">
|
||||||
<button @click="batal"
|
<input v-model="form.email" type="email" placeholder=" " required
|
||||||
class="bg-gray-600 text-white font-semibold px-6 py-2 rounded-lg transition mr-2">
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
Batal
|
<label class="absolute left-1 top-0 text-gray-400 text-xs transition-all
|
||||||
</button>
|
peer-placeholder-shown:top-4 peer-placeholder-shown:left-2 peer-placeholder-shown:text-gray-400 peer-placeholder-shown:text-sm
|
||||||
<button @click="konfirmasi"
|
peer-focus:top-0 peer-focus:left-1 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
class="bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg transition">
|
peer-valid:top-0 peer-valid:left-1 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
Konfirmasi
|
Email
|
||||||
</button>
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- No Telepon -->
|
||||||
|
<div class="relative">
|
||||||
|
<input v-model="form.no_tlpn" type="text" placeholder=" " required
|
||||||
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<label class="absolute left-1 top-0 text-gray-400 text-xs transition-all
|
||||||
|
peer-placeholder-shown:top-4 peer-placeholder-shown:left-2 peer-placeholder-shown:text-gray-400 peer-placeholder-shown:text-sm
|
||||||
|
peer-focus:top-0 peer-focus:left-1 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
|
peer-valid:top-0 peer-valid:left-1 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
No Telepon
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- 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 class="grid gap-4">
|
||||||
|
<template v-for="(field, i) in [
|
||||||
|
{ key: 'nama_lengkap', label: 'Nama Lengkap' },
|
||||||
|
{ key: 'nama_bapak', label: 'Nama Bapak' },
|
||||||
|
{ key: 'nama_ibu', label: 'Nama Ibu' },
|
||||||
|
{ key: 'umur_yang_dirayakan', label: 'Umur yang Dirayakan', type: 'number' },
|
||||||
|
{ key: 'anak_ke', label: 'Anak Ke', type: 'number' }
|
||||||
|
]" :key="i">
|
||||||
|
<div class="relative">
|
||||||
|
<input v-model="form.form[field.key]" :type="field.type || 'text'" required placeholder=" "
|
||||||
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<label class="absolute left-1 top-0 text-gray-400 text-xs transition-all
|
||||||
|
peer-placeholder-shown:top-4 peer-placeholder-shown:left-2 peer-placeholder-shown:text-gray-400 peer-placeholder-shown:text-sm
|
||||||
|
peer-focus:top-0 peer-focus:left-1 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
|
peer-valid:top-0 peer-valid:left-1 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
{{ field.label }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Detail Acara -->
|
||||||
|
<section class="mb-8">
|
||||||
|
<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="relative">
|
||||||
|
<input v-model="form.form.hari_tanggal_acara" type="date" required placeholder=" "
|
||||||
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<label class="absolute left-2 text-gray-400 text-xs transition-all
|
||||||
|
peer-placeholder-shown:top-4 peer-placeholder-shown:text-sm
|
||||||
|
peer-focus:top-0 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
|
peer-valid:top-0 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
Hari & Tanggal Acara
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative">
|
||||||
|
<input v-model="form.form.waktu" type="time" required placeholder=" "
|
||||||
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<label class="absolute left-2 text-gray-400 text-xs transition-all
|
||||||
|
peer-placeholder-shown:top-4 peer-placeholder-shown:text-sm
|
||||||
|
peer-focus:top-0 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
|
peer-valid:top-0 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
Waktu
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative md:col-span-2">
|
||||||
|
<textarea v-model="form.form.alamat" rows="4" required placeholder=" "
|
||||||
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition resize-none" />
|
||||||
|
<label class="absolute left-1 top-0 text-gray-400 text-xs transition-all
|
||||||
|
peer-placeholder-shown:top-4 peer-placeholder-shown:left-2 peer-placeholder-shown:text-gray-400 peer-placeholder-shown:text-sm
|
||||||
|
peer-focus:top-0 peer-focus:left-1 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
|
peer-valid:top-0 peer-valid:left-1 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
Alamat
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="relative md:col-span-2">
|
||||||
|
<input v-model="form.form.link_gmaps" type="text" required placeholder=" "
|
||||||
|
class="peer w-full border border-gray-300 rounded-lg px-2.5 pt-4 pb-1.5 text-sm focus:ring-2 focus:ring-blue-400 focus:border-blue-400 outline-none transition" />
|
||||||
|
<label class="absolute left-1 top-0 text-gray-400 text-xs transition-all
|
||||||
|
peer-placeholder-shown:top-4 peer-placeholder-shown:left-2 peer-placeholder-shown:text-gray-400 peer-placeholder-shown:text-sm
|
||||||
|
peer-focus:top-0 peer-focus:left-1 peer-focus:text-[10px] peer-focus:text-blue-500
|
||||||
|
peer-valid:top-0 peer-valid:left-1 peer-valid:text-[10px] peer-valid:text-gray-500">
|
||||||
|
Link Gmaps
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Foto Upload -->
|
||||||
|
<section class="mb-8">
|
||||||
|
<h2 class="font-semibold text-blue-600 mb-3 border-b pb-1">Galeri Foto</h2>
|
||||||
|
<div 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">
|
||||||
|
<input id="gallery" type="file" multiple 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. 2, JPEG/PNG, maks. 2MB)</span>
|
||||||
|
</label>
|
||||||
|
<div v-else class="grid grid-cols-2 sm:grid-cols-2 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">
|
||||||
|
X
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<label v-if="previews.length < 2" 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>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Tombol -->
|
||||||
|
<div class="text-end mt-6">
|
||||||
|
<button @click="batal"
|
||||||
|
class="bg-gray-600 text-white font-semibold px-6 py-2 rounded-lg transition mr-2">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button @click="konfirmasi"
|
||||||
|
class="bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg transition">
|
||||||
|
Konfirmasi
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import Swal from 'sweetalert2'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const ADMIN_WA = '62895333053398' // Ganti dengan nomor admin yang benar
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
nama_pemesan: '',
|
nama_pemesan: '',
|
||||||
@ -123,7 +181,10 @@ const form = ref({
|
|||||||
no_tlpn: '',
|
no_tlpn: '',
|
||||||
form: {
|
form: {
|
||||||
nama_lengkap: '',
|
nama_lengkap: '',
|
||||||
|
nama_bapak: '',
|
||||||
|
nama_ibu: '',
|
||||||
umur_yang_dirayakan: '',
|
umur_yang_dirayakan: '',
|
||||||
|
anak_ke: '',
|
||||||
hari_tanggal_acara: '',
|
hari_tanggal_acara: '',
|
||||||
waktu: '',
|
waktu: '',
|
||||||
alamat: ''
|
alamat: ''
|
||||||
@ -138,19 +199,18 @@ const handleFileChange = (e) => {
|
|||||||
const totalFiles = form.value.foto.length + files.length
|
const totalFiles = form.value.foto.length + files.length
|
||||||
|
|
||||||
if (totalFiles > 2) {
|
if (totalFiles > 2) {
|
||||||
alert('Maksimal 2 foto!')
|
Swal.fire('Oops!', 'Maksimal 2 foto!', 'warning')
|
||||||
e.target.value = ''
|
e.target.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
// Validate file size (2MB) and type
|
|
||||||
if (file.size > 2 * 1024 * 1024) {
|
if (file.size > 2 * 1024 * 1024) {
|
||||||
alert(`File ${file.name} terlalu besar! Maksimal 2MB.`)
|
Swal.fire('File Terlalu Besar!', `${file.name} melebihi 2MB`, 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!['image/jpeg', 'image/png', 'image/jpg'].includes(file.type)) {
|
if (!['image/jpeg', 'image/png', 'image/jpg'].includes(file.type)) {
|
||||||
alert(`File ${file.name} harus berupa JPEG atau PNG!`)
|
Swal.fire('Format Salah!', `${file.name} harus JPEG/PNG`, 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
form.value.foto.push(file)
|
form.value.foto.push(file)
|
||||||
@ -167,29 +227,26 @@ const removeFile = (index) => {
|
|||||||
|
|
||||||
const konfirmasi = async () => {
|
const konfirmasi = async () => {
|
||||||
try {
|
try {
|
||||||
// Basic client-side validation
|
// Validasi wajib
|
||||||
if (!form.value.nama_pemesan || !form.value.email) {
|
if (!form.value.nama_pemesan || !form.value.email) {
|
||||||
alert('Harap isi kolom wajib (Nama Pemesan, Email)!')
|
Swal.fire('Data Kurang!', 'Nama Pemesan dan Email wajib diisi!', 'warning')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = new FormData()
|
const data = new FormData()
|
||||||
data.append('nama_pemesan', form.value.nama_pemesan)
|
data.append('nama_pemesan', form.value.nama_pemesan)
|
||||||
data.append('email', form.value.email)
|
data.append('email', form.value.email)
|
||||||
data.append('no_tlpn', form.value.no_telepon)
|
data.append('no_tlpn', form.value.no_tlpn)
|
||||||
data.append('template_slug', 'undangan-ulang-tahun-starter')
|
data.append('template_slug', 'undangan-ulang-tahun-starter')
|
||||||
|
|
||||||
// Append form fields individually to ensure Laravel receives them as an array
|
|
||||||
for (const [key, value] of Object.entries(form.value.form)) {
|
for (const [key, value] of Object.entries(form.value.form)) {
|
||||||
data.append(`form[${key}]`, value)
|
data.append(`form[${key}]`, value || '-')
|
||||||
}
|
}
|
||||||
|
|
||||||
form.value.foto.forEach((file, index) => {
|
form.value.foto.forEach((file, index) => {
|
||||||
data.append(`foto[${index}]`, file)
|
data.append(`foto[${index}]`, file)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log([...data]) // untuk debugging
|
|
||||||
|
|
||||||
const res = await fetch('http://localhost:8000/api/pelanggans', {
|
const res = await fetch('http://localhost:8000/api/pelanggans', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data
|
body: data
|
||||||
@ -201,19 +258,73 @@ const konfirmasi = async () => {
|
|||||||
if (res.status === 422) {
|
if (res.status === 422) {
|
||||||
const errors = result.errors || {}
|
const errors = result.errors || {}
|
||||||
const errorMessages = Object.values(errors).flat().join('\n')
|
const errorMessages = Object.values(errors).flat().join('\n')
|
||||||
throw new Error(errorMessages || result.message || 'Validasi gagal')
|
throw new Error(errorMessages || 'Validasi gagal')
|
||||||
}
|
}
|
||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
throw new Error(result.message || 'Template tidak ditemukan')
|
throw new Error('Template tidak ditemukan')
|
||||||
}
|
}
|
||||||
throw new Error(result.message || 'Gagal mengirim data')
|
throw new Error(result.message || 'Gagal mengirim data')
|
||||||
}
|
}
|
||||||
|
|
||||||
alert(result.message || 'Data berhasil disimpan!')
|
// === SUKSES: Tampilkan SweetAlert ===
|
||||||
router.push('/')
|
await Swal.fire({
|
||||||
|
title: 'Berhasil!',
|
||||||
|
text: result.message || 'Data undangan kamu berhasil disimpan.',
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'Lanjut ke WhatsApp',
|
||||||
|
confirmButtonColor: '#2563eb',
|
||||||
|
background: '#f9fafb',
|
||||||
|
color: '#111827',
|
||||||
|
showClass: { popup: 'animate__animated animate__fadeInDown' },
|
||||||
|
hideClass: { popup: 'animate__animated animate__fadeOutUp' }
|
||||||
|
})
|
||||||
|
|
||||||
|
// === BUAT PESAN WHATSAPP ===
|
||||||
|
const f = form.value
|
||||||
|
const child = f.form
|
||||||
|
|
||||||
|
const message = `
|
||||||
|
Halo Admin,
|
||||||
|
Saya ingin membuat *Undangan Ulang Tahun Starter*
|
||||||
|
|
||||||
|
*Data Pemesan*
|
||||||
|
- Nama: ${f.nama_pemesan}
|
||||||
|
- Email: ${f.email}
|
||||||
|
- No. Telepon: ${f.no_tlpn}
|
||||||
|
|
||||||
|
*Data Anak*
|
||||||
|
- Nama Lengkap: ${child.nama_lengkap}
|
||||||
|
- Bapak: ${child.nama_bapak || '-'}
|
||||||
|
- Ibu: ${child.nama_ibu || '-'}
|
||||||
|
- Umur: ${child.umur_yang_dirayakan} tahun
|
||||||
|
- Anak ke: ${child.anak_ke || '-'}
|
||||||
|
|
||||||
|
*Detail Acara*
|
||||||
|
- Tanggal: ${child.hari_tanggal_acara}
|
||||||
|
- Waktu: ${child.waktu}
|
||||||
|
- Alamat: ${child.alamat}
|
||||||
|
|
||||||
|
Terima kasih
|
||||||
|
`.trim()
|
||||||
|
|
||||||
|
const encodedMsg = encodeURIComponent(message)
|
||||||
|
const waUrl = `https://wa.me/${ADMIN_WA}?text=${encodedMsg}`
|
||||||
|
|
||||||
|
// === BUKA WHATSAPP ===
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Membuka WhatsApp...',
|
||||||
|
text: 'Mohon tunggu sebentar',
|
||||||
|
timer: 1500,
|
||||||
|
timerProgressBar: true,
|
||||||
|
showConfirmButton: false,
|
||||||
|
willClose: () => {
|
||||||
|
window.open(waUrl, '_blank')
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
Swal.fire('Gagal', err.message, 'error')
|
||||||
alert('Terjadi kesalahan: ' + err.message)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -131,11 +131,11 @@ const fetchInvitation = async () => {
|
|||||||
const response = await $fetch(`${backendUrl}/api/pelanggans/code/${route.params.code}`)
|
const response = await $fetch(`${backendUrl}/api/pelanggans/code/${route.params.code}`)
|
||||||
|
|
||||||
console.log('✅ API response:', response)
|
console.log('✅ API response:', response)
|
||||||
|
console.log('🎫 tamuData:', tamuData.value)
|
||||||
// Validate response
|
// Validate response
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
throw new Error(response.message || 'Undangan tidak ditemukan')
|
throw new Error(response.message || 'Undangan tidak ditemukan')
|
||||||
console.log('🎫 tamuData:', tamuData.value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.data || !response.data.pelanggan) {
|
if (!response.data || !response.data.pelanggan) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user