Compare commits
2 Commits
024c9b243f
...
29de22c0d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29de22c0d0 | ||
|
|
6eaa82f652 |
@ -1,37 +1,55 @@
|
||||
<template>
|
||||
<div class="p-6 text-center max-w-2xl mx-auto relative">
|
||||
<h2 class="text-4xl font-bold bg-gradient-to-r from-orange-600 to-yellow-600 bg-clip-text text-transparent mb-8">
|
||||
💌 Buku Tamu 💌
|
||||
💌 Guest Book 💌
|
||||
</h2>
|
||||
|
||||
<!-- 🎈 Balon Kiri -->
|
||||
<img src="/balloon2.png" alt="Balloons Left"
|
||||
class="absolute w-32 md:w-40 -top-12 -left-7.5 animate-swing-top pointer-events-none select-none" />
|
||||
<img
|
||||
src="/balloon2.png"
|
||||
alt="Balloons Left"
|
||||
class="absolute w-32 md:w-40 -top-12 -left-7.5 animate-swing-top pointer-events-none select-none"
|
||||
/>
|
||||
|
||||
<!-- 🎈 Balon Kanan -->
|
||||
<img src="/balloon2.png" alt="Balloons Right"
|
||||
class="absolute w-32 md:w-40 -top-12 -right-10.5 animate-swing-top pointer-events-none select-none" />
|
||||
<img
|
||||
src="/balloon2.png"
|
||||
alt="Balloons Right"
|
||||
class="absolute w-32 md:w-40 -top-12 -right-10.5 animate-swing-top pointer-events-none select-none"
|
||||
/>
|
||||
|
||||
<!-- 💌 Form RSVP -->
|
||||
<div class="bg-white/80 backdrop-blur-lg rounded-2xl p-8 shadow-xl border border-yellow-100 mb-8 relative z-10">
|
||||
<div
|
||||
class="bg-white/80 backdrop-blur-lg rounded-2xl p-8 shadow-xl border border-yellow-100 mb-8 relative z-10"
|
||||
>
|
||||
<form @submit.prevent="submitMessage" class="space-y-4">
|
||||
<!-- Nama Tamu -->
|
||||
<div>
|
||||
<input v-model="form.name" type="text" :placeholder="guest || 'Nama Lengkap Tamu'"
|
||||
<input
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
:placeholder="guest || 'Nama Lengkap Tamu'"
|
||||
class="w-full p-4 border-2 border-yellow-300 rounded-2xl focus:ring-2 focus:ring-orange-400 focus:border-orange-400 transition-all duration-300"
|
||||
:disabled="!!guest" />
|
||||
:disabled="!!guest"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Pesan/Ucapan -->
|
||||
<div>
|
||||
<textarea v-model="form.message" rows="4" placeholder="Tulis ucapan dan harapan terbaik..."
|
||||
class="w-full p-4 border-2 border-yellow-300 rounded-2xl focus:ring-2 focus:ring-orange-400 focus:border-orange-400 transition-all duration-300 resize-none"></textarea>
|
||||
<textarea
|
||||
v-model="form.message"
|
||||
rows="4"
|
||||
placeholder="Tulis ucapan dan harapan terbaik..."
|
||||
class="w-full p-4 border-2 border-yellow-300 rounded-2xl focus:ring-2 focus:ring-orange-400 focus:border-orange-400 transition-all duration-300 resize-none"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- Status Kehadiran -->
|
||||
<div>
|
||||
<select v-model="form.attendance"
|
||||
class="w-full p-4 border-2 border-yellow-300 rounded-2xl focus:ring-2 focus:ring-orange-400 focus:border-orange-400 transition-all duration-300 appearance-none bg-white">
|
||||
<select
|
||||
v-model="form.attendance"
|
||||
class="w-full p-4 border-2 border-yellow-300 rounded-2xl focus:ring-2 focus:ring-orange-400 focus:border-orange-400 transition-all duration-300 appearance-none bg-white"
|
||||
>
|
||||
<option value="hadir">✅ Saya Hadir</option>
|
||||
<option value="tidak_hadir">❌ Tidak Hadir</option>
|
||||
<option value="mungkin">🤔 Mungkin Hadir</option>
|
||||
@ -39,13 +57,19 @@
|
||||
</div>
|
||||
|
||||
<!-- Error Message -->
|
||||
<div v-if="errorMessage" class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-xl">
|
||||
<div
|
||||
v-if="errorMessage"
|
||||
class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-xl"
|
||||
>
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<button type="submit" :disabled="!form.name.trim() || !form.message.trim() || submitLoading"
|
||||
class="bg-gradient-to-r from-orange-500 to-yellow-500 hover:from-orange-600 hover:to-yellow-600 text-white px-8 py-4 rounded-full font-semibold shadow-lg transition-all duration-300 transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed w-full text-lg">
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="!form.name.trim() || !form.message.trim() || submitLoading"
|
||||
class="bg-gradient-to-r from-orange-500 to-yellow-500 hover:from-orange-600 hover:to-yellow-600 text-white px-8 py-4 rounded-full font-semibold shadow-lg transition-all duration-300 transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed w-full text-lg"
|
||||
>
|
||||
✨ {{ submitLoading ? 'Mengirim...' : 'Kirim RSVP' }}
|
||||
</button>
|
||||
</form>
|
||||
@ -58,16 +82,17 @@
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-4 max-h-96 overflow-y-auto px-2 relative z-10">
|
||||
<div v-for="(msg, i) in messages" :key="msg.id || i"
|
||||
class="bg-white/80 backdrop-blur-md p-6 rounded-2xl shadow-lg border-l-4 border-orange-400 transform hover:scale-105 transition-all duration-300">
|
||||
<div class="flex items-start justify-between mb-2">
|
||||
<span class="font-bold text-orange-800 text-lg">{{ msg.nama }}</span>
|
||||
<span :class="getAttendanceClass(msg.status_kehadiran)" class="px-3 py-1 rounded-full text-sm font-semibold">
|
||||
<div class="space-y-4">
|
||||
<div v-for="msg in messages" :key="msg.id" class="bg-white rounded-xl shadow-md p-4 text-left">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<span class="font-bold text-orange-800">{{ msg.nama }}</span>
|
||||
<span :class="getAttendanceClass(msg.status_kehadiran)" class="text-sm px-2 py-1 rounded-lg">
|
||||
{{ formatAttendance(msg.status_kehadiran) }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-gray-700 text-left">{{ msg.pesan }}</p>
|
||||
<p class="text-gray-700">{{ msg.pesan }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="messages.length === 0" class="bg-white/60 p-8 rounded-2xl">
|
||||
<p class="text-gray-600 text-lg">
|
||||
@ -86,27 +111,20 @@ const route = useRoute();
|
||||
const config = useRuntimeConfig();
|
||||
const backendUrl = config.public.apiBaseUrl;
|
||||
const invitationCode = route.params.code || '';
|
||||
const guest = route.query.guest
|
||||
const guest = route.query.code
|
||||
|
||||
|
||||
const messages = ref([]);
|
||||
const form = ref({ name: '', message: '', attendance: 'hadir' });
|
||||
|
||||
|
||||
// Fungsi untuk mengambil daftar RSVP dari backend
|
||||
const fetchMessages = async () => {
|
||||
try {
|
||||
const response = await fetch(`${backendUrl}/api/rsvp/${invitationCode}`);
|
||||
if (!response.ok) throw new Error('Gagal mengambil data RSVP');
|
||||
|
||||
const data = await response.json();
|
||||
messages.value = data.data || [];
|
||||
} catch (error) {
|
||||
console.error('Error mengambil RSVP:', error);
|
||||
alert('Terjadi kesalahan saat mengambil data RSVP.');
|
||||
const props = defineProps({
|
||||
messages: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: () => []
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
const messages = ref([...props.messages])
|
||||
|
||||
|
||||
const form = ref({ name: '', message: '', attendance: 'hadir' });
|
||||
|
||||
// Fungsi untuk mengirim data RSVP ke backend
|
||||
const submitMessage = async () => {
|
||||
@ -123,6 +141,7 @@ const submitMessage = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('POST to:', `${backendUrl}/api/rsvp/${invitationCode}`, payload)
|
||||
const response = await fetch(`${backendUrl}/api/rsvp/${invitationCode}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -131,18 +150,19 @@ const submitMessage = async () => {
|
||||
body: JSON.stringify({
|
||||
nama: form.value.name,
|
||||
pesan: form.value.message,
|
||||
status_kehadiran: form.value.attendance,
|
||||
status_kehadiran: form.value.attendance,
|
||||
}),
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Gagal menyimpan RSVP');
|
||||
if (!response.ok) {
|
||||
console.log(response)
|
||||
throw new Error(`Gagal menyimpan RSVP,${response.errors}`);
|
||||
}
|
||||
|
||||
|
||||
const result = await response.json();
|
||||
messages.value.push(result.data); // Tambahkan RSVP baru ke daftar
|
||||
form.value = { name: '', message: '', attendance: 'yes' }; // Reset form
|
||||
form.value = { name: '', message: '', attendance: 'hadir' };
|
||||
alert(result.message); // Tampilkan pesan sukses dari backend
|
||||
} catch (error) {
|
||||
console.error('Error menyimpan RSVP:', error);
|
||||
@ -153,11 +173,11 @@ const submitMessage = async () => {
|
||||
// Fungsi untuk mengatur kelas CSS berdasarkan status kehadiran
|
||||
const getAttendanceClass = (attendance) => {
|
||||
switch (attendance) {
|
||||
case 'yes':
|
||||
case 'iya':
|
||||
return 'bg-green-100 text-green-700';
|
||||
case 'no':
|
||||
case 'tidak':
|
||||
return 'bg-red-100 text-red-700';
|
||||
case 'maybe':
|
||||
case 'mungkin':
|
||||
return 'bg-yellow-100 text-yellow-700';
|
||||
default:
|
||||
return 'bg-gray-100 text-gray-700';
|
||||
@ -167,33 +187,25 @@ const getAttendanceClass = (attendance) => {
|
||||
// Fungsi untuk memformat teks kehadiran
|
||||
const formatAttendance = (attendance) => {
|
||||
switch (attendance) {
|
||||
case 'yes':
|
||||
case 'iya':
|
||||
return 'Hadir';
|
||||
case 'no':
|
||||
case 'tidak':
|
||||
return 'Tidak Hadir';
|
||||
case 'maybe':
|
||||
case 'mungkin':
|
||||
return 'Mungkin';
|
||||
default:
|
||||
return attendance;
|
||||
}
|
||||
};
|
||||
|
||||
// Panggil fetchMessages saat komponen dimuat
|
||||
onMounted(() => {
|
||||
fetchMessages();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@keyframes swing-top {
|
||||
0% {
|
||||
transform: rotate(2deg);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: rotate(-2deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(2deg);
|
||||
}
|
||||
@ -202,6 +214,5 @@ onMounted(() => {
|
||||
.animate-swing-top {
|
||||
animation: swing-top 4s ease-in-out infinite;
|
||||
transform-origin: bottom center;
|
||||
/* ✅ Balon berayun dari bawah (tali diam) */
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@ -9,81 +9,58 @@
|
||||
</div>
|
||||
|
||||
<!-- Navigation -->
|
||||
<nav
|
||||
v-if="currentSection !== 'landing'"
|
||||
class="fixed top-6 left-1/2 transform -translate-x-1/2 z-20 animate-fade-in"
|
||||
>
|
||||
<nav v-if="currentSection !== 'landing'"
|
||||
class="fixed top-6 left-1/2 transform -translate-x-1/2 z-20 animate-fade-in">
|
||||
<ul
|
||||
class="flex space-x-2 bg-white/70 backdrop-blur-lg px-6 py-3 rounded-full shadow-lg text-sm font-semibold text-gray-800 border border-yellow-200"
|
||||
>
|
||||
<li><button @click="switchSection('introduction')" :class="navClass('introduction')" class="px-3 py-1 rounded-full transition-all duration-300">Intro</button></li>
|
||||
<li><button @click="switchSection('event')" :class="navClass('event')" class="px-3 py-1 rounded-full transition-all duration-300">Event</button></li>
|
||||
<li><button @click="switchSection('gallery')" :class="navClass('gallery')" class="px-3 py-1 rounded-full transition-all duration-300">Galeri</button></li>
|
||||
<li><button @click="switchSection('guestbook')" :class="navClass('guestbook')" class="px-3 py-1 rounded-full transition-all duration-300">Buku Tamu</button></li>
|
||||
<li><button @click="switchSection('thanks')" :class="navClass('thanks')" class="px-3 py-1 rounded-full transition-all duration-300">Terima Kasih</button></li>
|
||||
class="flex space-x-2 bg-white/70 backdrop-blur-lg px-6 py-3 rounded-full shadow-lg text-sm font-semibold text-gray-800 border border-yellow-200">
|
||||
<li><button @click="switchSection('introduction')" :class="navClass('introduction')"
|
||||
class="px-3 py-1 rounded-full transition-all duration-300">Intro</button></li>
|
||||
<li><button @click="switchSection('event')" :class="navClass('event')"
|
||||
class="px-3 py-1 rounded-full transition-all duration-300">Event</button></li>
|
||||
<li><button @click="switchSection('gallery')" :class="navClass('gallery')"
|
||||
class="px-3 py-1 rounded-full transition-all duration-300">Galeri</button></li>
|
||||
<li><button @click="switchSection('guestbook')" :class="navClass('guestbook')"
|
||||
class="px-3 py-1 rounded-full transition-all duration-300">Guest Book</button></li>
|
||||
<li><button @click="switchSection('thanks')" :class="navClass('thanks')"
|
||||
class="px-3 py-1 rounded-full transition-all duration-300">Terima Kasih</button></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- Tombol Musik -->
|
||||
<div class="fixed bottom-6 left-6 z-30" v-if="currentSection !== 'landing'">
|
||||
<button
|
||||
@click="toggleMusic"
|
||||
class="bg-gradient-to-r from-yellow-500 to-orange-500 hover:from-yellow-600 hover:to-orange-600 p-4 rounded-full text-white shadow-xl transition-all duration-300 hover:scale-110 hover:shadow-2xl"
|
||||
>
|
||||
<button @click="toggleMusic"
|
||||
class="bg-gradient-to-r from-yellow-500 to-orange-500 hover:from-yellow-600 hover:to-orange-600 p-4 rounded-full text-white shadow-xl transition-all duration-300 hover:scale-110 hover:shadow-2xl">
|
||||
<span class="text-lg">{{ isPlaying ? '⏸️' : '▶️' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Main Section -->
|
||||
<main
|
||||
class="relative z-10 min-h-screen flex items-center justify-center p-4 transition-all duration-700 ease-in-out"
|
||||
>
|
||||
class="relative z-10 min-h-screen flex items-center justify-center p-4 transition-all duration-700 ease-in-out">
|
||||
<!-- Landing -->
|
||||
<Landing
|
||||
v-if="currentSection === 'landing' && tamu"
|
||||
:childName="formData.nama_panggilan"
|
||||
<Landing v-if="currentSection === 'landing' && tamu" :childName="formData.nama_panggilan"
|
||||
:guestName="route.query.guest || tamu.nama_tamu || 'Tamu Undangan'"
|
||||
@open-invitation="switchSection('introduction')"
|
||||
@toggle-music="toggleMusic"
|
||||
/>
|
||||
@open-invitation="switchSection('introduction')" @toggle-music="toggleMusic" />
|
||||
|
||||
<!-- Introduction -->
|
||||
<Introduction
|
||||
v-if="currentSection === 'introduction'"
|
||||
:age="formData.umur_yang_dirayakan"
|
||||
:childName="formData.nama_lengkap"
|
||||
:childOrder="formData.anak_ke"
|
||||
<Introduction v-if="currentSection === 'introduction'" :age="formData.umur_yang_dirayakan"
|
||||
:childName="formData.nama_lengkap" :childOrder="formData.anak_ke"
|
||||
:parentsName="`${formData.nama_bapak} & ${formData.nama_ibu}`"
|
||||
:childPhoto="formData.foto && formData.foto.length ? `${backendUrl}/storage/${formData.foto[0]}` : null"
|
||||
/>
|
||||
:childPhoto="formData.foto && formData.foto.length ? `${backendUrl}/storage/${formData.foto[0]}` : null" />
|
||||
|
||||
<!-- Event -->
|
||||
<Event
|
||||
v-if="currentSection === 'event'"
|
||||
:hari_tanggal_acara="formData.hari_tanggal_acara"
|
||||
:waktu="formData.waktu"
|
||||
:alamat="formData.alamat"
|
||||
:link_gmaps="formData.link_gmaps"
|
||||
:hitung_mundur="formData.hitung_mundur"
|
||||
/>
|
||||
<Event v-if="currentSection === 'event'" :hari_tanggal_acara="formData.hari_tanggal_acara" :waktu="formData.waktu"
|
||||
:alamat="formData.alamat" :link_gmaps="formData.link_gmaps" :hitung_mundur="formData.hitung_mundur" />
|
||||
|
||||
<!-- Gallery -->
|
||||
<Gallery v-if="currentSection === 'gallery'" :images="galleryImages" />
|
||||
|
||||
<!-- Guest Book -->
|
||||
<GuestBook
|
||||
v-if="currentSection === 'guestbook'"
|
||||
:guestName="route.query.guest || tamu.nama_tamu || 'Tamu Undangan'"
|
||||
:messages="messages"
|
||||
@addMessage="addMessage"
|
||||
/>
|
||||
<GuestBook v-if="currentSection === 'guestbook'" :guestName="tamu.nama_tamu || 'Tamu Undangan'" :messages="messages"
|
||||
@addMessage="addMessage" />
|
||||
|
||||
<!-- Thank You -->
|
||||
<ThankYou
|
||||
v-if="currentSection === 'thanks'"
|
||||
:childName="formData.nama_panggilan"
|
||||
:jsonData="formData"
|
||||
/>
|
||||
<ThankYou v-if="currentSection === 'thanks'" :childName="formData.nama_panggilan" :jsonData="formData" />
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
@ -113,7 +90,7 @@ const route = useRoute()
|
||||
|
||||
// Data dari backend
|
||||
const formData = computed(() => props.data.form || {})
|
||||
const messages = computed(() => props.data.rsvp || [])
|
||||
const messages = ref(props.data.rsvp || [])
|
||||
|
||||
// Galeri gambar (support foto array atau field lama)
|
||||
const galleryImages = computed(() => {
|
||||
@ -167,8 +144,15 @@ button {
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from { opacity: 0; transform: translateY(-10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-fade-in {
|
||||
|
||||
@ -12,12 +12,41 @@
|
||||
<section class="mb-8">
|
||||
<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">
|
||||
<input v-model="form.nama_pemesan" type="text" placeholder="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" />
|
||||
<input v-model="form.email" type="email" placeholder="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" />
|
||||
<input v-model="form.no_tlpn" type="text" placeholder="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" />
|
||||
<!-- Nama Pemesan -->
|
||||
<div class="relative">
|
||||
<input v-model="form.nama_pemesan" 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">
|
||||
Nama Pemesan
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Email -->
|
||||
<div class="relative">
|
||||
<input v-model="form.email" type="email" 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">
|
||||
Email
|
||||
</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>
|
||||
</section>
|
||||
|
||||
@ -25,19 +54,25 @@
|
||||
<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.nama_panggilan" placeholder="Nama Panggilan"
|
||||
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.nama_bapak" placeholder="Nama Bapak"
|
||||
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.nama_ibu" placeholder="Nama Ibu"
|
||||
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 class="grid gap-4">
|
||||
<template v-for="(field, i) in [
|
||||
{ key: 'nama_lengkap', label: 'Nama Lengkap' },
|
||||
{ key: 'nama_panggilan', label: 'Nama Panggilan' },
|
||||
{ key: 'nama_bapak', label: 'Nama Bapak' },
|
||||
{ key: 'nama_ibu', label: 'Nama Ibu' },
|
||||
{ key: 'umur_yang_dirayakan', label: 'Umur Yang Dirayakan', 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>
|
||||
@ -46,29 +81,108 @@
|
||||
<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>
|
||||
<input v-model="form.form.link_gmaps" type="text" placeholder="Link Gmaps"
|
||||
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"
|
||||
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.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 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 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 Acara
|
||||
</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" />
|
||||
<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 class="relative">
|
||||
<input v-model="form.form.hitung_mundur_mulai" type="datetime-local" 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">
|
||||
Hitung Mundur Mulai
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="relative">
|
||||
<input v-model="form.form.hitung_mundur_selesai" type="datetime-local" 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">
|
||||
Hitung Mundur Selesai
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Pesan & Rekening -->
|
||||
<section class="mb-8">
|
||||
<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..."
|
||||
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>
|
||||
|
||||
<!-- Say Something -->
|
||||
<section class="mb-8">
|
||||
<textarea v-model="form.form.say_something" rows="4" placeholder="Kata-kata spesial atau pesan untuk tamu..."
|
||||
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>
|
||||
</section>
|
||||
|
||||
<div class="grid md:grid-cols-1 gap-4 mt-4">
|
||||
<input v-model="form.form.rekening_1" placeholder="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" />
|
||||
<input v-model="form.form.link_music" placeholder="Link Music (opsional)"
|
||||
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.form.rekening_1" 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">
|
||||
|
||||
Rekening 1
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid md:grid-cols-1 gap-4 mt-4">
|
||||
<div class="relative">
|
||||
<input v-model="form.form.link_music" 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">
|
||||
Link Music (opsional)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -76,43 +190,23 @@
|
||||
<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"
|
||||
/>
|
||||
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. 4, JPEG/PNG, maks. 2MB)</span>
|
||||
</label>
|
||||
<div v-else class="grid grid-cols-2 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)"
|
||||
<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"
|
||||
>
|
||||
title="Hapus foto">
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<label
|
||||
v-if="previews.length < 4"
|
||||
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"
|
||||
>
|
||||
<label v-if="previews.length < 4" 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>
|
||||
@ -121,12 +215,10 @@
|
||||
|
||||
<!-- 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">
|
||||
<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">
|
||||
<button @click="konfirmasi" class="bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg transition">
|
||||
Konfirmasi
|
||||
</button>
|
||||
</div>
|
||||
@ -137,8 +229,10 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import Swal from 'sweetalert2'
|
||||
|
||||
const router = useRouter()
|
||||
const ADMIN_WA = '62895333053398'
|
||||
|
||||
const form = ref({
|
||||
nama_pemesan: '',
|
||||
@ -154,7 +248,8 @@ const form = ref({
|
||||
waktu: '',
|
||||
alamat: '',
|
||||
link_gmaps: '',
|
||||
hitung_mundur: '',
|
||||
hitung_mundur_mulai: '',
|
||||
hitung_mundur_selesai: '',
|
||||
say_something: '',
|
||||
rekening_1: '',
|
||||
link_music: ''
|
||||
@ -175,7 +270,6 @@ const handleFileChange = (e) => {
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
// Validate file size (2MB) and type
|
||||
if (file.size > 2 * 1024 * 1024) {
|
||||
alert(`File ${file.name} terlalu besar! Maksimal 2MB.`)
|
||||
return
|
||||
@ -187,7 +281,6 @@ const handleFileChange = (e) => {
|
||||
form.value.foto.push(file)
|
||||
previews.value.push(URL.createObjectURL(file))
|
||||
})
|
||||
|
||||
e.target.value = ''
|
||||
}
|
||||
|
||||
@ -198,7 +291,6 @@ const removeFile = (index) => {
|
||||
|
||||
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
|
||||
@ -207,10 +299,9 @@ const konfirmasi = async () => {
|
||||
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_telepon)
|
||||
data.append('no_tlpn', form.value.no_tlpn)
|
||||
data.append('template_slug', 'undangan-ulang-tahun-basic')
|
||||
|
||||
// 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)
|
||||
}
|
||||
@ -240,11 +331,70 @@ const konfirmasi = async () => {
|
||||
throw new Error(result.message || 'Gagal mengirim data')
|
||||
}
|
||||
|
||||
alert(result.message || 'Data berhasil disimpan!')
|
||||
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'
|
||||
}
|
||||
})
|
||||
|
||||
const f = form.value
|
||||
const child = f.form
|
||||
|
||||
const message = `
|
||||
Halo Admin 👋,
|
||||
Saya ingin membuat *Undangan Ulang Tahun Basic* 🎂
|
||||
|
||||
📋 *Data Pemesan*
|
||||
- Nama: ${f.nama_pemesan}
|
||||
- Email: ${f.email}
|
||||
- No. Telepon: ${f.no_tlpn}
|
||||
|
||||
🎉 *Data Anak*
|
||||
- Nama Lengkap: ${child.nama_lengkap}
|
||||
- Nama Panggilan: ${child.nama_panggilan}
|
||||
- Umur: ${child.umur_yang_dirayakan} tahun
|
||||
- Bapak: ${child.nama_bapak}
|
||||
- Ibu: ${child.nama_ibu}
|
||||
|
||||
📅 *Detail Acara*
|
||||
- Tanggal: ${child.hari_tanggal_acara}
|
||||
- Waktu: ${child.waktu}
|
||||
- Alamat: ${child.alamat}
|
||||
- Link Gmaps: ${child.link_gmaps || '-'}
|
||||
|
||||
💌 *Pesan Tambahan*
|
||||
${child.say_something || '-'}
|
||||
|
||||
Terima kasih 🙏
|
||||
`
|
||||
|
||||
const encodedMsg = encodeURIComponent(message)
|
||||
const waUrl = `https://wa.me/${ADMIN_WA}?text=${encodedMsg}`
|
||||
|
||||
Swal.fire({
|
||||
title: 'Membuka WhatsApp...',
|
||||
text: 'Mohon tunggu sebentar ⏳',
|
||||
timer: 1500,
|
||||
timerProgressBar: true,
|
||||
showConfirmButton: false,
|
||||
willClose: () => {
|
||||
window.open(waUrl, '_blank')
|
||||
router.push('/')
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
alert('Terjadi kesalahan: ' + err.message)
|
||||
Swal.fire('❌ Gagal', err.message, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user