release v2.0.0 #4
|
@ -45,8 +45,8 @@ export default defineComponent({
|
|||
const today = new Date();
|
||||
return (
|
||||
user.birthday &&
|
||||
user.birthday.getMonth === today.getMonth &&
|
||||
user.birthday.getDate === today.getDate
|
||||
user.birthday.getMonth() === today.getMonth() &&
|
||||
user.birthday.getDate() === today.getDate()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -196,6 +196,8 @@ export default defineComponent({
|
|||
|
||||
function save() {
|
||||
let changed = <FG.User>props.user;
|
||||
if (typeof changed.birthday === 'string')
|
||||
changed.birthday = new Date(changed.birthday);
|
||||
changed = Object.assign(changed, {
|
||||
password: password.value,
|
||||
});
|
||||
|
|
|
@ -14,11 +14,17 @@ export interface UserStateInterface {
|
|||
loading: number;
|
||||
}
|
||||
|
||||
function loadUserFromLocalStorage() {
|
||||
const user = SessionStorage.getItem<FG.User>('currentUser') || undefined;
|
||||
if (user && user.birthday && typeof user.birthday === 'string')
|
||||
user.birthday = new Date(user.birthday);
|
||||
return user;
|
||||
}
|
||||
const state: UserStateInterface = {
|
||||
users: [],
|
||||
roles: [],
|
||||
permissions: [],
|
||||
currentUser: SessionStorage.getItem<FG.User>('currentUser') || undefined,
|
||||
currentUser: loadUserFromLocalStorage(),
|
||||
currentPermissions:
|
||||
SessionStorage.getItem<FG.Permission[]>('currentPermissions') || [],
|
||||
loading: 0
|
||||
|
@ -26,6 +32,9 @@ const state: UserStateInterface = {
|
|||
|
||||
const mutations: MutationTree<UserStateInterface> = {
|
||||
setCurrentUser(state, data: FG.User) {
|
||||
if (typeof data.birthday === 'string')
|
||||
data.birthday = new Date(data.birthday);
|
||||
console.warn(data.birthday);
|
||||
SessionStorage.set('currentUser', data);
|
||||
state.currentUser = data;
|
||||
},
|
||||
|
@ -68,8 +77,6 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
|
|||
axios
|
||||
.get(`/users/${rootState.session.currentSession.userid}`)
|
||||
.then((response: AxiosResponse<CurrentUserResponse>) => {
|
||||
if (response.data.birthday)
|
||||
response.data.birthday = new Date(response.data.birthday);
|
||||
commit('setCurrentUser', response.data);
|
||||
commit('setCurrentPermissions', response.data.permissions);
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue