- Implemented `getGoogleAuthUrl` and `postGoogleCallback` in auth API. - Added corresponding hooks `useGoogleAuth` and `useGoogleCallback` for handling Google authentication. feat(api): enhance API structure with mentors and upload services - Created `mentors` and `upload` API modules with respective services for managing mentor details and file uploads. - Added session management utilities to handle authentication tokens in cookies. feat(users): expand user service with detailed user management - Enhanced user service to include detailed user information and update capabilities. - Added hooks for fetching and updating user data. feat(hooks): introduce hooks for mentors and upload functionalities - Added hooks for fetching mentor details and updating mentor information. - Implemented hooks for file upload, avatar upload, and CV upload with validation. refactor(types): organize and extend type definitions - Introduced new types for mentors and enhanced existing user types. - Re-exported user-related types for better accessibility. chore: update index files to include new services and hooks - Updated index files to export new services and hooks for mentors and uploads.
90 lines
2.2 KiB
TypeScript
90 lines
2.2 KiB
TypeScript
import { api, ApiResponse } from '../index';
|
|
import { TUserItem } from '../../types/users';
|
|
|
|
export interface UserDetailResponseDto extends TUserItem {
|
|
bio?: string;
|
|
location?: string;
|
|
website_url?: string;
|
|
linkedin_url?: string;
|
|
github_url?: string;
|
|
twitter_url?: string;
|
|
skills?: string[];
|
|
career_status?: string;
|
|
experience?: Array<{
|
|
id: string;
|
|
company: string;
|
|
position: string;
|
|
duration: string;
|
|
period: string;
|
|
}>;
|
|
education?: Array<{
|
|
id: string;
|
|
institution: string;
|
|
degree: string;
|
|
field: string;
|
|
period: string;
|
|
}>;
|
|
}
|
|
|
|
export interface UserUpdateRequestDto {
|
|
fullname?: string;
|
|
bio?: string;
|
|
location?: string;
|
|
website_url?: string;
|
|
linkedin_url?: string;
|
|
github_url?: string;
|
|
twitter_url?: string;
|
|
skills?: string[];
|
|
phone_number?: string;
|
|
birthdate?: string;
|
|
gender?: string;
|
|
career_status?: string;
|
|
avatar?: string;
|
|
cv_url?: string;
|
|
phone_for_verification?: string;
|
|
domicile?: string;
|
|
experience?: Array<{
|
|
id: string;
|
|
company: string;
|
|
position: string;
|
|
duration: string;
|
|
period: string;
|
|
}>;
|
|
education?: Array<{
|
|
id: string;
|
|
institution: string;
|
|
degree: string;
|
|
field: string;
|
|
period: string;
|
|
}>;
|
|
}
|
|
|
|
export interface UserService {
|
|
getUserMe(): Promise<UserDetailResponseDto>;
|
|
getUserById(id: string): Promise<UserDetailResponseDto>;
|
|
updateUserMe(data: UserUpdateRequestDto): Promise<UserDetailResponseDto>;
|
|
updateUserById(id: string, data: UserUpdateRequestDto): Promise<UserDetailResponseDto>;
|
|
}
|
|
|
|
export const userService: UserService = {
|
|
async getUserMe() {
|
|
const response = await api.get<ApiResponse<UserDetailResponseDto>>('/users/me');
|
|
return response.data.data;
|
|
},
|
|
|
|
async getUserById(id: string) {
|
|
const response = await api.get<ApiResponse<UserDetailResponseDto>>(`/users/detail/${id}`);
|
|
return response.data.data;
|
|
},
|
|
|
|
async updateUserMe(data: UserUpdateRequestDto) {
|
|
const response = await api.put<ApiResponse<UserDetailResponseDto>>('/users/update/me', data);
|
|
return response.data.data;
|
|
},
|
|
|
|
async updateUserById(id: string, data: UserUpdateRequestDto) {
|
|
const response = await api.put<ApiResponse<UserDetailResponseDto>>(`/users/${id}`, data);
|
|
return response.data.data;
|
|
},
|
|
};
|