MSP-3237 add fetchUI in ActionCreators
This commit is contained in:
1 parent
96d9a012ee
commit
d2c21e7bfc
2 files changed
+21
-3
No files matched your search
@@ -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)
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in new issue
Block a user