MSP-3237 add fetchUI in ActionCreators

This commit is contained in:
Anastasiia committed 2024-04-27 16:02:27 +03:00
1 parent 96d9a012ee
commit d2c21e7bfc
2 files changed
+21 -3

No files matched your search

+3 -1
View File
@@ -44,6 +44,7 @@ type PathKeys =
| 'getTokensByAppId'
| 'revokeTokens'
| 'revokeTokensForApp'
| 'getUI'
export const apiPaths: Record<PathKeys, string> = {
baseUrl: '/api/kkd-configuration-service',
@@ -61,6 +62,7 @@ export const apiPaths: Record<PathKeys, string> = {
logout: '/api/admin/auth/logout',
// ======= PROFILE ======
getProfile: '/api/admin/user/get_profile',
getUI: '/api/admin/user/get_design',
// ======= USERS ======
getUsers: '/get_users',
createUser: '/create_user',
@@ -99,7 +101,7 @@ export const apiPaths: Record<PathKeys, string> = {
getServicesByDomainId: '/service/get_services_by_domain_id',
// ======= TOKENS ======
createToken: '/token/create_token',
getTokensByAppId: '/token/get_tokens_by_app_id',
getTokensByAppId: '/token/get_tokens_by_app_id',
revokeTokens: '/token/revoke_tokens',
revokeTokensForApp: '/token/revoke_tokens_for_app'
}
+18 -2
View File
@@ -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)
}
}
)