Use vue's Composition API #10

Merged
jacob1123 merged 4 commits from vue-composition into master 2022-02-14 23:44:01 +01:00
Showing only changes of commit 87a70ee5fa - Show all commits

View File

@ -18,16 +18,9 @@ const props = defineProps<{
const budgetsStore = useBudgetsStore(); const budgetsStore = useBudgetsStore();
const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID); const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID);
const accountStore = useAccountStore(); const categoriesForMonth = useAccountStore().CategoriesForMonth;
//const categoriesForMonth = accountStore.CategoriesForMonth;
const Categories = computed(() => { const Categories = computed(() => {
const yearMap = accountStore.Months.get(selected.value.Year); return [...categoriesForMonth(selected.value.Year, selected.value.Month)];
const monthMap = yearMap?.get(selected.value.Month);
console.log("MTH", monthMap)
const CategoriesForMonth = [ ...monthMap?.values() || [] ];
console.log("YAY?")
return CategoriesForMonth;
//return [...categoriesForMonth(selected.value.Year, selected.value.Month)];
}); });
const previous = computed(() => ({ const previous = computed(() => ({
Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(), Year: new Date(selected.value.Year, selected.value.Month - 1, 1).getFullYear(),
@ -39,7 +32,7 @@ const current = computed(() => ({
})); }));
const selected = computed(() => ({ const selected = computed(() => ({
Year: Number(props.year) ?? current.value.Year, Year: Number(props.year) ?? current.value.Year,
Month: Number(props.month ?? current.value.Month) + 1 Month: Number(props.month ?? current.value.Month)
})); }));
const next = computed(() => ({ const next = computed(() => ({
Year: new Date(selected.value.Year, Number(props.month) + 1, 1).getFullYear(), Year: new Date(selected.value.Year, Number(props.month) + 1, 1).getFullYear(),
@ -57,7 +50,7 @@ watchEffect(() => {
</script> </script>
<template> <template>
<h1>Budget for {{ selected.Month }}/{{ selected.Year }}</h1> <h1>Budget for {{ selected.Month + 1 }}/{{ selected.Year }}</h1>
<div> <div>
<router-link <router-link
:to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month" :to="'/budget/' + CurrentBudgetID + '/budgeting/' + previous.Year + '/' + previous.Month"