diff --git a/backend-baru/app/Http/Controllers/Api/TemplateApiController.php b/backend-baru/app/Http/Controllers/Api/TemplateApiController.php index bd3baae..822e96f 100644 --- a/backend-baru/app/Http/Controllers/Api/TemplateApiController.php +++ b/backend-baru/app/Http/Controllers/Api/TemplateApiController.php @@ -14,13 +14,13 @@ class TemplateApiController extends Controller $transformedTemplates = $templates->map(function ($template) { return [ - 'id' => $template->id, + 'id' => $template->id, 'nama_template' => $template->nama_template, - 'slug' => $template->slug, - 'harga' => $template->harga, - 'paket' => $template->paket, - 'kategori' => $template->kategori ? $template->kategori->nama : null, - 'foto' => $template->foto ? asset('storage/' . $template->foto) : null, + 'slug' => $template->slug, + 'harga' => $template->harga, + 'paket' => $template->paket, + 'kategori' => $template->kategori ? $template->kategori->nama : null, + 'foto' => $template->foto ? asset('storage/' . $template->foto) : null, ]; }); @@ -34,14 +34,14 @@ class TemplateApiController extends Controller $formData = $this->addDummyValues($template->form ?? []); return response()->json([ - 'id' => $template->id, + '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, + '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, ]); } @@ -74,22 +74,23 @@ class TemplateApiController extends Controller public function getByCategory($id) { - $templates = Template::with('fiturs', 'kategori') - ->where('kategori_id', $id) - ->get(); + $templates = Template::with('kategori') + ->where('kategori_id', $id) + ->get(); + $transformed = $templates->map(function ($template) { return [ - 'id' => $template->id, + 'id' => $template->id, 'nama_template' => $template->nama_template, - 'harga' => $template->harga, - 'paket' => $template->paket, - 'kategori' => $template->kategori ? [ + '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 ?? [], + 'foto' => $template->foto ? asset('storage/' . $template->foto) : null, + 'fiturs' => $template->fiturs ?? [], ]; }); diff --git a/proyek-frontend/app/components/landing-page/featuredtemplates.vue b/proyek-frontend/app/components/landing-page/featuredtemplates.vue index 5df72f5..fc504b6 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 = [3, 5, 7] +const selectedIds = [3, 6, 9] // State dropdown const openDropdownId = ref(null) @@ -88,6 +88,7 @@ const formMapping = { // Fetch data template dari backend (nama_template, harga, kategori, foto) const { data: templatesData, error } = await useFetch('http://localhost:8000/api/templates') +console.log(templatesData.value) // Mapping template: gabungkan backend + paket & fitur hardcode const paketMapping = { @@ -129,11 +130,12 @@ const templates = computed(() => -
+
- + +
diff --git a/proyek-frontend/app/components/template-page/CategorySelection.vue b/proyek-frontend/app/components/template-page/CategorySelection.vue index 3bf9268..b142f4a 100644 --- a/proyek-frontend/app/components/template-page/CategorySelection.vue +++ b/proyek-frontend/app/components/template-page/CategorySelection.vue @@ -14,7 +14,7 @@ Kembali ke Beranda
- +

Pilih Kategori Favoritmu @@ -29,27 +29,38 @@ Gagal memuat kategori.

- -
-
- -
-
-

{{ category.nama }}

-

- {{ category.deskripsi }} -

-
-
+ +
+
+ +
+
+

+ {{ category.nama }} +

+

+ {{ category.deskripsi }} +

+
+
-
- Belum ada kategori. -
+
+ Belum ada kategori. +
@@ -67,12 +78,14 @@ Belum ada template tersedia.
-
+
- + +
@@ -114,11 +127,12 @@
- +