This commit is contained in:
2025-06-27 16:02:00 +02:00
parent 96dbc38c3a
commit 012058b998
21 changed files with 1299 additions and 433 deletions

View File

@ -8,7 +8,7 @@ import type { FrontPageSection } from "~/types/frontSection";
export const useStore = defineStore("store", () => {
const currentPageID = ref("");
const { $toast } = useNuxtApp();
// calculator
const monthlySavings = ref(137);
@ -16,19 +16,13 @@ export const useStore = defineStore("store", () => {
const totalInvestment: Ref<number> = ref(0);
const minValue = ref();
// login
const email = ref();
const password = ref();
const components = ref({} as FrontPageSection[]);
const getSections = async (id: string) => {
const { data } = await useMyFetch<GenericResponse<FrontPageSection[]>>(
`/api/public/front/sections/${id}`
)
components.value = data
);
components.value = data;
};
async function getComponents(): Promise<componentsListType[]> {
@ -56,7 +50,6 @@ export const useStore = defineStore("store", () => {
name: componentName,
component: child.front_section,
componentInstance: nonReactiveComponent,
});
} catch (error) {
console.error(`Failed to load component ${componentName}`, error);
@ -103,39 +96,12 @@ export const useStore = defineStore("store", () => {
}
);
minValue.value = data;
} catch (error) {
console.error("getList error:", error);
}
}
async function logIn() {
try {
const { data } = await useMyFetch<GenericResponse<object>>(
`/api/public/user/session/start`,
{
method: "POST",
body: JSON.stringify({
mail: email.value,
password: password.value,
}),
headers: {
"Content-Type": "application/json",
},
onErrorOccured: (_, status) => {
throw new Error(`HTTP error: ${status}`);
},
}
);
minValue.value = data;
} catch (error) {
console.error("getList error:", error);
}
}
return {
currentPageID,
components,
@ -143,9 +109,6 @@ export const useStore = defineStore("store", () => {
monthlySavings,
storagePeriod,
minValue,
email,
password,
logIn,
getCalculator,
getComponents,
getSections,