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