nuxt-layer-core 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,25 @@ const parseValue = (value: unknown) => {
24
24
 
25
25
  const toCamelCase = (key: string) => key.replace(/_([a-z0-9])/gi, (_, c) => c.toUpperCase())
26
26
 
27
+ // Gói cần tư vấn được mang theo qua query (vd từ CoursesSection/PricingPlansSection ở trang khác) khi
28
+ // người dùng bấm "Liên hệ tư vấn" cho 1 slug cụ thể - áp dụng cho mọi slug, không riêng gì 1 trang nào
29
+ const route = useRoute()
30
+
31
+ const queryPlan = computed(() => {
32
+ const id = route.query.plan
33
+ if (!id) return null
34
+
35
+ return {
36
+ id: String(id),
37
+ name: String(route.query.name || ''),
38
+ level: String(route.query.level || ''),
39
+ duration: String(route.query.duration || ''),
40
+ price: String(route.query.price || ''),
41
+ description: String(route.query.description || ''),
42
+ icon: 'lucide:server',
43
+ }
44
+ })
45
+
27
46
  // Gom các item_id_0M_groups_0N (M: 1-3) của 1 group cụ thể thành mảng item hợp lệ
28
47
  const pickGroupItems = (sectionProps: Record<string, any> | undefined, groupSuffix: string) => {
29
48
  if (!sectionProps) return []
@@ -82,16 +101,31 @@ const sections = computed(() => {
82
101
  : null
83
102
 
84
103
  return list.map((section) => {
85
- if (section.component !== 'CtaSection') return section
86
-
87
- return {
88
- ...section,
89
- props: {
90
- ...section.props,
91
- courses,
92
- pricingPlans,
93
- },
104
+ if (section.component === 'CtaSection') {
105
+ return {
106
+ ...section,
107
+ props: {
108
+ ...section.props,
109
+ courses,
110
+ pricingPlans,
111
+ },
112
+ }
94
113
  }
114
+
115
+ // RegistrationSection: nếu URL có sẵn ?plan=... (đến từ nút "Liên hệ tư vấn" ở trang khác)
116
+ // thì hiển thị đúng gói đó thay vì danh sách trống do CMS không có data theo query
117
+ if (section.component === 'RegistrationSection' && queryPlan.value) {
118
+ return {
119
+ ...section,
120
+ props: {
121
+ ...section.props,
122
+ plans: [queryPlan.value],
123
+ selectedPlanId: queryPlan.value.id,
124
+ },
125
+ }
126
+ }
127
+
128
+ return section
95
129
  })
96
130
  })
97
131
  </script>
@@ -13,7 +13,7 @@ const { data } = await useAsyncData(
13
13
  )
14
14
  </script>
15
15
 
16
- <template>{{ data }}
16
+ <template>
17
17
  <DynamicPageSections
18
18
  :field-resumes="data?.resumeData?.fieldResumes"
19
19
  :target-c-t-a="data?.productData?.targetCTA"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "nuxt-layer-core",
3
3
  "type": "module",
4
4
  "private": false,
5
- "version": "1.0.6",
5
+ "version": "1.0.8",
6
6
  "scripts": {
7
7
  "build": "env-cmd -f .env nuxt build",
8
8
  "dev": "env-cmd -f .env nuxt dev"