feat(auth): add Google authentication endpoints and hooks (#51)

- 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.
This commit is contained in:
Asep Haryana Saputra
2025-08-18 12:50:32 +07:00
committed by GitHub
parent 65a6bb686c
commit 3c301ec2c4
65 changed files with 7215 additions and 26 deletions
+44 -1
View File
@@ -1 +1,44 @@
export {};
import { useQuery, useMutation, UseQueryResult, UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
import { userService, UserDetailResponseDto, UserUpdateRequestDto } from '../../api/users';
import { TResponseError } from '../../types/common';
export const useUserMe = (options?: UseQueryOptions<UserDetailResponseDto, TResponseError>): UseQueryResult<UserDetailResponseDto, TResponseError> => {
return useQuery({
queryKey: ['user-me'],
queryFn: () => userService.getUserMe(),
...options,
});
};
export const useUserById = (id: string, options?: UseQueryOptions<UserDetailResponseDto, TResponseError>): UseQueryResult<UserDetailResponseDto, TResponseError> => {
return useQuery({
queryKey: ['user-by-id', id],
queryFn: () => userService.getUserById(id),
enabled: !!id,
...options,
});
};
export const useUpdateUserMe = (): UseMutationResult<
UserDetailResponseDto,
TResponseError,
UserUpdateRequestDto,
unknown
> => {
return useMutation({
mutationKey: ['update-user-me'],
mutationFn: (data) => userService.updateUserMe(data),
});
};
export const useUpdateUserById = (): UseMutationResult<
UserDetailResponseDto,
TResponseError,
{ id: string; data: UserUpdateRequestDto },
unknown
> => {
return useMutation({
mutationKey: ['update-user-by-id'],
mutationFn: ({ id, data }) => userService.updateUserById(id, data),
});
};