Revert "pig update: decentralization, format date time"
All checks were successful
Build and Release / release (push) Successful in 27s

This reverts commit 49b99289bb.
This commit is contained in:
2026-04-20 01:00:52 +07:00
parent 49b99289bb
commit 1fe25c1944
16 changed files with 242 additions and 781 deletions

View File

@@ -3,13 +3,6 @@
import { useRef } from 'react';
import { Provider } from 'react-redux';
import { store } from './store';
import { useRestoreUserData } from '@/hooks/useRestoreUserData';
function RestoreUserDataComponent() {
useRestoreUserData();
return null;
}
export default function StoreProvider({
children,
@@ -17,10 +10,5 @@ export default function StoreProvider({
children: React.ReactNode;
}) {
const storeRef = useRef(store);
return (
<Provider store={storeRef.current}>
<RestoreUserDataComponent />
{children}
</Provider>
);
return <Provider store={storeRef.current}>{children}</Provider>;
}

View File

@@ -1,6 +1,5 @@
import { UserData } from '@/interface/user';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { getUserFromCookie } from '@/lib/cookieStorage';
const getStoredApplication = () => {
if (typeof window !== "undefined") {
@@ -10,24 +9,15 @@ const getStoredApplication = () => {
return null;
};
const getStoredUserData = (): UserData | null => {
if (typeof window === "undefined") {
return null;
}
return getUserFromCookie();
};
interface UserState {
data: UserData | null;
isAuthenticated: boolean;
selectedApplication: any | null;
}
const storedUserData = getStoredUserData();
const initialState: UserState = {
data: storedUserData,
isAuthenticated: Boolean(storedUserData),
data: null,
isAuthenticated: false,
selectedApplication: getStoredApplication(),
};
@@ -39,10 +29,6 @@ const userSlice = createSlice({
state.data = action.payload;
state.isAuthenticated = true;
},
clearUserData: (state) => {
state.data = null;
state.isAuthenticated = false;
},
setSelectedApplication: (state, action: PayloadAction<any>) => {
state.selectedApplication = action.payload;
if (typeof window !== "undefined") {
@@ -58,5 +44,5 @@ const userSlice = createSlice({
},
});
export const { setUserData, clearUserData, setSelectedApplication, clearSelectedApplication } = userSlice.actions;
export const { setUserData, setSelectedApplication, clearSelectedApplication } = userSlice.actions;
export default userSlice.reducer;

View File

@@ -1,5 +1,4 @@
import { configureStore } from '@reduxjs/toolkit';
import { useDispatch, useSelector, TypedUseSelectorHook } from 'react-redux'; // Thêm dòng này
import userReducer from './features/userSlice';
export const store = configureStore({
@@ -9,7 +8,4 @@ export const store = configureStore({
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
export type AppDispatch = typeof store.dispatch;