- Fix API service paths to use /v1/iam/, /v1/dimentorin/, /v1/gacha/, /v1/hackathon/ prefixes - Add roles, permissions, events, testimonials, sessions API services and hooks - Rewrite gacha service with full CRUD + roll/claim endpoints - Replace all mock data in backoffice pages with real API calls (accounts, roles, permissions, gacha-roll, dashboard, sessions, users-dimentorin, feedback-review, settings) - Wire dimentorin mentoring list to useMentorList with search + pagination - Wire dimentorin mentor detail page to useMentorById, pass real data to all sections - Wire appointment modal to useBookSession with controlled schedule inputs - Wire gacha app Spin Now to useExecuteGachaRoll, show credits and real items Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.6 KiB
TypeScript
70 lines
2.6 KiB
TypeScript
import { api, ApiResponse } from '../index';
|
|
import type {
|
|
TUsersListItem,
|
|
TUsersDetailItem,
|
|
TUserCreateRequest,
|
|
TUserUpdateRequest,
|
|
} from '../../types/users';
|
|
import type { TApiPaginated, TPaginationParams } from '../../types/common';
|
|
|
|
// Re-export for backward compatibility
|
|
export type UserDetailResponseDto = TUsersDetailItem;
|
|
export type UserUpdateRequestDto = TUserUpdateRequest;
|
|
|
|
export const getUserList = async (params?: TPaginationParams): Promise<TApiPaginated<TUsersListItem>> => {
|
|
const response = await api.get<TApiPaginated<TUsersListItem>>('/v1/iam/users', { params });
|
|
return response.data;
|
|
};
|
|
|
|
export const getUserMe = async (): Promise<TUsersDetailItem> => {
|
|
const response = await api.get<ApiResponse<TUsersDetailItem>>('/v1/iam/users/me');
|
|
return response.data.data;
|
|
};
|
|
|
|
export const getUserById = async (id: string): Promise<TUsersDetailItem> => {
|
|
const response = await api.get<ApiResponse<TUsersDetailItem>>(`/v1/iam/users/detail/${id}`);
|
|
return response.data.data;
|
|
};
|
|
|
|
export const createUser = async (data: TUserCreateRequest): Promise<TUsersDetailItem> => {
|
|
const response = await api.post<ApiResponse<TUsersDetailItem>>('/v1/iam/users/create', data);
|
|
return response.data.data;
|
|
};
|
|
|
|
export const updateUserMe = async (data: TUserUpdateRequest): Promise<TUsersDetailItem> => {
|
|
const response = await api.put<ApiResponse<TUsersDetailItem>>('/v1/iam/users/update/me', data);
|
|
return response.data.data;
|
|
};
|
|
|
|
export const updateUserById = async (id: string, data: TUserUpdateRequest): Promise<TUsersDetailItem> => {
|
|
const response = await api.put<ApiResponse<TUsersDetailItem>>(`/v1/iam/users/update/${id}`, data);
|
|
return response.data.data;
|
|
};
|
|
|
|
export const activateUser = async (id: string, is_active: boolean): Promise<{ message: string }> => {
|
|
const response = await api.put<{ message: string }>(`/v1/iam/users/activate/${id}`, { is_active });
|
|
return response.data;
|
|
};
|
|
|
|
export const deleteUser = async (id: string): Promise<{ message: string }> => {
|
|
const response = await api.delete<{ message: string }>(`/v1/iam/users/delete/${id}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const uploadUserFile = async (file: File): Promise<{ url: string }> => {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
const response = await api.post<ApiResponse<{ url: string }>>('/v1/iam/users/upload', formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
});
|
|
return response.data.data;
|
|
};
|
|
|
|
// Legacy service object for backward compatibility
|
|
export const userService = {
|
|
getUserMe,
|
|
getUserById,
|
|
updateUserMe,
|
|
updateUserById: (id: string, data: TUserUpdateRequest) => updateUserById(id, data),
|
|
};
|