fix langs
This commit is contained in:
@ -1,16 +1,14 @@
|
||||
import { useMyFetch } from "#imports";
|
||||
// import { usePB } from "~/composables/usePB";
|
||||
import type {
|
||||
componentsListType,
|
||||
GenericResponse,
|
||||
PlanPrediction,
|
||||
} from "~/types";
|
||||
// import { useI18n } from "vue-i18n";
|
||||
import type { FrontPageSection } from "~/types/frontSection";
|
||||
|
||||
export const useStore = defineStore("store", () => {
|
||||
const currentPageID = ref("");
|
||||
// const pb = usePB();
|
||||
// const { $i18n } = useNuxtApp();
|
||||
|
||||
|
||||
// calculator
|
||||
const monthlySavings = ref(137);
|
||||
@ -23,40 +21,14 @@ export const useStore = defineStore("store", () => {
|
||||
const password = ref();
|
||||
|
||||
const components = ref({} as FrontPageSection[]);
|
||||
// const getSections = async (id: string) => {
|
||||
// pb.cancelRequest("menu_view");
|
||||
// components.value = (
|
||||
// await pb.collection<PBPageItem>("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) => {
|
||||
// if(!id){
|
||||
// id = useMenuStore().defaultMenu.id
|
||||
// }
|
||||
// console.log(useMenuStore().defaultMenu);
|
||||
|
||||
const {data} = await useMyFetch<GenericResponse<FrontPageSection[]>>(
|
||||
const { data } = await useMyFetch<GenericResponse<FrontPageSection[]>>(
|
||||
`/api/public/front/sections/${id}`
|
||||
)
|
||||
// console.log(data, id, "data");
|
||||
components.value = data
|
||||
// return data
|
||||
|
||||
// pb.cancelRequest("menu_view");
|
||||
// components.value = (
|
||||
// await pb.collection<PBPageItem>("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<componentsListType[]> {
|
||||
@ -72,7 +44,6 @@ export const useStore = defineStore("store", () => {
|
||||
|
||||
for (const child of children) {
|
||||
const componentName = child.front_section.component_name;
|
||||
// const pageName = child.front_section.page_name;
|
||||
if (!componentName) continue;
|
||||
|
||||
try {
|
||||
@ -85,8 +56,7 @@ export const useStore = defineStore("store", () => {
|
||||
name: componentName,
|
||||
component: child.front_section,
|
||||
componentInstance: nonReactiveComponent,
|
||||
// data: child.front_section.front_section_lang[0].data || {} as unknown,
|
||||
// data: {}
|
||||
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Failed to load component ${componentName}`, error);
|
||||
@ -133,11 +103,7 @@ export const useStore = defineStore("store", () => {
|
||||
}
|
||||
);
|
||||
|
||||
// if (!res.ok) {
|
||||
// throw new Error(`HTTP error: ${res.status}`);
|
||||
// }
|
||||
|
||||
// const data = await res.json();
|
||||
minValue.value = data;
|
||||
} catch (error) {
|
||||
console.error("getList error:", error);
|
||||
@ -169,8 +135,6 @@ export const useStore = defineStore("store", () => {
|
||||
}
|
||||
}
|
||||
|
||||
getCalculator();
|
||||
getMinValue();
|
||||
|
||||
return {
|
||||
currentPageID,
|
||||
@ -185,5 +149,6 @@ export const useStore = defineStore("store", () => {
|
||||
getCalculator,
|
||||
getComponents,
|
||||
getSections,
|
||||
getMinValue,
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user