-
-
{{ component.section_lang_data.main_description }}
-
{{ component.section_lang_data.section_title }}
+
+
+
{{ component.front_section_lang[0].data.main_description }}
+
{{ component.front_section_lang[0].data.section_title }}
- -
+
-
{{ index + 1 }}. {{ item }}
-
+
-
-
+
+
20 {{ $t("years") }}
-
![]()
-
![]()
+
![]()
+
-
{{ component.section_lang_data.info_description }}
+
{{ component.front_section_lang[0].data.info_description }}
- {{ component.section_lang_data.info_title }}
+ {{ component.front_section_lang[0].data.info_title }}
-
+
-
+
diff --git a/components/section/InvestmentWhy.vue b/components/section/InvestmentWhy.vue
index 2417067..d48428c 100644
--- a/components/section/InvestmentWhy.vue
+++ b/components/section/InvestmentWhy.vue
@@ -2,42 +2,45 @@
-
+
{{ item.text }}
-
+
- {{ component.section_lang_data.description }}
+ {{ component.front_section_lang[0].data.description }}
diff --git a/components/section/InvestmentZone.vue b/components/section/InvestmentZone.vue
index 273eb1c..76f21a0 100644
--- a/components/section/InvestmentZone.vue
+++ b/components/section/InvestmentZone.vue
@@ -1,22 +1,22 @@
-
{{ item.text }}
-
+
-
{{ component.section_lang_data.main_description }}
+
{{ component.front_section_lang[0].data.main_description }}
- {{ component.section_lang_data.section_title }}
+ {{ component.front_section_lang[0].data.section_title }}
@@ -59,21 +59,21 @@
-
{{ component.section_lang_data.section_description }}
+
{{ component.front_section_lang[0].data.section_description }}
- {{ component.section_lang_data.info_title }}
+ {{ component.front_section_lang[0].data.info_title }}
-
{{ component.section_lang_data.info_description }}
+
{{ component.front_section_lang[0].data.info_description }}
- {{ component.section_lang_data.cta_title }}
+ {{ component.front_section_lang[0].data.cta_title }}
@@ -115,28 +115,35 @@
diff --git a/components/section/MainProducts.vue b/components/section/MainProducts.vue
index e3caa3e..cd7560c 100644
--- a/components/section/MainProducts.vue
+++ b/components/section/MainProducts.vue
@@ -43,19 +43,17 @@
\ No newline at end of file
diff --git a/pages/index.vue b/pages/index.vue
index 68e7472..5643e3c 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -16,7 +16,7 @@ const menuStore = useMenuStore();
const route = useRoute();
-route.params.id = menuStore.defaultMenu.id_page;
+route.params.id = menuStore.defaultMenu.id;
route.params.slug = menuStore.defaultMenu.link_rewrite;
const store = useStore();
@@ -26,6 +26,6 @@ onMounted(() => {
menuStore.openMenu = false;
});
-useHead(menuStore.headMeta);
+// useHead(menuStore.headMeta);
const componentsList = await store.getComponents(route.params.id);
diff --git a/stores/frontSection.ts b/stores/frontSection.ts
new file mode 100644
index 0000000..c0c58f0
--- /dev/null
+++ b/stores/frontSection.ts
@@ -0,0 +1,22 @@
+export interface FrontPageSection {
+ id_front_page: number
+ id_position: number
+ id_section: number
+ front_section: FrontSection
+}
+
+export interface FrontSection {
+ id: number
+ name: string
+ img: string[]
+ component_name: string
+ is_no_lang: boolean
+ page_name: string
+ front_section_lang: FrontSectionLang[]
+}
+
+export interface FrontSectionLang {
+ data: unknown
+ id_front_section: number
+ id_lang: number
+}
diff --git a/stores/menuStore.ts b/stores/menuStore.ts
index a687968..adca200 100644
--- a/stores/menuStore.ts
+++ b/stores/menuStore.ts
@@ -4,32 +4,39 @@ import type {
Currencies,
Currency,
FooterListResponse,
+ FrontMenu,
GenericResponse,
GenericResponseItems,
- MenuListResponse,
PBFooterItem,
- PBMenuItem,
+ UIFrontMenu,
UIMenuItem,
} from "~/types";
import { useStore } from "./store";
import { ref, watch } from "vue";
import { useMyFetch } from "#imports";
-function buildTreeRecursive(
- data: (PBMenuItem | UIMenuItem)[],
- parentId: string
-): UIMenuItem[] {
- const children = data.filter(
- (item): item is UIMenuItem =>
- item.id_parent === parentId && !item.is_default
- );
+// function buildTreeRecursive(
+// data: (PBMenuItem | UIMenuItem)[],
+// parentId: string
+// ): UIMenuItem[] {
+// const children = data.filter(
+// (item): item is UIMenuItem =>
+// item.id_parent === parentId && !item.is_default
+// );
- return children.map((item) => ({
- ...item,
- children: buildTreeRecursive(data, item.id),
- }));
+// return children.map((item) => ({
+// ...item,
+// children: buildTreeRecursive(data, item.id),
+// }));
+// }
+
+function buildTreeRecursive(data: (FrontMenu | UIFrontMenu)[], parentId: number): UIFrontMenu[] {
+ const children = data.filter((item): item is UIFrontMenu => item.id_parent === parentId && !item.is_default);
+
+ return children.map((item) => ({ ...item, children: buildTreeRecursive(data, item.id) }));
}
+
export const useMenuStore = defineStore("menuStore", () => {
const pb = usePB();
const store = useStore();
@@ -41,8 +48,11 @@ export const useMenuStore = defineStore("menuStore", () => {
const openDropDown = ref(false);
const defaultMenu = ref();
- const menu = ref
([]);
- const menuItems = ref();
+ // const menu = ref([]);
+ // const menuItems = ref();
+
+ const menu = ref([]);
+ const menuItems = ref();
const footerItems = ref();
const countryList = ref();
@@ -55,23 +65,44 @@ export const useMenuStore = defineStore("menuStore", () => {
const loadMenu = async () => {
try {
- menuItems.value = (await pb
- .collection("menu_view")
- .getList(1, 50, {
- filter: `id_lang="${$i18n.locale.value}"&&active=true`,
- sort: "position_id",
- })) as MenuListResponse;
+ // menuItems.value = (await pb
+ // .collection("menu_view")
+ // .getList(1, 50, {
+ // filter: `id_lang="${$i18n.locale.value}"&&active=true`,
+ // sort: "position_id",
+ // })) as MenuListResponse;
- const root = menuItems.value.items.find((item) => item.is_root);
- defaultMenu.value = menuItems.value.items.find((item) => item.is_default);
+ const { data } = await useMyFetch>(`/api/public/front/menu`, {
+ onErrorOccured: (err, status) => {
+ console.log(err, status);
+ },
+ // onSuccess(data) {
+ // console.log(data.data, "data");
+ // },
+ })
+
+ const root = data.find((item) => item.is_root) as UIFrontMenu;
+ defaultMenu.value = data.find((item) => item.is_default);
+ // console.log(menuNew, "data");
if (root) {
- menu.value = buildTreeRecursive(menuItems.value.items, root.id);
- store.currentPageID = menu.value[0]?.id_page || "";
+ menu.value = buildTreeRecursive(data, root.id);
} else {
console.warn("Root menu item not found");
menu.value = [];
}
+
+
+ // const root = menuItems.value.items.find((item) => item.is_root);
+ // defaultMenu.value = menuItems.value.items.find((item) => item.is_default);
+
+ // if (root) {
+ // menu.value = buildTreeRecursive(menuItems.value.items, root.id);
+ // store.currentPageID = menu.value[0]?.id_page || "";
+ // } else {
+ // console.warn("Root menu item not found");
+ // menu.value = [];
+ // }
} catch (error) {
console.log(error);
}
@@ -91,7 +122,7 @@ export const useMenuStore = defineStore("menuStore", () => {
const getCountryList = async () => {
try {
- const {data} = await useMyFetch>(
+ const { data } = await useMyFetch>(
`/api/public/country/list`,
{
headers: {
@@ -116,7 +147,7 @@ export const useMenuStore = defineStore("menuStore", () => {
const getCurrencies = async () => {
try {
- const {data} = await useMyFetch>(
+ const { data } = await useMyFetch>(
`/api/public/currencies`,
{
headers: {
@@ -134,16 +165,16 @@ export const useMenuStore = defineStore("menuStore", () => {
currencies.value = data.items
// console.log(data.items, "data");
-
+
} catch (error) {
console.error("getList error:", error);
}
}
- const navigateToItem = (item?: UIMenuItem) => {
+ const navigateToItem = (item?: UIFrontMenu) => {
if (item) {
router.push({
- params: { slug: item.link_rewrite, id: item.id_page },
+ params: { slug: item.front_menu_lang[0].link_rewrite, id: item.id },
name: `id-slug___${$i18n.locale.value}`,
});
openDropDown.value = false;
diff --git a/stores/store.ts b/stores/store.ts
index 760e27c..ff546c0 100644
--- a/stores/store.ts
+++ b/stores/store.ts
@@ -1,17 +1,16 @@
import { useMyFetch } from "#imports";
-import { usePB } from "~/composables/usePB";
+// import { usePB } from "~/composables/usePB";
import type {
componentsListType,
GenericResponse,
- PBPageItem,
PlanPrediction,
} from "~/types";
// import { useI18n } from "vue-i18n";
export const useStore = defineStore("store", () => {
const currentPageID = ref("");
- const pb = usePB();
- const { $i18n } = useNuxtApp();
+ // const pb = usePB();
+ // const { $i18n } = useNuxtApp();
// calculator
const monthlySavings = ref(137);
@@ -23,17 +22,41 @@ export const useStore = defineStore("store", () => {
const email = ref();
const password = ref();
- const components = ref({} as PBPageItem[]);
+ const components = ref({} as FrontPageSection[]);
+ // const getSections = async (id: string) => {
+ // pb.cancelRequest("menu_view");
+ // components.value = (
+ // await pb.collection("page_view").getList(1, 50, {
+ // filter: `id="${id}"&&(section_lang_id_lang="${
+ // $i18n.locale.value
+ // }"||section_is_no_lang=${true})`,
+ // sort: "page_section_id_position",
+ // })
+ // ).items as PBPageItem[];
+ // };
+
const getSections = async (id: string) => {
- pb.cancelRequest("menu_view");
- components.value = (
- await pb.collection("page_view").getList(1, 50, {
- filter: `id="${id}"&&(section_lang_id_lang="${
- $i18n.locale.value
- }"||section_is_no_lang=${true})`,
- sort: "page_section_id_position",
- })
- ).items as PBPageItem[];
+ // if(!id){
+ // id = useMenuStore().defaultMenu.id
+ // }
+ // console.log(useMenuStore().defaultMenu);
+
+ const {data} = await useMyFetch>(
+ `/api/public/front/sections/${id}`
+ )
+ // console.log(data, id, "data");
+ components.value = data
+ // return data
+
+ // pb.cancelRequest("menu_view");
+ // components.value = (
+ // await pb.collection("page_view").getList(1, 50, {
+ // filter: `id="${id}"&&(section_lang_id_lang="${
+ // $i18n.locale.value
+ // }"||section_is_no_lang=${true})`,
+ // sort: "page_section_id_position",
+ // })
+ // ).items as PBPageItem[];
};
async function getComponents(): Promise {
@@ -48,8 +71,8 @@ export const useStore = defineStore("store", () => {
const componentsList = [] as componentsListType[];
for (const child of children) {
- const componentName = child.component_name;
- const pageName = child.page_name;
+ const componentName = child.front_section.component_name;
+ // const pageName = child.front_section.page_name;
if (!componentName) continue;
try {
@@ -58,12 +81,12 @@ export const useStore = defineStore("store", () => {
).default;
const nonReactiveComponent = markRaw(componentInstance);
-
componentsList.push({
name: componentName,
- component: child,
+ component: child.front_section,
componentInstance: nonReactiveComponent,
- data: child.section_lang_data,
+ // data: child.front_section.front_section_lang[0].data || {} as unknown,
+ // data: {}
});
} catch (error) {
console.error(`Failed to load component ${componentName}`, error);
diff --git a/types/frontMenu.ts b/types/frontMenu.ts
new file mode 100644
index 0000000..ca6eae2
--- /dev/null
+++ b/types/frontMenu.ts
@@ -0,0 +1,26 @@
+export interface FrontMenu {
+ id: number
+ id_parent: number
+ active: boolean
+ position_id: number
+ id_front_page: number
+ is_default: boolean
+ is_root: boolean
+ url: string
+ front_menu_lang: FrontMenuLang[]
+}
+
+export interface FrontMenuLang {
+ name: string
+ id_lang: number
+ id_menu: number
+ link_title: string
+ meta_title: string
+ meta_description: string
+ link_rewrite: string
+}
+
+
+export interface UIFrontMenu extends FrontMenu {
+ children?: UIFrontMenu[];
+}
\ No newline at end of file
diff --git a/types/index.ts b/types/index.ts
index f834108..388146f 100644
--- a/types/index.ts
+++ b/types/index.ts
@@ -52,31 +52,31 @@ export interface PBFooterItem {
}>;
}
-export interface PBPageItem {
- collectionId: string;
- collectionName: string;
- component_name: string;
- id: string;
- image_collection: string;
- page_created: string;
- page_id: string;
- page_name: string;
- page_section_id_position: number;
- page_updated: string;
- section_id: string;
- section_img: string[];
- section_lang_created: string;
- section_lang_data: SectionLangData;
- section_lang_id_lang: string;
- section_name: string;
-}
+// export interface PBPageItem {
+// collectionId: string;
+// collectionName: string;
+// component_name: string;
+// id: string;
+// image_collection: string;
+// page_created: string;
+// page_id: string;
+// page_name: string;
+// page_section_id_position: number;
+// page_updated: string;
+// section_id: string;
+// section_img: string[];
+// section_lang_created: string;
+// section_lang_data: SectionLangData;
+// section_lang_id_lang: string;
+// section_name: string;
+// }
-export interface SectionLangData {
- title: string;
- description: string;
- button: string;
- button_call: string;
-}
+// export interface SectionLangData {
+// title: string;
+// description: string;
+// button: string;
+// button_call: string;
+// }
export interface UIMenuItem extends PBMenuItem {
children?: UIMenuItem[];
@@ -92,9 +92,9 @@ export interface FooterListResponse extends ListResponse {
export type componentsListType = {
name: string;
- component: PBPageItem;
+ component: FrontSection;
componentInstance: DefineComponent;
- data: SectionLangData;
+ // data: unknown;
};
// menuStore
@@ -212,3 +212,4 @@ export type {
PeriodToFirstPiece,
} from "./planPrediction";
export type { Product } from "./product";
+export type { FrontMenu, FrontMenuLang, UIFrontMenu } from "./frontMenu";
\ No newline at end of file