This commit is contained in:
2025-06-16 15:53:57 +02:00
parent c7479b1aa6
commit 9cd264e839
5 changed files with 470 additions and 31 deletions

View File

@ -13,6 +13,10 @@ export const useStore = defineStore("store", () => {
const totalInvestment = ref()
const minValue = ref()
// login
const email = ref()
const password = ref()
const components = ref({} as PBPageItem[]);
const getSections = async (id: string) => {
pb.cancelRequest("menu_view");
@ -111,6 +115,34 @@ export const useStore = defineStore("store", () => {
}
}
async function logIn() {
try {
const res = await fetch(
'http://127.0.0.1:4000/api/public/user/session/start',
{
method: 'POST',
body: JSON.stringify({
mail: email.value,
password: password.value
}),
headers: {
"Content-Type": "application/json",
},
}
);
if (!res.ok) {
throw new Error(`HTTP error: ${res.status}`);
}
const data = await res.json();
minValue.value = data.data
} catch (error) {
console.error("getList error:", error);
}
}
getCalculator()
getMinValue()
@ -121,6 +153,9 @@ export const useStore = defineStore("store", () => {
monthlySavings,
storagePeriod,
minValue,
email,
password,
logIn,
getCalculator,
getComponents,
getSections,