diff --git a/components/HeaderBlock.vue b/components/HeaderBlock.vue index 90e3808..46417f2 100644 --- a/components/HeaderBlock.vue +++ b/components/HeaderBlock.vue @@ -6,9 +6,9 @@
-

{{ component.section_lang_data.section_2.title }}

+

{{ component.front_section_lang[0].data.section_2.title }}

-

{{ item - }}

+

{{ item + }}

-
-

{{ component.section_lang_data.section_3.title }}

-
+

{{ component.front_section_lang[0].data.section_3.title }} +

+

{{ item }}

-
+
{{ $t('buy_gold') }}
@@ -72,23 +75,31 @@ diff --git a/components/section/AboutUsDifferent.vue b/components/section/AboutUsDifferent.vue index d877a5a..e998526 100644 --- a/components/section/AboutUsDifferent.vue +++ b/components/section/AboutUsDifferent.vue @@ -3,44 +3,35 @@

- {{ component.section_lang_data.title }} + {{ component.front_section_lang[0].data.title }}

-

{{ component.section_lang_data.description }}

+

{{ component.front_section_lang[0].data.description }}

-
-
+
+

0{{ index + 1 }}
{{ item.block_title }}

{{ item.block_description }}

+ class="sm:text-white xl:row-start-2 md:col-start-1 md:col-end-3 xl:col-end-2 w-full md:h-full flex justify-center xl:items-end"> Zakoupit zlato
-
+ }" />
@@ -48,21 +39,28 @@ diff --git a/components/section/AboutUsHistory.vue b/components/section/AboutUsHistory.vue index c40255d..bfe662a 100644 --- a/components/section/AboutUsHistory.vue +++ b/components/section/AboutUsHistory.vue @@ -2,98 +2,79 @@

- {{ component.section_lang_data.section_1.title }} + {{ component.front_section_lang[0].data.section_1.title }}

-
+

- {{ component.section_lang_data.section_1.sub_title }} + {{ component.front_section_lang[0].data.section_1.sub_title }}

-

+

{{ item }}

- {{ component.section_lang_data.section_1.sub_title_second }} + {{ component.front_section_lang[0].data.section_1.sub_title_second }}

- {{ component.section_lang_data.section_2.title }} + {{ component.front_section_lang[0].data.section_2.title }}

-

+

{{ item }}

- {{ component.section_lang_data.section_3.title }} + {{ component.front_section_lang[0].data.section_3.title }}

-
-
+
+
-

- {{ component.section_lang_data.story_title }} + {{ component.front_section_lang[0].data.story_title }}

-
+
-

- {{ item }} -

-
-
+

+ {{ item }} +

+
+

- {{ component.section_lang_data.story_subtitle }} + {{ component.front_section_lang[0].data.story_subtitle }}

-

+

{{ el }} -

-
-
+
+
+

@@ -64,19 +59,28 @@ diff --git a/components/section/BusinessMain.vue b/components/section/BusinessMain.vue index a145684..ee315ec 100644 --- a/components/section/BusinessMain.vue +++ b/components/section/BusinessMain.vue @@ -2,131 +2,117 @@

- + {{ item.text }} - +

-
+
-

{{ component.section_lang_data.main_description }}

+

{{ component.front_section_lang[0].data.main_description }}

- {{ component.section_lang_data.secondary_description }} + {{ component.front_section_lang[0].data.secondary_description }}

- {{ component.section_lang_data.section_1_title }} + {{ component.front_section_lang[0].data.section_1_title }}

-

+

- + {{ item.text }} - +

-

+

- {{ component.section_lang_data.section_3_title }} + {{ component.front_section_lang[0].data.section_3_title }}

-
+
-

{{ component.section_lang_data.section_3_description }}

+

{{ component.front_section_lang[0].data.section_3_description }}

-

+

{{ index + 1 }}. {{ item }}

-
+

- {{ component.section_lang_data.section_4_title }} + {{ component.front_section_lang[0].data.section_4_title }}

-

+

diff --git a/components/section/BusinessReasons.vue b/components/section/BusinessReasons.vue index 54afb2f..9844913 100644 --- a/components/section/BusinessReasons.vue +++ b/components/section/BusinessReasons.vue @@ -2,23 +2,22 @@

- + {{ item.text }}

-
@@ -43,31 +42,31 @@

- {{ component.section_lang_data.cta_section_title }} + {{ component.front_section_lang[0].data.cta_section_title }}

-

{{ component.section_lang_data.cta_description_intro }}

+

{{ component.front_section_lang[0].data.cta_description_intro }}

- {{ component.section_lang_data.main_call_to_action_statement }} + {{ component.front_section_lang[0].data.main_call_to_action_statement }}

-

{{ component.section_lang_data.cta_description_details }}

+

{{ component.front_section_lang[0].data.cta_description_details }}

- {{ component.section_lang_data.form_section_title }} + {{ component.front_section_lang[0].data.form_section_title }}

@@ -114,14 +113,14 @@
-

{{ component.section_lang_data.closing_inspirational_block }}

+

{{ component.front_section_lang[0].data.closing_inspirational_block }}

-

-

{{ component.section_lang_data.final_tagline }}

+

{{ component.front_section_lang[0].data.final_tagline }}

@@ -143,39 +142,41 @@ diff --git a/components/section/ContactMain.vue b/components/section/ContactMain.vue index 14b283e..edac74f 100644 --- a/components/section/ContactMain.vue +++ b/components/section/ContactMain.vue @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/components/section/FooterBlock.vue b/components/section/FooterBlock.vue index 4838e59..afdb723 100644 --- a/components/section/FooterBlock.vue +++ b/components/section/FooterBlock.vue @@ -3,7 +3,7 @@
-

{{ item.title }}

diff --git a/components/section/InvestmentMain.vue b/components/section/InvestmentMain.vue index fa0f1cb..f24b092 100644 --- a/components/section/InvestmentMain.vue +++ b/components/section/InvestmentMain.vue @@ -1,63 +1,45 @@ diff --git a/components/section/InvestmentSave.vue b/components/section/InvestmentSave.vue index 42d5be7..c21ece5 100644 --- a/components/section/InvestmentSave.vue +++ b/components/section/InvestmentSave.vue @@ -3,97 +3,80 @@

- {{ component.section_lang_data.main_title }} + {{ component.front_section_lang[0].data.main_title }}

-
-
-

{{ 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 @@ 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