feat: integrate all backend APIs into frontend apps
- 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>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
8d2aaf5188
commit
53ad40f3fd
@@ -1,45 +1,72 @@
|
||||
import { useQuery, useMutation, UseQueryResult, UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
|
||||
import { mentorService } from '../../api/mentors';
|
||||
import { MentorDetailResponseDto, MentorUpdateRequestDto } from '../../types/mentors';
|
||||
import { TResponseError } from '../../types/common';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
getMentorMe,
|
||||
getMentorById,
|
||||
getMentorList,
|
||||
updateMentorMe,
|
||||
updateMentorById,
|
||||
verifyMentor,
|
||||
deleteMentor,
|
||||
} from '../../api/mentors';
|
||||
import type { MentorDetailResponseDto, MentorUpdateRequestDto } from '../../types/mentors';
|
||||
import type { TPaginationParams } from '../../types/common';
|
||||
|
||||
export const useMentorMe = (options?: UseQueryOptions<MentorDetailResponseDto, TResponseError>): UseQueryResult<MentorDetailResponseDto, TResponseError> => {
|
||||
export const useMentorMe = () => {
|
||||
return useQuery({
|
||||
queryKey: ['mentor-me'],
|
||||
queryFn: () => mentorService.getMentorMe(),
|
||||
...options,
|
||||
queryFn: getMentorMe,
|
||||
});
|
||||
};
|
||||
|
||||
export const useMentorById = (id: string, options?: UseQueryOptions<MentorDetailResponseDto, TResponseError>): UseQueryResult<MentorDetailResponseDto, TResponseError> => {
|
||||
export const useMentorById = (id: string) => {
|
||||
return useQuery({
|
||||
queryKey: ['mentor-by-id', id],
|
||||
queryFn: () => mentorService.getMentorById(id),
|
||||
queryFn: () => getMentorById(id),
|
||||
enabled: !!id,
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateMentorMe = (): UseMutationResult<
|
||||
MentorDetailResponseDto,
|
||||
TResponseError,
|
||||
MentorUpdateRequestDto,
|
||||
unknown
|
||||
> => {
|
||||
export const useMentorList = (params?: TPaginationParams) => {
|
||||
return useQuery({
|
||||
queryKey: ['mentor-list', params],
|
||||
queryFn: () => getMentorList(params),
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateMentorMe = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationKey: ['update-mentor-me'],
|
||||
mutationFn: (data) => mentorService.updateMentorMe(data),
|
||||
mutationFn: (data: MentorUpdateRequestDto) => updateMentorMe(data),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['mentor-me'] }),
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateMentorById = (): UseMutationResult<
|
||||
MentorDetailResponseDto,
|
||||
TResponseError,
|
||||
{ id: string; data: MentorUpdateRequestDto },
|
||||
unknown
|
||||
> => {
|
||||
export const useUpdateMentorById = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationKey: ['update-mentor-by-id'],
|
||||
mutationFn: ({ id, data }) => mentorService.updateMentorById(id, data),
|
||||
mutationFn: ({ id, data }: { id: string; data: MentorUpdateRequestDto }) =>
|
||||
updateMentorById(id, data),
|
||||
onSuccess: (_, vars) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['mentor-by-id', vars.id] });
|
||||
queryClient.invalidateQueries({ queryKey: ['mentor-list'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const useVerifyMentor = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => verifyMentor(id),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['mentor-list'] }),
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteMentor = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => deleteMentor(id),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['mentor-list'] }),
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user