shop
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user