MSP-3104 add getProfile method

This commit is contained in:
veselovnk committed 2024-04-10 14:39:37 +03:00
1 parent 8cfb1ad921
commit 83f5a04f48
4 files changed
+25 -8

No files matched your search

+12 -2
View File
@@ -1,4 +1,12 @@
type PathKeys = 'baseUrl' | 'getAllRoles' | 'createRole' | 'updateRole' | 'deleteRole' | 'login' | 'logout'
type PathKeys =
| 'baseUrl'
| 'getAllRoles'
| 'createRole'
| 'updateRole'
| 'deleteRole'
| 'login'
| 'logout'
| 'getProfile'
export const apiPaths: Record<PathKeys, string> = {
baseUrl: '/api/admin',
// ======= ROLES ======
@@ -8,5 +16,7 @@ export const apiPaths: Record<PathKeys, string> = {
deleteRole: '/role/delete',
// ======= AUTH ======
login: '/api/admin/auth/login',
logout: '/api/admin/auth/logout'
logout: '/api/admin/auth/logout',
// ======= PROFILE ======
getProfile: '/api/admin/user/get_profile'
}
+1 -1
View File
@@ -17,7 +17,7 @@ export const apiService = axios.create({
apiService.defaults.headers.post['X-APPLICATION-TOKEN'] = getConfigProperty(
'APP_TOKEN',
import.meta.env.APP_TOKEN
import.meta.env.VITE_APP_TOKEN
)
apiService.interceptors.request.use(
+5 -2
View File
@@ -2,15 +2,18 @@ import { createAsyncThunk } from '@reduxjs/toolkit'
import { apiPaths } from '@constants/api/apiPaths.ts'
import { ProfileDataType } from '@pages/ProfilePage/profile-page.type.ts'
import { apiService } from '@services/apiService.ts'
import { ProfileDataType } from '@type/profile.type.ts'
export const fetchProfile = createAsyncThunk(
'profile/fetchProfile',
async (_, { rejectWithValue }) => {
try {
const response = await apiService.post<ProfileDataType>(apiPaths.baseUrl)
const response = await apiService.post<ProfileDataType>(
apiPaths.getProfile
)
return response.data
} catch (error) {
return rejectWithValue(error)
+7 -3
View File
@@ -1,13 +1,17 @@
import {
ActionReducerMapBuilder,
PayloadAction,
createSlice
createSlice,
PayloadAction
} from '@reduxjs/toolkit'
import { ProfileDataType, ProfileType } from '@type/profile.type.ts'
import {
ProfileDataType,
ProfileType
} from '@pages/ProfilePage/profile-page.type.ts'
import { fetchProfile } from './ActionCreators.ts'
export enum StateProfileStatus {
resolved = 'resolved',
pending = 'pending',