feat(dimentorin): wire appointment payment flow to payments API

- PaymentStep: selectable VA/QRIS method, rate from mentor.mentoring_rate (fallback 50000), onMethodChange
- AppointmentModal: book session -> create payment -> route to VA/QRIS step with real payment data; then success
- QrisPaymentStep/VAPaymentStep: show real total + external_ref (VA number/QR ref) + expiry
- service lib: TPayment/TCreatePaymentRequest types + postCreatePayment/getMyPayments/getPaymentById/postConfirmPayment + hooks
- build verified, payments flow bundled
This commit is contained in:
asepharyana
2026-08-05 09:28:56 +07:00
parent a74fabe5f5
commit 893f7ba03c
7 changed files with 209 additions and 30 deletions
@@ -11,8 +11,12 @@ import {
getMentorSessions,
getMentorStats,
getMentors,
getMyPayments,
getMySessions,
getPaymentById,
postBookSession,
postConfirmPayment,
postCreatePayment,
postRegisterMentor,
postSessionFeedback,
} from '../../api/dimentorin';
@@ -21,11 +25,13 @@ import {
TArticleListItem,
TArticleListParams,
TBookSessionRequest,
TCreatePaymentRequest,
TMentorAvailability,
TMentorDetail,
TMentorListParams,
TMentorRegisterRequest,
TMentorStats,
TPayment,
TSessionFeedbackRequest,
TSessionListResponse,
} from '../../types/dimentorin';
@@ -134,6 +140,41 @@ export const usePostRegisterMentor = () => {
});
};
export const usePostCreatePayment = (sessionId: string) => {
return useMutation({
mutationKey: ['post-create-payment', sessionId],
mutationFn: async (payload: TCreatePaymentRequest) =>
await postCreatePayment(sessionId, payload),
});
};
export const useGetMyPayments = (): UseQueryResult<
TPayment[],
TResponseError
> => {
return useQuery({
queryKey: ['get-my-payments'],
queryFn: async () => await getMyPayments(),
});
};
export const useGetPaymentById = (
id: string
): UseQueryResult<TPayment, TResponseError> => {
return useQuery({
queryKey: ['get-payment-by-id', id],
queryFn: async () => await getPaymentById(id),
enabled: !!id,
});
};
export const usePostConfirmPayment = () => {
return useMutation({
mutationKey: ['post-confirm-payment'],
mutationFn: async (id: string) => await postConfirmPayment(id),
});
};
export const useGetArticles = (
params?: TArticleListParams
): UseQueryResult<TArticleListItem[], TResponseError> => {