Convert frontend to Vue #3

Merged
jacob1123 merged 158 commits from vue into master 2022-02-08 22:20:11 +01:00
Showing only changes of commit 8b4ebadec2 - Show all commits

View File

@ -19,14 +19,14 @@ const store = createStore({
let store = localStorage.getItem("store"); let store = localStorage.getItem("store");
if(store){ if(store){
this.replaceState( this.replaceState(
Object.assign(state, store) Object.assign(state, JSON.parse(store))
); );
} }
}, },
getDashboard (state) { getDashboard (state) {
fetch("/api/v1/dashboard", { fetch("/api/v1/dashboard", {
headers: { headers: {
'Authorization': 'Bearer ' + state.Token 'Authorization': 'Bearer ' + state.Session.Token
} }
}) })
.then(x => x.json()) .then(x => x.json())
@ -37,13 +37,18 @@ const store = createStore({
document.title = "Budgeteer - " + title; document.title = "Budgeteer - " + title;
}, },
setToken(state, token) { setToken(state, token) {
state.Token = token; state.Session.Token = token;
} }
} }
}) })
store.subscribe((mutation, state) => { store.subscribe((mutation, state) => {
localStorage.setItem("store", JSON.stringify(state)); let persistedState = {
Session: state.Session,
Budgets: state.Budgets,
CurrentBudget: state.CurrentBudget
}
localStorage.setItem("store", JSON.stringify(persistedState));
}) })
const app = createApp(App) const app = createApp(App)