chore: build
Omnex Plateform App - EAS Build / build (push) Canceled after 7m42s
Omnex Plateform Client - EAS Build / build (push) Canceled after 4m43s

This commit is contained in:
Xor290
2026-08-04 21:18:12 +02:00
parent f75cf5700c
commit bef57d91de
55 changed files with 24850 additions and 5 deletions
File diff suppressed because it is too large Load Diff
+781
View File
@@ -0,0 +1,781 @@
// ============================================
// api/api_TYPES.ts - TOUTES LES INTERFACES
// ============================================
export interface ApiResponse {
success: boolean;
message?: string;
error?: string;
access_token?: string;
token_type?: string;
expires_in?: number;
user?: UserResponse;
[key: string]: any; // Pour les champs additionnels
}
/**
* Données utilisateur retournées après login/register
*/
export interface UserResponse {
id: number;
username: string;
nom?: string;
prenom?: string;
telephone?: string;
role?: string;
session_id?: string;
command?: number;
point_extra?: number;
amende?: number;
must_change_password?: boolean;
}
/**
* Requête de login
*/
export interface LoginRequest {
username: string;
password: string;
}
/**
* Réponse de login
*/
export interface LoginResponse {
success: boolean;
message?: string;
access_token?: string;
token_type?: string;
expires_in?: number;
user?: UserResponse;
}
/**
* Requête d'enregistrement client
*/
export interface RegisterRequest {
username: string;
password: string;
nom: string;
prenom: string;
telephone: string;
}
/**
* Alternative: RegisterData (utilisée dans Register.tsx)
*/
export interface RegisterData {
username: string;
password: string;
nom: string;
prenom: string;
telephone: string;
}
/**
* Réponse d'enregistrement
*/
export interface RegisterResponse {
success: boolean;
message?: string;
access_token?: string;
token_type?: string;
expires_in?: number;
user?: UserResponse;
}
/**
* Requête d'enregistrement admin
*/
export interface RegisterAdminRequest {
username: string;
password: string;
role: "admin" | "cabine" | "livreur";
}
// ============================================
// 🛒 PANIER - TYPES
// ============================================
/**
* Item du panier côté frontend
*/
export interface CartItem {
id: number;
product_id: number;
name_product: string;
price: number;
quantity: number;
category: string;
image?: string;
}
/**
* Item du panier retourné par l'API
*/
export interface BasketItem {
id: number;
product_id: number;
username: string;
name_product?: string;
product_name?: string;
category: string;
price: number;
quantity: number;
image?: string;
created_at?: string;
updated_at?: string;
}
/**
* Requête d'ajout au panier
*/
export interface AddToBasketRequest {
username: string;
name_product: string;
category: string;
quantity: number;
price: number;
}
/**
* Réponse du panier
*/
export interface BasketResponse {
success: boolean;
message?: string;
panier?: BasketItem[];
data?: {
panier?: BasketItem[];
};
count?: number;
total?: number;
}
/**
* Requête de suppression du panier
*/
export interface RemoveFromBasketRequest {
id: number;
username: string;
}
/**
* Requête de vidage du panier
*/
export interface ClearBasketRequest {
username: string;
}
// ============================================
// 📦 COMMANDES - TYPES
// ============================================
/**
* Requête de checkout
*/
export interface CheckoutRequest {
username: string;
delivery_address: string;
first_name?: string;
last_name?: string;
phone?: string;
payment_method?: string;
}
/**
* Data pour le checkout
*/
export interface CheckoutData {
username?: string;
delivery_address: string;
first_name?: string;
last_name?: string;
phone?: string;
payment_method?: string;
}
/**
* Item de commande
*/
export interface OrderItem {
id: number;
command_id: number;
produit?: string;
product_name?: string;
name_product?: string;
prix?: number;
price?: number;
quantite?: number;
quantity?: number;
category?: string;
image?: string;
}
/**
* Détails d'une commande
*/
export interface OrderDetail {
id: number;
client_order_number?: number;
username: string;
status: string;
delivery_address?: string;
adresse?: string;
created_at: string;
updated_at?: string;
total?: number;
total_prix?: number;
livreur_assign?: string;
items?: OrderItem[];
// Infos client enrichies
client_id?: number;
client_prenom?: string;
client_nom?: string;
client_telephone?: string;
// Infos du formulaire checkout
first_name?: string;
last_name?: string;
phone?: string;
// Infos livreur
livreur_username?: string;
livreur_distance?: number;
// Métadonnées
payment_method?: string;
notes?: string;
// Proposition de modification d'adresse
proposed_address?: string | null;
address_proposal_status?: "none" | "pending" | "accepted" | "rejected";
[key: string]: any;
}
/**
* Réponse des commandes
*/
export interface OrdersResponse {
success: boolean;
message?: string;
commands?: OrderDetail[];
count?: number;
}
/**
* Informations de livraison assignée
*/
export interface AssignedDelivery {
username: string;
distance_km: number;
eta_minutes: number;
last_update?: string;
status?: string;
}
/**
* Position dans la file d'attente
*/
export interface QueueInfo {
position: number;
status: string;
estimated_wait: string;
total_in_queue?: number;
}
/**
* Réponse de checkout
*/
export interface CheckoutResponse {
success: boolean;
message?: string;
command_id?: number;
command?: {
id: number;
status: string;
total?: number;
livreur_assign?: string;
created_at?: string;
};
delivery_address?: string;
assigned_to?: AssignedDelivery;
queue_info?: QueueInfo;
}
/**
* Requête d'approbation de livraison
*/
export interface ApproveDeliveryRequest {
rating?: number;
comment?: string;
}
/**
* Réponse d'approbation
*/
export interface ApproveDeliveryResponse {
success: boolean;
message?: string;
points_earned?: number;
category?: string; // ✅ AJOUTER CETTE LIGNE
points_info?: string; // ✅ AJOUTER CETTE LIGNE
}
// ============================================
// 📍 TRACKING & SUIVI - TYPES
// ============================================
export interface TrackingResponse {
success: boolean;
command_id: number;
status: string;
current_step: string;
livreur?: string;
livreur_username?: string;
livreur_distance?: number;
estimated_arrival?: string;
eta_minutes?: number;
location?: {
latitude: number;
longitude: number;
};
delivery_address?: string;
incidents_detected?: number;
updated_at?: number;
created_at?: string;
message?: string;
[key: string]: any;
}
// ============================================
// 📦 PRODUITS - TYPES
// ============================================
export interface ProductPrice {
quantity: number;
price: number;
active_price?: boolean;
}
export interface Product {
id: number;
name: string;
description?: string;
category: string;
stock: number;
unit?: string;
prices?: ProductPrice[];
media?: Array<{
// ✅ CHANGÉ
url: string;
type: string;
id?: number;
created_at?: string;
}>;
created_at?: string;
updated_at?: string;
[key: string]: any;
}
export interface ProductsResponse {
success: boolean;
message?: string;
data?: Product[];
products?: Product[];
count?: number;
[key: string]: any;
}
/**
* Réponse produit unique
*/
export interface ProductResponse {
success: boolean;
message?: string;
data?: Product;
product?: Product;
}
// ============================================
// 🔐 SESSION - TYPES
// ============================================
/**
* Données de session côté frontend
*/
export interface SessionData {
token: string;
username: string;
user_id?: number;
session_id?: string;
created_at?: number;
expires_at?: number;
}
/**
* JWT Payload (claims)
*/
export interface JWTPayload {
client_id?: number;
user_id?: number;
username: string;
role: string;
session_id: string;
iat: number;
exp: number;
iss: string;
[key: string]: any;
}
// ============================================
// 🎯 ERROR - TYPES
// ============================================
/**
* Réponse d'erreur API
*/
export interface ErrorResponse {
success: false;
error: string;
message?: string;
details?: string;
status_code?: number;
[key: string]: any;
}
/**
* Erreur de validation
*/
export interface ValidationError {
field: string;
message: string;
}
/**
* Réponse de validation échouée
*/
export interface ValidationErrorResponse {
success: false;
errors: ValidationError[];
message?: string;
}
// ============================================
// 📊 CONTEXTE PANIER - TYPES
// ============================================
/**
* État du contexte panier
*/
export interface CartContextState {
cartItems: CartItem[];
cartCount: number;
cartTotal: number;
loading: boolean;
isAuthenticated: boolean;
error?: string;
}
/**
* Actions du contexte panier
*/
export interface CartContextActions {
addToCart: (item: Omit<CartItem, "id">) => Promise<void>;
removeFromCart: (id: number) => Promise<void>;
updateQuantity: (id: number, quantity: number) => Promise<void>;
clearCart: () => Promise<void>;
refreshCart: () => Promise<void>;
showToast: (
message: string,
type: "success" | "error" | "warning" | "info",
) => void;
}
/**
* Toast notification
*/
export interface ToastMessage {
id: string;
message: string;
type: "success" | "error" | "warning" | "info";
duration?: number;
}
// ============================================
// 🔐 AUTHENTIFICATION UTILS - TYPES
// ============================================
/**
* Résultat de validation du formulaire de login
*/
export interface LoginFormValidation {
valid: boolean;
errors: {
username?: string;
password?: string;
};
}
/**
* Résultat de validation du formulaire d'enregistrement
*/
export interface RegisterFormValidation {
valid: boolean;
errors: {
nom?: string;
prenom?: string;
telephone?: string;
username?: string;
password?: string;
};
}
/**
* État du formulaire de login
*/
export interface LoginFormState {
username: string;
password: string;
}
/**
* État du formulaire d'enregistrement
*/
export interface RegisterFormState {
nom: string;
prenom: string;
telephone: string;
username: string;
password: string;
}
/**
* État du formulaire de checkout
*/
export interface CheckoutFormState {
firstName: string;
lastName: string;
address: string;
phone: string;
paymentMethod: string;
}
export interface CompletedOrder {
id: number;
client_order_number?: number;
username: string;
status: string;
adresse: string;
total_prix: number;
referral_used?: number;
livreur_assign?: string;
created_at: string;
updated_at: string;
}
export interface ClientStats {
username: string;
nom?: string;
prenom?: string;
telephone?: string;
total_commands: number;
points: number;
pool_points: number[];
pool_names: string[];
penalties: number;
}
export interface HistoryResponse {
success: boolean;
commands: CompletedOrder[];
count: number;
client_stats?: ClientStats;
message?: string;
}
export interface ETAResponse {
success: boolean;
command_id: number;
eta_minutes: number;
estimated_arrival: string;
status: string;
livreur_distance?: number;
message?: string;
[key: string]: any;
}
// ============================================
// 🚫 ANNULATION DE COMMANDES - TYPES
// ============================================
export interface CancelCommandRequest {
reason?: string;
force?: boolean;
}
export interface PenaltyDetails {
points: number;
total_violations: number;
reason: string;
message: string;
}
export interface PenaltyWarning {
will_apply: boolean;
penalty_amount: number;
current_violations: number;
message: string;
scale: {
"1st_cancel": string;
"2nd_cancel": string;
"3rd_cancel": string;
"4th+_cancel": string;
your_next: string;
};
}
export interface CancelCommandResponse {
success: boolean;
message?: string;
warning?: boolean;
command_id?: number;
penalty?: PenaltyDetails;
penalty_warning?: PenaltyWarning;
details?: {
livreur?: string;
status?: string;
position_in_queue?: number;
queue_info?: any;
};
action_required?: string;
example?: any;
new_status?: string;
cancelled_by?: {
username: string;
role: string;
};
reason?: string;
info?: string;
}
export interface CancellationHistoryItem {
command_id: number;
cancelled_at: string;
reason: string;
penalty_applied: number;
had_livreur: boolean;
livreur_username?: string;
}
export interface CancellationHistoryResponse {
success: boolean;
data?: {
username: string;
history: CancellationHistoryItem[];
total_penalties: number;
warning?: string;
info?: string;
};
message?: string;
}
export interface GetOrderDetailsResponse {
success: boolean;
message?: string;
order?: OrderDetailsData | null;
}
export interface OrderDetailsData extends OrderDetail {
products?: OrderProduct[];
phone?: string;
email?: string;
payment_method?: string;
delivery_time?: string;
delivery_notes?: string;
}
export interface OrderProduct {
id: number;
name_product: string;
category: string;
price: number;
quantity: number;
image?: string;
}
export interface PenaltyInfo {
username: string;
total_penalty: number;
cancellations_count: number;
has_penalties: boolean;
points?: number; // ✅ AJOUTER CETTE LIGNE (points weed/hash)
points_zipette?: number; // ✅ AJOUTER CETTE LIGNE (points zipette)
cancellation_history?: {
current_amende: number;
next_penalty: number;
};
}
export interface PenaltiesResponse {
success: boolean;
data?: PenaltyInfo;
message?: string;
}
export interface CheckoutCartData {
username?: string;
delivery_address: string;
}
export interface ReferralBalanceResponse {
success: boolean;
balance: number;
message?: string;
}
export interface CheckoutCartResponse {
success: boolean;
message: string;
invalid_address?: boolean;
suggested_address?: string;
command_id?: number;
delivery_address?: string;
command?: {
id: number;
status: string;
total: number;
livreur_assign?: string;
created_at: string;
};
assigned_to?: {
username: string;
distance_km: number;
eta_minutes: number;
};
queue_info?: {
position: number;
status: string;
estimated_wait: string;
};
referral_used?: number;
referral_balance?: number;
// Crypto payment fields
payment_method?: string;
payment_status?: string;
pay_address?: string;
pay_amount?: number;
pay_currency?: string;
price_amount?: number;
price_currency?: string;
}
export interface ConfirmReceptionResponse {
success: boolean;
message: string;
points_earned?: number;
category?: string; // 'total', 'zipette&co', 'weed&hash', 'mixed'
data?: {
category?: string;
points_earned?: number;
[key: string]: any;
};
}
+65
View File
@@ -0,0 +1,65 @@
import axios from "axios";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { getToken, getAdminToken } from "../auth/tokenStorage";
const SERVER_URL_KEY = "server_base_url";
export let API_BASE_URL = "https://mln-uber.club";
const apiClient = axios.create({
baseURL: API_BASE_URL,
timeout: 15000,
headers: {
"Content-Type": "application/json",
},
});
// Updates the active backend URL for every subsequent request made
// through apiClient (used by the pre-login server config screen).
export const setApiBaseUrl = (url: string) => {
API_BASE_URL = url;
apiClient.defaults.baseURL = url;
};
export const getStoredServerUrl = () => AsyncStorage.getItem(SERVER_URL_KEY);
export const saveServerUrl = async (url: string) => {
await AsyncStorage.setItem(SERVER_URL_KEY, url);
setApiBaseUrl(url);
};
// Restores the previously saved server URL (if any) into apiClient.
// Must resolve before any screen can issue API calls.
export const initServerBaseUrl = async (): Promise<string | null> => {
const stored = await getStoredServerUrl();
if (stored) {
setApiBaseUrl(stored);
}
return stored;
};
apiClient.interceptors.request.use(async (config) => {
const isAdminRoute =
config.url?.includes("/api/v2/") ||
config.url?.includes("/api/v1/cabine/") ||
config.url?.includes("/api/v1/livreur/");
const token = isAdminRoute ? await getAdminToken() : await getToken();
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
apiClient.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
console.log("Session expirée");
}
return Promise.reject(error);
},
);
export default apiClient;