MSP-3104 add getProfile method
This commit is contained in:
1 parent
8cfb1ad921
commit
83f5a04f48
4 files changed
+25
-8
No files matched your search
@@ -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'
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user