2024-04-27 16:21:14: merge [main:aa6853211bb46e321bc26b3b8132b18c03592910];
This commit is contained in:
1 parent
a31c44eb7b
commit
a6f4c85231
38 files changed
+1966
-60
No files matched your search
+16
-5
@@ -3,15 +3,19 @@ import { theme } from 'antd'
|
||||
import { MapToken, SeedToken } from 'antd/es/theme/interface'
|
||||
import { createContext, Dispatch, SetStateAction } from 'react'
|
||||
|
||||
import sessionServiceApi from '@services/sessionService.ts'
|
||||
import accessListApi from '@services/accessListService.ts'
|
||||
import appApi from '@services/appService.ts'
|
||||
import applicationsGroupApi from '@services/applicationsGroupService.ts'
|
||||
import applicationsApi from '@services/applicationsService.ts'
|
||||
import modulesServiceApi from '@services/modulesService.ts'
|
||||
import roleApi from '@services/roleService.ts'
|
||||
import securityLogServiceApi from '@services/securityLogService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
import routeApi from '@services/routeService.ts'
|
||||
import securityLogServiceApi from '@services/securityLogService.ts'
|
||||
import sessionServiceApi from '@services/sessionService.ts'
|
||||
import userServiceApi from '@services/userService.ts'
|
||||
|
||||
import profileReducer from './redusers/ProfileSlice.ts'
|
||||
import UIReducer from './redusers/UISlice.ts'
|
||||
|
||||
export interface ContextProps {
|
||||
setTheme: Dispatch<
|
||||
@@ -25,13 +29,17 @@ export const Context = createContext<ContextProps>({
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
profileReducer,
|
||||
UIReducer,
|
||||
[roleApi.reducerPath]: roleApi.reducer,
|
||||
[userServiceApi.reducerPath]: userServiceApi.reducer,
|
||||
[sessionServiceApi.reducerPath]: sessionServiceApi.reducer,
|
||||
[securityLogServiceApi.reducerPath]: securityLogServiceApi.reducer,
|
||||
[appApi.reducerPath]: appApi.reducer,
|
||||
[accessListApi.reducerPath]: accessListApi.reducer,
|
||||
[routeApi.reducerPath]: routeApi.reducer
|
||||
[routeApi.reducerPath]: routeApi.reducer,
|
||||
[modulesServiceApi.reducerPath]: modulesServiceApi.reducer,
|
||||
[applicationsGroupApi.reducerPath]: applicationsGroupApi.reducer,
|
||||
[applicationsApi.reducerPath]: applicationsApi.reducer
|
||||
})
|
||||
|
||||
export const setupStore = () =>
|
||||
@@ -46,7 +54,10 @@ export const setupStore = () =>
|
||||
accessListApi.middleware,
|
||||
routeApi.middleware,
|
||||
userServiceApi.middleware,
|
||||
sessionServiceApi.middleware
|
||||
sessionServiceApi.middleware,
|
||||
modulesServiceApi.middleware,
|
||||
applicationsGroupApi.middleware,
|
||||
applicationsApi.middleware
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,11 +2,15 @@ import { createAsyncThunk } from '@reduxjs/toolkit'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { ProfileDataType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
import {
|
||||
ProfileDataType,
|
||||
UIDataType
|
||||
} from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import { initUI } from '@utils/UIUtiles.tsx'
|
||||
|
||||
import { apiService } from '@services/apiService.ts'
|
||||
|
||||
|
||||
export const fetchProfile = createAsyncThunk(
|
||||
'profile/fetchProfile',
|
||||
async (_, { rejectWithValue }) => {
|
||||
@@ -20,3 +24,15 @@ export const fetchProfile = createAsyncThunk(
|
||||
}
|
||||
}
|
||||
)
|
||||
export const fetchUI = createAsyncThunk(
|
||||
'ui/fetchUI',
|
||||
async (_, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await apiService.post<UIDataType>(apiPaths.getUI)
|
||||
initUI(response.data)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
return rejectWithValue(error)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
ActionReducerMapBuilder,
|
||||
createSlice,
|
||||
PayloadAction
|
||||
} from '@reduxjs/toolkit'
|
||||
|
||||
import { UIDataType, UIType } from '@pages/ProfilePage/profile-page.type.ts'
|
||||
|
||||
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
|
||||
|
||||
import { fetchUI } from './ActionCreators.ts'
|
||||
|
||||
export const initialState: UIType = {
|
||||
ui: {
|
||||
name: '',
|
||||
primaryColor: ''
|
||||
},
|
||||
status: StateProfileStatus.notInit,
|
||||
error: ''
|
||||
}
|
||||
|
||||
export const UISlice = createSlice({
|
||||
name: 'ui',
|
||||
initialState,
|
||||
reducers: {
|
||||
clearUI(state) {
|
||||
state.ui = initialState.ui
|
||||
}
|
||||
},
|
||||
extraReducers: (builder: ActionReducerMapBuilder<UIType>) => {
|
||||
builder
|
||||
.addCase(
|
||||
fetchUI.fulfilled,
|
||||
(state, action: PayloadAction<UIDataType>) => {
|
||||
state.status = StateProfileStatus.resolved
|
||||
state.ui = { ...action.payload }
|
||||
}
|
||||
)
|
||||
.addCase(fetchUI.pending, (state) => {
|
||||
state.status = StateProfileStatus.pending
|
||||
})
|
||||
.addCase(fetchUI.rejected, (state, action: any) => {
|
||||
state.status = StateProfileStatus.rejected
|
||||
state.error = action.payload
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export default UISlice.reducer
|
||||
Reference in new issue
Block a user