Files
2026-06-06 14:11:51 +03:30

27 lines
982 B
TypeScript

import { apiClient } from './client';
import { PendingReferralRewardsResponse, FulfillReferralRewardResponse } from '@/types/referral';
export const referralApi = {
// List users who reached the invite target and have not been granted the free month yet
getPendingRewards: async (token: string): Promise<PendingReferralRewardsResponse> => {
return apiClient.get<PendingReferralRewardsResponse>('/admin/referral-rewards', token);
},
// Grant the free month to a user. product_id is optional: omit it to
// auto-grant the meditation package's monthly product.
fulfillReward: async (
userId: number,
token: string,
productId?: number
): Promise<FulfillReferralRewardResponse> => {
const data = productId ? { product_id: productId } : {};
return apiClient.post<FulfillReferralRewardResponse>(
`/admin/referral-rewards/${userId}/fulfill`,
data,
token
);
}
};