chore: add parrainage
This commit is contained in:
@@ -471,6 +471,44 @@ export const deleteClientAdmin = async (clientId: number) => {
|
||||
return { success: true, message: data.message };
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// PARRAINAGE ADMIN
|
||||
// ============================================
|
||||
|
||||
export const creditClientReferral = async (
|
||||
username: string,
|
||||
amount: number,
|
||||
): Promise<{ success: boolean; balance?: number; message?: string }> => {
|
||||
try {
|
||||
const { data } = await apiClient.post(
|
||||
`${V2}/admin/protected/client/${username}/referral/credit`,
|
||||
{ amount },
|
||||
);
|
||||
return { success: true, balance: data.balance, message: data.message };
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.error || "Erreur crédit parrainage",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const getClientReferralAdmin = async (
|
||||
username: string,
|
||||
): Promise<{ success: boolean; balance?: number; message?: string }> => {
|
||||
try {
|
||||
const { data } = await apiClient.get(
|
||||
`${V2}/admin/protected/client/${username}/referral`,
|
||||
);
|
||||
return { success: true, balance: data.balance };
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.error || "Erreur récupération",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// ALERTES
|
||||
// ============================================
|
||||
@@ -676,6 +714,7 @@ export interface AppSettings {
|
||||
points_separated: boolean;
|
||||
points_weed_tiers: PointsTier[];
|
||||
points_zipette_tiers: PointsTier[];
|
||||
referral_enabled: boolean;
|
||||
}
|
||||
|
||||
export const getSettings = async (): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {
|
||||
@@ -687,6 +726,35 @@ export const getSettings = async (): Promise<{ success: boolean; settings?: AppS
|
||||
}
|
||||
};
|
||||
|
||||
export const registerAdminPushToken = async (pushToken: string): Promise<void> => {
|
||||
try {
|
||||
await apiClient.post(`${V2}/admin/protected/push-token`, { push_token: pushToken });
|
||||
} catch { /* ignore */ }
|
||||
};
|
||||
|
||||
export const unregisterAdminPushToken = async (): Promise<void> => {
|
||||
try {
|
||||
await apiClient.delete(`${V2}/admin/protected/push-token`);
|
||||
} catch { /* ignore */ }
|
||||
};
|
||||
|
||||
export interface AppNotification {
|
||||
command_id: number;
|
||||
type: string;
|
||||
message: string;
|
||||
created_at: string;
|
||||
read: boolean;
|
||||
}
|
||||
|
||||
export const getAdminNotifications = async (): Promise<{ notifications: AppNotification[]; unread_count: number }> => {
|
||||
const { data } = await apiClient.get(`${V2}/admin/protected/notifications`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const markAdminNotificationsRead = async (): Promise<void> => {
|
||||
await apiClient.post(`${V2}/admin/protected/notifications/read`);
|
||||
};
|
||||
|
||||
export const updateSettings = async (
|
||||
settings: AppSettings,
|
||||
): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {
|
||||
|
||||
Reference in New Issue
Block a user