chore: build
This commit is contained in:
@@ -92,9 +92,6 @@ export const extractUsernameFromToken = (): string | null => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ✅ Synchroniser sessionStorage avec JWT
|
||||
*/
|
||||
export const syncUsernameFromJWT = (): string | null => {
|
||||
const jwtUsername = extractUsernameFromToken();
|
||||
|
||||
@@ -700,6 +697,8 @@ export const createCheckout = async (checkoutData: CheckoutData) => {
|
||||
message: data.error || "Erreur création",
|
||||
postal_code: data.postal_code as string | undefined,
|
||||
zone_error: isZoneError as boolean,
|
||||
invalid_address: !!data.corrected_address,
|
||||
suggested_address: data.corrected_address as string | undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1863,6 +1862,13 @@ export interface PublicSettings {
|
||||
shop_name: string;
|
||||
two_fa_enabled: boolean;
|
||||
contact_telegram: string;
|
||||
client_color_primary: string;
|
||||
client_color_secondary: string;
|
||||
client_color_success: string;
|
||||
client_color_danger: string;
|
||||
client_color_warning: string;
|
||||
client_title_gradient_from: string;
|
||||
client_title_gradient_to: string;
|
||||
}
|
||||
|
||||
export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
@@ -1880,6 +1886,13 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
shop_name: "Milieu-Nantais",
|
||||
two_fa_enabled: false,
|
||||
contact_telegram: "",
|
||||
client_color_primary: "#8b5cf6",
|
||||
client_color_secondary: "#22d3ee",
|
||||
client_color_success: "#22c55e",
|
||||
client_color_danger: "#ef4444",
|
||||
client_color_warning: "#f59e0b",
|
||||
client_title_gradient_from: "#a78bfa",
|
||||
client_title_gradient_to: "#22d3ee",
|
||||
};
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/app-settings`);
|
||||
@@ -1904,6 +1917,15 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
shop_name: data.shop_name || "Milieu-Nantais",
|
||||
two_fa_enabled: data.two_fa_enabled ?? false,
|
||||
contact_telegram: data.contact_telegram || "",
|
||||
client_color_primary: data.client_color_primary || "#8b5cf6",
|
||||
client_color_secondary: data.client_color_secondary || "#22d3ee",
|
||||
client_color_success: data.client_color_success || "#22c55e",
|
||||
client_color_danger: data.client_color_danger || "#ef4444",
|
||||
client_color_warning: data.client_color_warning || "#f59e0b",
|
||||
client_title_gradient_from:
|
||||
data.client_title_gradient_from || "#a78bfa",
|
||||
client_title_gradient_to:
|
||||
data.client_title_gradient_to || "#22d3ee",
|
||||
};
|
||||
} catch {
|
||||
return defaults;
|
||||
@@ -2152,6 +2174,13 @@ export type RewardCategoryConfig = {
|
||||
amount: number;
|
||||
};
|
||||
|
||||
export type RewardItemConfig = {
|
||||
product_id: number;
|
||||
product_name: string;
|
||||
quantity: number;
|
||||
price: number;
|
||||
};
|
||||
|
||||
export type PointsPoolInfo = {
|
||||
key: string;
|
||||
name: string;
|
||||
@@ -2160,13 +2189,7 @@ export type PointsPoolInfo = {
|
||||
rewards_claimed: number;
|
||||
rewards_available: number;
|
||||
eligible_configs: RewardCategoryConfig[];
|
||||
};
|
||||
|
||||
export type RewardItemConfig = {
|
||||
product_id: number;
|
||||
product_name: string;
|
||||
quantity: number;
|
||||
price: number;
|
||||
eligible_reward_items: RewardItemConfig[];
|
||||
};
|
||||
|
||||
export type PointsRewardConfig = {
|
||||
@@ -2183,12 +2206,14 @@ export const getMyPointsRewards = async (): Promise<{
|
||||
reward: PointsRewardConfig | null;
|
||||
}> => {
|
||||
const token = getAuthToken();
|
||||
if (!token) return { success: false, enabled: false, pools: [], reward: null };
|
||||
if (!token)
|
||||
return { success: false, enabled: false, pools: [], reward: null };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/points/rewards`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!response.ok) return { success: false, enabled: false, pools: [], reward: null };
|
||||
if (!response.ok)
|
||||
return { success: false, enabled: false, pools: [], reward: null };
|
||||
const data = await safeJson(response);
|
||||
return {
|
||||
success: true,
|
||||
@@ -2201,12 +2226,58 @@ export const getMyPointsRewards = async (): Promise<{
|
||||
}
|
||||
};
|
||||
|
||||
export const claimMyReward = async (poolKey: string): Promise<{
|
||||
export const submitLivreurRating = async (
|
||||
orderId: number,
|
||||
rating: number,
|
||||
comment: string,
|
||||
): Promise<{ success: boolean; error?: string }> => {
|
||||
const token = getAuthToken();
|
||||
if (!token) return { success: false, error: "Non authentifié" };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/orders/${orderId}/rate`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify({ rating, comment }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
const data = await safeJson(response);
|
||||
return { success: false, error: data.error || "Erreur" };
|
||||
}
|
||||
return { success: true };
|
||||
} catch {
|
||||
return { success: false, error: "Erreur de connexion" };
|
||||
}
|
||||
};
|
||||
|
||||
export const getOrderRatingStatus = async (
|
||||
orderId: number,
|
||||
): Promise<{ rated: boolean; rating?: number; comment?: string }> => {
|
||||
const token = getAuthToken();
|
||||
if (!token) return { rated: false };
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/orders/${orderId}/rating`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!response.ok) return { rated: false };
|
||||
const data = await safeJson(response);
|
||||
return data;
|
||||
} catch {
|
||||
return { rated: false };
|
||||
}
|
||||
};
|
||||
|
||||
export const claimMyReward = async (
|
||||
poolKey: string,
|
||||
productId?: number,
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
description?: string;
|
||||
remaining_rewards?: number;
|
||||
product_added?: boolean;
|
||||
product_name?: string;
|
||||
product_names?: string[];
|
||||
error?: string;
|
||||
}> => {
|
||||
const token = getAuthToken();
|
||||
@@ -2218,16 +2289,20 @@ export const claimMyReward = async (poolKey: string): Promise<{
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify({ pool_key: poolKey }),
|
||||
body: JSON.stringify({
|
||||
pool_key: poolKey,
|
||||
product_id: productId ?? 0,
|
||||
}),
|
||||
});
|
||||
const data = await safeJson(response);
|
||||
if (!response.ok) return { success: false, error: data.error || "Erreur" };
|
||||
if (!response.ok)
|
||||
return { success: false, error: data.error || "Erreur" };
|
||||
return {
|
||||
success: true,
|
||||
description: data.description,
|
||||
remaining_rewards: data.remaining_rewards,
|
||||
product_added: data.product_added,
|
||||
product_name: data.product_name,
|
||||
product_names: data.product_names,
|
||||
};
|
||||
} catch {
|
||||
return { success: false, error: "Erreur de connexion" };
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// ============================================
|
||||
// api/api_TYPES.ts - TOUTES LES INTERFACES
|
||||
// ============================================
|
||||
|
||||
export interface ApiResponse {
|
||||
success: boolean;
|
||||
message?: string;
|
||||
@@ -91,6 +95,10 @@ export interface RegisterAdminRequest {
|
||||
role: "admin" | "cabine" | "livreur";
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// 🛒 PANIER - TYPES
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Item du panier côté frontend
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user