Convert frontend to Vue #3
| @@ -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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user