chore: update
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
// ✅ loginUser et registerUser retournent AuthResponse
|
||||
// ✅ sessionStorage (pas localStorage)
|
||||
|
||||
const API_URL = "https://uber-stup.club/api/v1";
|
||||
const BACKEND_URL = "https://uber-stup.club";
|
||||
const API_URL = "http://5.181.0.112/api/v1";
|
||||
const BACKEND_URL = "http://5.181.0.112";
|
||||
|
||||
export function getMediaUrl(url: string): string {
|
||||
if (!url) return "";
|
||||
@@ -683,7 +683,10 @@ export const createCheckout = async (checkoutData: CheckoutData) => {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify(checkoutData),
|
||||
body: JSON.stringify({
|
||||
...checkoutData,
|
||||
use_referral_balance: checkoutData.use_referral_balance ?? false,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
@@ -783,6 +786,24 @@ export interface Product {
|
||||
media?: MediaItem[]; // ✅ CHANGÉ: string[] → MediaItem[]
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
color: string;
|
||||
is_coming_soon: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export const getCategories = async (): Promise<Category[]> => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/categories`);
|
||||
const data = await response.json();
|
||||
return data.categories || [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
export const getAllProducts = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/products`);
|
||||
@@ -968,8 +989,9 @@ export const getOrderETA = async (commandId: number): Promise<ETAResponse> => {
|
||||
success: true,
|
||||
command_id: data.id || commandId,
|
||||
eta_minutes: data.eta_minutes || 0,
|
||||
estimated_arrival: data.estimated_arrival || "N/A",
|
||||
estimated_arrival: data.estimated_arrival || "",
|
||||
status: data.status || "pending",
|
||||
eta_available: data.eta_available === true,
|
||||
livreur_distance: data.livreur_distance,
|
||||
message: "ETA récupéré",
|
||||
};
|
||||
@@ -1805,3 +1827,50 @@ export const markNotificationsRead = async (): Promise<{
|
||||
return { success: false };
|
||||
}
|
||||
};
|
||||
|
||||
export interface PublicSettings {
|
||||
penalties_enabled: boolean;
|
||||
show_amende_score: boolean;
|
||||
points_enabled: boolean;
|
||||
points_separated: boolean;
|
||||
referral_enabled: boolean;
|
||||
}
|
||||
|
||||
export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
const defaults: PublicSettings = { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/app-settings`);
|
||||
if (!response.ok) return defaults;
|
||||
const data = await response.json();
|
||||
return {
|
||||
penalties_enabled: data.penalties_enabled ?? true,
|
||||
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 defaults;
|
||||
}
|
||||
};
|
||||
|
||||
export interface ReferralBalanceResponse {
|
||||
success: boolean;
|
||||
balance: number;
|
||||
referral_enabled?: boolean;
|
||||
}
|
||||
|
||||
export const getReferralBalance = async (): Promise<ReferralBalanceResponse> => {
|
||||
const token = getAuthToken();
|
||||
if (!token) return { success: false, balance: 0 };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/referral/balance`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!response.ok) return { success: false, balance: 0 };
|
||||
const data = await response.json();
|
||||
return { success: true, balance: data.balance ?? 0, referral_enabled: data.referral_enabled };
|
||||
} catch {
|
||||
return { success: false, balance: 0 };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user