This commit is contained in:
2025-06-16 15:53:57 +02:00
committed by Marek Goc
parent c7479b1aa6
commit 7b0d9b9c7b
12 changed files with 1993 additions and 1544 deletions

View File

@ -88,7 +88,7 @@ export const useMenuStore = defineStore("menuStore", () => {
const getCountryList = async () => {
try {
const res = await fetch(
`http://127.0.0.1:4000/api/public/country/list`,
`/api/public/country/list`,
{
headers: {
"Content-Type": "application/json",
@ -113,7 +113,7 @@ export const useMenuStore = defineStore("menuStore", () => {
const getCurrencies = async () => {
try {
const res = await fetch(
`http://127.0.0.1:4000/api/public/currencies`,
`/api/public/currencies`,
{
headers: {
"Content-Type": "application/json",
@ -139,7 +139,8 @@ export const useMenuStore = defineStore("menuStore", () => {
name: `id-slug___${$i18n.locale.value}`,
});
openDropDown.value = false;
} else {
}
else {
router.push({
params: {
slug: defaultMenu.value.link_rewrite,

View File

@ -4,7 +4,7 @@ export const useProductStore = defineStore("productStore", () => {
async function getList(count: number, categoryId = 1) {
try {
const res = await fetch(
`http://127.0.0.1:4000/api/public/products/category/${categoryId}?p=1&elems=${count}`,
`/api/public/products/category/${categoryId}?p=1&elems=${count}`,
{
headers: {
"Content-Type": "application/json",

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");
@ -68,7 +72,7 @@ export const useStore = defineStore("store", () => {
async function getCalculator() {
try {
const res = await fetch(
`http://127.0.0.1:4000/api/public/plan-prediction/easy/calculate?monthly_deposit=${monthlySavings.value}&years=${storagePeriod.value}`,
`/api/public/plan-prediction/easy/calculate?monthly_deposit=${monthlySavings.value}&years=${storagePeriod.value}`,
{
headers: {
"Content-Type": "application/json",
@ -91,7 +95,7 @@ export const useStore = defineStore("store", () => {
async function getMinValue() {
try {
const res = await fetch(
'http://127.0.0.1:4000/api/public/plan-prediction/free/minimum',
'/api/public/plan-prediction/free/minimum',
{
headers: {
"Content-Type": "application/json",
@ -111,6 +115,34 @@ export const useStore = defineStore("store", () => {
}
}
async function logIn() {
try {
const res = await fetch(
'/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,