invest page

This commit is contained in:
2025-06-06 15:50:06 +02:00
parent c7d71ddb21
commit 3d91d7f1bb
16 changed files with 331 additions and 80 deletions

View File

@ -6,8 +6,11 @@ export const useStore = defineStore("store", () => {
const currentPageID = ref("");
const pb = usePB();
const { $i18n } = useNuxtApp();
const menuStore = useMenuStore()
const colorMode = useColorMode()
// calculator
const monthlySavings = ref(137);
const storagePeriod = ref(10);
const totalInvestment = ref()
const components = ref({} as PBPageItem[]);
const getSections = async (id: string) => {
@ -61,19 +64,38 @@ export const useStore = defineStore("store", () => {
return [];
}
const isDark = computed({
get() {
return colorMode.value === "dark";
},
set(_isDark) {
colorMode.preference = _isDark ? "dark" : "light";
},
});
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}`,
{
headers: {
"Content-Type": "application/json",
},
}
);
if (!res.ok) {
throw new Error(`HTTP error: ${res.status}`);
}
const data = await res.json();
totalInvestment.value = data.data.total_investement_value
} catch (error) {
console.error("getList error:", error);
}
}
getCalculator()
return {
currentPageID,
components,
isDark,
totalInvestment,
monthlySavings,
storagePeriod,
getCalculator,
getComponents,
getSections,
};