forked from jsnbuchanan/crowd-funder-for-time-pwa
Added Pinia account state tracking. Also modified router to go to Start if no account is defined.
This commit is contained in:
@@ -4,16 +4,19 @@ import { defineStore } from "pinia";
|
||||
export const useAccountStore = defineStore({
|
||||
id: "account",
|
||||
state: () => ({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
account: JSON.parse(
|
||||
typeof localStorage["account"] == "undefined"
|
||||
? null
|
||||
: localStorage["account"]
|
||||
),
|
||||
}),
|
||||
|
||||
getters: {
|
||||
firstName: (state) => state.account.firstName,
|
||||
lastName: (state) => state.account.lastName,
|
||||
},
|
||||
actions: {
|
||||
reset() {
|
||||
this.$patch({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
});
|
||||
localStorage.removeItem("account");
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { createStore } from "vuex";
|
||||
|
||||
export default createStore({
|
||||
state: {},
|
||||
getters: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
modules: {},
|
||||
});
|
||||
Reference in New Issue
Block a user