fix kategori
This commit is contained in:
parent
28d3155070
commit
d2b2db90a6
@ -29,38 +29,28 @@
|
|||||||
Gagal memuat kategori.
|
Gagal memuat kategori.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Kategori Grid -->
|
<!-- Kategori Grid -->
|
||||||
<div
|
<div v-else-if="categories.length > 0" class="mt-12 flex flex-wrap justify-center gap-6">
|
||||||
v-else-if="categories.length > 0"
|
<div v-for="category in categories" :key="category.id + '-' + category.foto"
|
||||||
class="mt-12 flex flex-wrap justify-center gap-6"
|
@click="onCategoryClick(category)"
|
||||||
>
|
class="group cursor-pointer relative overflow-hidden rounded-lg shadow-lg hover:shadow-2xl transition-all duration-300 w-72">
|
||||||
<div
|
<img v-if="category.foto" :src="`http://localhost:8000${category.foto}`" :alt="category.nama"
|
||||||
v-for="category in categories"
|
class="w-full h-96 object-cover transition-transform duration-300 group-hover:scale-110">
|
||||||
:key="category.id + '-' + category.foto"
|
<div class="absolute inset-0 bg-gradient-to-t from-black/70 via-black/40 to-transparent"></div>
|
||||||
@click="onCategoryClick(category)"
|
<div class="absolute inset-0 flex flex-col justify-center items-start px-4 text-white">
|
||||||
class="group cursor-pointer relative overflow-hidden rounded-lg shadow-lg hover:shadow-2xl transition-all duration-300 w-72"
|
<h3 class="text-xl font-semibold mb-2">
|
||||||
>
|
{{ category.nama }}
|
||||||
<img
|
</h3>
|
||||||
v-if="category.foto"
|
<p class="text-lg font-normal leading-snug whitespace-normal break-words max-w-[90%]">
|
||||||
:src="`http://localhost:8000${category.foto}`"
|
{{ category.deskripsi }}
|
||||||
:alt="category.nama"
|
</p>
|
||||||
class="w-full h-96 object-cover transition-transform duration-300 group-hover:scale-110"
|
</div>
|
||||||
>
|
</div>
|
||||||
<div class="absolute inset-0 bg-gradient-to-t from-black/70 via-black/40 to-transparent"></div>
|
|
||||||
<div class="absolute inset-0 flex flex-col justify-center items-start px-4 text-white">
|
|
||||||
<h3 class="text-xl font-semibold mb-2">
|
|
||||||
{{ category.nama }}
|
|
||||||
</h3>
|
|
||||||
<p class="text-lg font-normal leading-snug whitespace-normal break-words max-w-[90%]">
|
|
||||||
{{ category.deskripsi }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-else class="mt-12 text-center text-gray-500">
|
<div v-else class="mt-12 text-center text-gray-500">
|
||||||
Belum ada kategori.
|
Belum ada kategori.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Header Templates -->
|
<!-- Header Templates -->
|
||||||
<div class="mt-20 text-center">
|
<div class="mt-20 text-center">
|
||||||
@ -127,12 +117,11 @@
|
|||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<div class="flex items-center gap-3 mt-6">
|
<div class="flex items-center gap-3 mt-6">
|
||||||
<button
|
<button @click="$router.push(`/preview/${t.id}`)"
|
||||||
class="w-full bg-white border border-gray-300 text-gray-800 font-semibold py-2 px-4 rounded-lg hover:bg-gray-100 transition-colors"
|
class="w-full bg-white border border-gray-300 text-gray-800 font-semibold py-2 px-4 rounded-lg hover:bg-gray-100 transition-colors">
|
||||||
@click="onTemplateClick(t)">
|
|
||||||
Preview
|
Preview
|
||||||
</button>
|
</button>
|
||||||
<NuxtLink :to="`${t.formPath}?template_id=${t.id}`"
|
<NuxtLink :to="`form/${t.formPath}`"
|
||||||
class="w-full bg-blue-600 text-white font-semibold py-2 px-4 rounded-lg hover:bg-blue-700 transition-colors text-center">
|
class="w-full bg-blue-600 text-white font-semibold py-2 px-4 rounded-lg hover:bg-blue-700 transition-colors text-center">
|
||||||
Order
|
Order
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
@ -263,7 +252,7 @@ const templatesWithFeatures = computed(() =>
|
|||||||
kategori: t.kategori,
|
kategori: t.kategori,
|
||||||
paket: paketData[index % paketData.length].paket,
|
paket: paketData[index % paketData.length].paket,
|
||||||
fiturs: paketData[index % paketData.length].fiturs.map((f, i) => ({ id: i + 1, deskripsi: f })),
|
fiturs: paketData[index % paketData.length].fiturs.map((f, i) => ({ id: i + 1, deskripsi: f })),
|
||||||
formPath: formMapping[t.nama_template] || `/form/lainny` // 🔥 ambil path form sesuai mapping
|
formPath: t.slug
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -75,14 +75,16 @@
|
|||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<div class="flex items-center gap-3 mt-6">
|
<div class="flex items-center gap-3 mt-6">
|
||||||
<NuxtLink :to="`/preview/${tpl.id}`"
|
|
||||||
class="w-full bg-white border border-gray-300 text-gray-800 font-semibold py-2 px-4 rounded-lg hover:bg-gray-100 transition-colors text-center">
|
<NuxtLink ::to="`/form/${tpl.kategori.nama}/${tpl.slug}`"
|
||||||
Preview
|
|
||||||
</NuxtLink>
|
|
||||||
<NuxtLink :to="`/form/${tpl.slug}`"
|
|
||||||
class="w-full bg-blue-600 text-white font-semibold py-2 px-4 rounded-lg hover:bg-blue-700 transition-colors text-center">
|
class="w-full bg-blue-600 text-white font-semibold py-2 px-4 rounded-lg hover:bg-blue-700 transition-colors text-center">
|
||||||
Order
|
Order
|
||||||
|
<p class="text-xs text-gray-400 mt-2">Path: {{ `/form/${tpl.kategori?.nama}/${tpl.slug}` }}</p>
|
||||||
|
|
||||||
|
<!-- <pre>{{ tpl }}</pre> -->
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -169,24 +171,26 @@ const fetchTemplates = async (categoryId) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
templates.value = res.map(tpl => {
|
templates.value = res.map(tpl => {
|
||||||
// Pastikan nama paket konsisten: 'Starter', 'Basic', 'Premium'
|
const paketKey = tpl.paket
|
||||||
const paketKey = tpl.paket ? tpl.paket.charAt(0).toUpperCase() + tpl.paket.slice(1).toLowerCase() : 'Starter'
|
? tpl.paket.charAt(0).toUpperCase() + tpl.paket.slice(1).toLowerCase()
|
||||||
|
: 'Starter'
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: tpl.id,
|
||||||
|
nama_template: tpl.nama_template,
|
||||||
|
slug: tpl.slug,
|
||||||
|
harga: tpl.harga,
|
||||||
|
kategori: tpl.kategori, // pastikan kategori berisi object { nama_kategori }
|
||||||
|
foto: tpl.foto ?? '/logo2.png',
|
||||||
|
paket: paketKey,
|
||||||
|
fiturs: (fiturPerPaket[paketKey] || []).map((f, i) => ({
|
||||||
|
id: i + 1,
|
||||||
|
deskripsi: f
|
||||||
|
})),
|
||||||
|
preview_link: tpl.preview_link ?? null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
|
||||||
id: tpl.id,
|
|
||||||
nama_template: tpl.nama_template,
|
|
||||||
harga: tpl.harga,
|
|
||||||
kategori: tpl.kategori,
|
|
||||||
foto: tpl.foto ?? '/logo2.png',
|
|
||||||
paket: paketKey,
|
|
||||||
fiturs: (fiturPerPaket[paketKey] || []).map((f, i) => ({
|
|
||||||
id: i + 1,
|
|
||||||
deskripsi: f
|
|
||||||
})),
|
|
||||||
preview_link: tpl.preview_link ?? null,
|
|
||||||
formPath: formMapping[tpl.nama_template] || '/form/lainny'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
error.value = 'Gagal memuat template.'
|
error.value = 'Gagal memuat template.'
|
||||||
@ -202,6 +206,8 @@ onMounted(() => fetchTemplates(props.id_category))
|
|||||||
watch(() => props.id_category, (newId) => {
|
watch(() => props.id_category, (newId) => {
|
||||||
if (newId) fetchTemplates(newId)
|
if (newId) fetchTemplates(newId)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user