update profile

This commit is contained in:
2026-04-17 11:44:58 +07:00
parent 7a6252063c
commit 5b6b59dc01
4 changed files with 118 additions and 25 deletions

View File

@@ -1,7 +1,6 @@
import { UserData } from '@/interface/user';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
// Hàm helper để đọc dữ liệu an toàn từ storage
const getStoredApplication = () => {
if (typeof window !== "undefined") {
const saved = sessionStorage.getItem('selected_application');
@@ -19,7 +18,7 @@ interface UserState {
const initialState: UserState = {
data: null,
isAuthenticated: false,
selectedApplication: getStoredApplication(), // Khởi tạo từ storage
selectedApplication: getStoredApplication(),
};
const userSlice = createSlice({
@@ -32,7 +31,6 @@ const userSlice = createSlice({
},
setSelectedApplication: (state, action: PayloadAction<any>) => {
state.selectedApplication = action.payload;
// Lưu vào sessionStorage để khi reload trang không bị mất
if (typeof window !== "undefined") {
sessionStorage.setItem('selected_application', JSON.stringify(action.payload));
}