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(() =>
diff --git a/proyek-frontend/app/components/template-page/CategorySelection.vue b/proyek-frontend/app/components/template-page/CategorySelection.vue index 87db324..098045f 100644 --- a/proyek-frontend/app/components/template-page/CategorySelection.vue +++ b/proyek-frontend/app/components/template-page/CategorySelection.vue @@ -114,12 +114,11 @@
- - + Order @@ -244,6 +243,7 @@ const templatesWithFeatures = computed(() => (templatesRaw.value || []).map((t, index) => ({ id: t.id, nama: t.nama_template, + slug: t.slug, harga: t.harga, foto: t.foto || '/logo1.png', kategori: t.kategori, diff --git a/proyek-frontend/app/components/template-page/TemplateGrid.vue b/proyek-frontend/app/components/template-page/TemplateGrid.vue index e4bfd8c..3edf89c 100644 --- a/proyek-frontend/app/components/template-page/TemplateGrid.vue +++ b/proyek-frontend/app/components/template-page/TemplateGrid.vue @@ -73,11 +73,11 @@
- Preview - - + Order diff --git a/proyek-frontend/app/pages/preview/[id].vue b/proyek-frontend/app/pages/preview/[id].vue index df23d34..1c7fda5 100644 --- a/proyek-frontend/app/pages/preview/[id].vue +++ b/proyek-frontend/app/pages/preview/[id].vue @@ -1,21 +1,321 @@ + +