diff --git a/backend-baru/app/Http/Controllers/Api/TemplateApiController.php b/backend-baru/app/Http/Controllers/Api/TemplateApiController.php index d905878..bd3baae 100644 --- a/backend-baru/app/Http/Controllers/Api/TemplateApiController.php +++ b/backend-baru/app/Http/Controllers/Api/TemplateApiController.php @@ -30,38 +30,69 @@ class TemplateApiController extends Controller // Ambil detail template tertentu public function show(Template $template) { + // Jika ada query ?with_dummy=true, tambahkan dummy value + $formData = $this->addDummyValues($template->form ?? []); + return response()->json([ 'id' => $template->id, 'nama_template' => $template->nama_template, + 'slug' => $template->slug, 'harga' => $template->harga, 'paket' => $template->paket, 'kategori' => $template->kategori ? $template->kategori->nama : null, + 'form' => $formData, 'foto' => $template->foto ? asset('storage/' . $template->foto) : null, ]); } - public function getByCategory($id) -{ - $templates = Template::with('fiturs', 'kategori') - ->where('kategori_id', $id) - ->get(); - $transformed = $templates->map(function($template) { - return [ - 'id' => $template->id, - 'nama_template' => $template->nama_template, - 'harga' => $template->harga, - 'paket' => $template->paket, - 'kategori' => $template->kategori ? [ - 'id' => $template->kategori->id, - 'nama' => $template->kategori->nama - ] : null, - 'foto' => $template->foto ? asset('storage/' . $template->foto) : null, - 'fiturs' => $template->fiturs ?? [], + private function addDummyValues(array $form) + { + if (empty($form['fields'])) { + return $form; + } + + // Aturan dummy value berdasarkan tipe + $dummyValues = [ + 'text' => 'XXXXX XXXX', + 'email' => 'example@domain.com', + 'textarea' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + 'date' => '2025-12-01', + 'datetime-local' => '2025-12-01T09:00', + 'number' => 17, + 'file' => null, + 'url' => 'https://example.com', ]; - }); - - return response()->json($transformed); -} - + // Map field untuk menambahkan dummy value + $form['fields'] = array_map(function ($field) use ($dummyValues) { + $field['value'] = $dummyValues[$field['type']] ?? 'Unknown Type'; + return $field; + }, $form['fields']); + + return $form; + } + + public function getByCategory($id) + { + $templates = Template::with('fiturs', 'kategori') + ->where('kategori_id', $id) + ->get(); + + $transformed = $templates->map(function ($template) { + return [ + 'id' => $template->id, + 'nama_template' => $template->nama_template, + 'harga' => $template->harga, + 'paket' => $template->paket, + 'kategori' => $template->kategori ? [ + 'id' => $template->kategori->id, + 'nama' => $template->kategori->nama + ] : null, + 'foto' => $template->foto ? asset('storage/' . $template->foto) : null, + 'fiturs' => $template->fiturs ?? [], + ]; + }); + + return response()->json($transformed); + } } diff --git a/proyek-frontend/app/components/landing-page/featuredtemplates.vue b/proyek-frontend/app/components/landing-page/featuredtemplates.vue index 0a5300a..5df72f5 100644 --- a/proyek-frontend/app/components/landing-page/featuredtemplates.vue +++ b/proyek-frontend/app/components/landing-page/featuredtemplates.vue @@ -2,7 +2,7 @@ import { ref, computed } from 'vue' // ID template yang mau ditampilkan -const selectedIds = [1, 3, 4, 5, 6, 7, 8, 9] +const selectedIds = [3, 5, 7] // State dropdown const openDropdownId = ref(null) @@ -174,6 +174,7 @@ const templates = computed(() =>
Mode Preview
+ +Paket
+{{ data.paket }}
+Kategori
+{{ data.kategori }}
+Harga
++ Rp {{ parseFloat(data.harga).toLocaleString('id-ID') }} +
+Slug
++ {{ data.slug }} +
+Loading invitation...
+Undangan Tidak Ditemukan
+Maaf, undangan yang Anda cari tidak tersedia atau sudah tidak berlaku.
++ Template dengan slug {{ data.slug }} belum memiliki komponen khusus. + Berikut adalah tampilan preview data template. +
++ 💡 Komponen custom untuk template ini sedang dalam pengembangan +
+