feat(dimentorin): senpai statistics from API (total sessions, mentee impact, avg rating)

This commit is contained in:
asepharyana
2026-08-04 23:09:15 +07:00
parent 6c5c5db47b
commit a74fabe5f5
5 changed files with 48 additions and 11 deletions
+9
View File
@@ -7,6 +7,7 @@ import {
TMentorDetail,
TMentorListParams,
TMentorRegisterRequest,
TMentorStats,
TSessionFeedbackRequest,
TSessionListResponse,
TBookSessionRequest,
@@ -135,6 +136,14 @@ export const getArticleById = async (id: string): Promise<TArticleDetail> => {
return data.data;
};
export const getMentorStats = async (mentorId: string): Promise<TMentorStats> => {
const { data } = await api({
method: 'GET',
url: `/dimentorin/mentors/${mentorId}/stats`,
});
return data.data;
};
export const postRegisterMentor = async (
payload: TMentorRegisterRequest
): Promise<TResponseMessage> => {
+16 -4
View File
@@ -9,6 +9,7 @@ import {
getMentorMe,
getMentorMeStatus,
getMentorSessions,
getMentorStats,
getMentors,
getMySessions,
postBookSession,
@@ -24,6 +25,7 @@ import {
TMentorDetail,
TMentorListParams,
TMentorRegisterRequest,
TMentorStats,
TSessionFeedbackRequest,
TSessionListResponse,
} from '../../types/dimentorin';
@@ -69,12 +71,22 @@ export const useGetMentorMeStatus = (): UseQueryResult<
};
export const useGetMentorAvailability = (
id: string
mentorId: string
): UseQueryResult<TMentorAvailability, TResponseError> => {
return useQuery({
queryKey: ['get-mentor-availability', id],
queryFn: async () => await getMentorAvailability(id),
enabled: !!id,
queryKey: ['get-mentor-availability', mentorId],
queryFn: async () => await getMentorAvailability(mentorId),
enabled: !!mentorId,
});
};
export const useGetMentorStats = (
mentorId: string
): UseQueryResult<TMentorStats, TResponseError> => {
return useQuery({
queryKey: ['get-mentor-stats', mentorId],
queryFn: async () => await getMentorStats(mentorId),
enabled: !!mentorId,
});
};
@@ -98,6 +98,13 @@ export type TSessionFeedbackRequest = {
rating: number;
};
export type TMentorStats = {
mentor_id: string;
total_sessions: number;
unique_mentees: number;
avg_rating: number;
};
export type TArticleListItem = {
id: string;
title: string;