diff --git a/web/src/App.vue b/web/src/App.vue
index cdcca6f..d1847a9 100644
--- a/web/src/App.vue
+++ b/web/src/App.vue
@@ -2,6 +2,11 @@
// This starter template is using Vue 3
-
-
- Budget
-
- ⌂
- {{$store.getters.CurrentBudget.Name}}
-
-
-
\ No newline at end of file
diff --git a/web/src/pages/BudgetSidebar.vue b/web/src/pages/BudgetSidebar.vue
new file mode 100644
index 0000000..3481411
--- /dev/null
+++ b/web/src/pages/BudgetSidebar.vue
@@ -0,0 +1,55 @@
+
+
+
+ Budget
+
+ ⌂
+ {{$store.getters.CurrentBudget.Name}}
+
+
+ - Budget
+ - Reports (Coming Soon)
+ - All Accounts
+ -
+ On-Budget Accounts
+
+ -
+ {{account.Name}}
+ {{account.Balance.Int / 100}}
+
+
+
+ -
+ Off-Budget Accounts
+
+ -
+ {{account.Name}}
+ {{account.Balance.Int / 100}}
+
+
+
+ -
+ Closed Accounts
+
+ -
+ Edit accounts
+
+ -
+ + Add Account
+
+ -
+ Budget-Settings
+
+ -
+ Admin
+
+
+
\ No newline at end of file
diff --git a/web/src/router/routes.js b/web/src/router/routes.js
index a0c2626..8c139eb 100644
--- a/web/src/router/routes.js
+++ b/web/src/router/routes.js
@@ -1,4 +1,4 @@
-import { createRouter, createWebHashHistory } from 'vue-router'
+import { createRouter, createWebHistory } from 'vue-router'
import Budget from '../pages/Budget.vue';
import Dashboard from '../pages/Dashboard.vue';
import Login from '../pages/Login.vue';
@@ -6,13 +6,14 @@ import Register from '../pages/Register.vue';
const routes = [
{ path: '/', name: 'Index', component: Dashboard },
+ { path: '/dashboard', name: 'Dashboard', component: Dashboard },
{ path: '/login', name: 'Login', component: Login },
{ path: '/register', name: 'Register', component: Register },
- { path: '/budget/:budgetid', name: 'Budget', component: Budget },
+ { path: '/budget/:budgetid', name: 'Budget', components: {default: Dashboard, sidebar: Budget } },
]
const router = createRouter({
- history: createWebHashHistory(),
+ history: createWebHistory(),
routes,
})
diff --git a/web/src/store/budget/index.js b/web/src/store/budget/index.js
index aaca938..71ec39c 100644
--- a/web/src/store/budget/index.js
+++ b/web/src/store/budget/index.js
@@ -9,7 +9,7 @@ const budget = {
},
mutations: {
setAccounts (state, accounts) {
- state.Accounts = accounts;
+ state.Accounts = accounts;
}
},
getters: {
diff --git a/web/src/store/dashboard/index.js b/web/src/store/dashboard/index.js
index 1ef347b..4138f41 100644
--- a/web/src/store/dashboard/index.js
+++ b/web/src/store/dashboard/index.js
@@ -11,24 +11,30 @@ const dashboard = {
},
addBudget(state, budget) {
state.Budgets.push(budget);
+ },
+ setCurrentBudget(state, budget) {
+ state.CurrentBudget = budget;
}
},
getters: {
Budgets(state) {
return state.Budgets || [];
+ },
+ CurrentBudget(state) {
+ return state.CurrentBudget || {};
}
},
actions: {
- fetchDashboard ({state, commit, rootState}) {
- fetch("/api/v1/dashboard", {
+ async fetchDashboard ({state, commit, rootState}) {
+ const response = await fetch("/api/v1/dashboard", {
headers: {
'Authorization': 'Bearer ' + rootState.Session.Token
}
})
- .then(x => x.json())
- .then(x => commit("setBudgets", x.Budgets));
+ const data = await response.json();
+ commit("setBudgets", data.Budgets);
},
- newBudget ({state, commit, rootState}, budgetName) {
+ async newBudget ({state, commit, rootState}, budgetName) {
fetch("/api/v1/budget/new", {
method: "POST",
body: JSON.stringify({name: budgetName}),
@@ -38,6 +44,17 @@ const dashboard = {
})
.then(x => x.json())
.then(x => commit("addBudget", x));
+ },
+ async setCurrentBudget({state, commit, dispatch}, budgetid) {
+ await dispatch("fetchDashboard");
+ for (const element of state.Budgets) {
+ if(element.ID != budgetid)
+ continue
+
+ commit("setCurrentBudget", element);
+ break
+ }
+ await dispatch("fetchBudget", budgetid);
}
}
}