chore: add parrainage
This commit is contained in:
+18
-2
@@ -7,6 +7,7 @@ import type {
|
||||
TrackingResponse,
|
||||
CancelCommandResponse,
|
||||
PenaltiesResponse,
|
||||
ReferralBalanceResponse,
|
||||
} from "./api_types";
|
||||
import { getToken } from "../auth/tokenStorage";
|
||||
import { extractUsernameFromToken } from "../auth/jwtUtils";
|
||||
@@ -290,6 +291,7 @@ export const checkoutCart = async (
|
||||
nom?: string,
|
||||
prenom?: string,
|
||||
telephone?: string,
|
||||
use_referral_balance?: boolean,
|
||||
): Promise<CheckoutCartResponse> => {
|
||||
const jwtUsername = await getJwtUsername();
|
||||
if (!jwtUsername) return { success: false, message: "Session invalide" };
|
||||
@@ -299,9 +301,10 @@ export const checkoutCart = async (
|
||||
message: "Veuillez saisir une adresse de livraison",
|
||||
};
|
||||
try {
|
||||
const payload: Record<string, string> = {
|
||||
const payload: Record<string, unknown> = {
|
||||
username: jwtUsername,
|
||||
delivery_address,
|
||||
use_referral_balance: use_referral_balance ?? false,
|
||||
};
|
||||
if (nom) payload.nom = nom;
|
||||
if (prenom) payload.prenom = prenom;
|
||||
@@ -315,6 +318,8 @@ export const checkoutCart = async (
|
||||
command: data.command,
|
||||
assigned_to: data.assigned_to,
|
||||
queue_info: data.queue_info,
|
||||
referral_used: data.referral_used,
|
||||
referral_balance: data.referral_balance,
|
||||
};
|
||||
} catch (error: any) {
|
||||
const errMsg: string = error.response?.data?.error || "Erreur serveur";
|
||||
@@ -334,6 +339,15 @@ export const checkoutCart = async (
|
||||
}
|
||||
};
|
||||
|
||||
export const getReferralBalance = async (): Promise<ReferralBalanceResponse> => {
|
||||
try {
|
||||
const { data } = await apiClient.get(`${V1}/referral/balance`);
|
||||
return { success: true, balance: data.balance ?? 0 };
|
||||
} catch {
|
||||
return { success: false, balance: 0, message: "Erreur récupération solde" };
|
||||
}
|
||||
};
|
||||
|
||||
export const approveDelivery = async (
|
||||
commandId: number,
|
||||
reqData?: { rating?: number; comment?: string },
|
||||
@@ -713,6 +727,7 @@ export interface PublicSettings {
|
||||
show_amende_score: boolean;
|
||||
points_enabled: boolean;
|
||||
points_separated: boolean;
|
||||
referral_enabled: boolean;
|
||||
}
|
||||
|
||||
export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
@@ -723,9 +738,10 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
show_amende_score: data.show_amende_score ?? true,
|
||||
points_enabled: data.points_enabled ?? true,
|
||||
points_separated: data.points_separated ?? true,
|
||||
referral_enabled: data.referral_enabled ?? true,
|
||||
};
|
||||
} catch {
|
||||
return { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true };
|
||||
return { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user