This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { apiRequest } from "@/lib/api/api-service";
|
||||
import { ApiResponse } from "@/types/api-response";
|
||||
|
||||
/**
|
||||
* Users Service
|
||||
* Backend: /api/users/*
|
||||
*/
|
||||
|
||||
export interface UpdateProfileDto {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
}
|
||||
|
||||
export interface ChangePasswordDto {
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export interface UserResponseDto {
|
||||
id: string;
|
||||
email: string;
|
||||
firstName: string | null;
|
||||
lastName: string | null;
|
||||
role: string;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
const getMe = () => {
|
||||
return apiRequest<ApiResponse<UserResponseDto>>({
|
||||
url: "/users/me",
|
||||
client: "core",
|
||||
method: "get",
|
||||
});
|
||||
};
|
||||
|
||||
const updateMe = (dto: UpdateProfileDto) => {
|
||||
return apiRequest<ApiResponse<UserResponseDto>>({
|
||||
url: "/users/me",
|
||||
client: "core",
|
||||
method: "put",
|
||||
data: dto,
|
||||
});
|
||||
};
|
||||
|
||||
const changePassword = (dto: ChangePasswordDto) => {
|
||||
return apiRequest<ApiResponse<null>>({
|
||||
url: "/users/me/password",
|
||||
client: "core",
|
||||
method: "patch",
|
||||
data: dto,
|
||||
});
|
||||
};
|
||||
|
||||
export const usersService = {
|
||||
getMe,
|
||||
updateMe,
|
||||
changePassword,
|
||||
};
|
||||
Reference in New Issue
Block a user