chore: update custom-rules & update style & script data
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
// ✅ loginUser et registerUser retournent AuthResponse
|
||||
// ✅ sessionStorage (pas localStorage)
|
||||
|
||||
const API_URL = "http://localhost:8080/api/v1";
|
||||
const API_URL = "/api/v1";
|
||||
import type {
|
||||
ConfirmReceptionResponse,
|
||||
CheckoutCartResponse,
|
||||
|
||||
@@ -15,7 +15,7 @@ import type {
|
||||
DeliveryPersonDetails,
|
||||
DeliveryPersonStats,
|
||||
} from "./api_admin_types";
|
||||
const API_URL = "http://localhost:8080/api/v2";
|
||||
const API_URL = "/api/v2";
|
||||
|
||||
// ============================================
|
||||
// 🔐 TYPES - ADMIN
|
||||
@@ -825,59 +825,6 @@ export const getCommandByID = async (commandId: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ✅ Récupérer les items d'une commande
|
||||
*/
|
||||
export const getCommandItems = async (commandId: number) => {
|
||||
const token = sessionStorage.getItem("admin_token");
|
||||
|
||||
if (!token) {
|
||||
throw new Error("Token admin non trouvé");
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("🔍 [GET_COMMAND_ITEMS] Appel:", commandId);
|
||||
|
||||
// Utiliser l'endpoint cabine qui est accessible avec le token admin
|
||||
const response = await fetch(
|
||||
`http://localhost:8080/api/v1/cabine/commands/${commandId}/items`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
console.error("❌ [GET_COMMAND_ITEMS] Erreur API:", data);
|
||||
return {
|
||||
success: false,
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
|
||||
console.log("✅ [GET_COMMAND_ITEMS] Réponse:", data);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
items: data.items || [],
|
||||
count: data.count || 0,
|
||||
command_info: data.command_info,
|
||||
client_info: data.client_info,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("❌ [GET_COMMAND_ITEMS] Erreur fetch:", error);
|
||||
return {
|
||||
success: false,
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ✅ Mettre à jour le statut d'une commande
|
||||
*/
|
||||
@@ -2653,7 +2600,6 @@ export default {
|
||||
// Commands
|
||||
getAllCommands,
|
||||
getCommandByID,
|
||||
getCommandItems,
|
||||
getCommandCount,
|
||||
getCommandCountCompleted,
|
||||
getCommandCountInRoute,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// ✅ Utilise /api/v1/cabine/* endpoints uniquement
|
||||
// ✅ sessionStorage pour la persistance
|
||||
|
||||
const API_URL = "http://localhost:8080/api/v1/cabine";
|
||||
const API_URL = "/api/v1/cabine";
|
||||
import type {
|
||||
DeliveryPerson,
|
||||
DeliveryPersonsStats,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// ✅ Fonctions helper pour le dashboard livreur
|
||||
// ✅ Utilise /api/v1/livreur/* endpoints
|
||||
|
||||
const API_URL = "http://localhost:8080/api/v1/livreur";
|
||||
const API_URL = "/api/v1/livreur";
|
||||
|
||||
// ============================================
|
||||
// 🔐 TYPES - LIVREUR
|
||||
|
||||
@@ -17,6 +17,7 @@ import "./AdminAlerts.css";
|
||||
import Sidebar from "../../components/Sidebar";
|
||||
import { isAdminAuthenticated, deleteAlertAdmin } from "../../api/api_admin";
|
||||
import { getAllAlerts, getAlertDetails } from "../../api/api_cabine";
|
||||
import Toast from "../../components/Toast";
|
||||
|
||||
interface Alert {
|
||||
id: number;
|
||||
@@ -32,6 +33,12 @@ interface AlertStats {
|
||||
resolved: number;
|
||||
}
|
||||
|
||||
interface ToastState {
|
||||
show: boolean;
|
||||
message: string;
|
||||
type: "success" | "error" | "warning" | "info";
|
||||
}
|
||||
|
||||
function AdminAlerts() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -54,6 +61,26 @@ function AdminAlerts() {
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
const [alertToDelete, setAlertToDelete] = useState<number | null>(null);
|
||||
|
||||
// État pour le Toast
|
||||
const [toast, setToast] = useState<ToastState>({
|
||||
show: false,
|
||||
message: "",
|
||||
type: "success",
|
||||
});
|
||||
|
||||
// Fonction pour afficher un toast
|
||||
const showToast = (
|
||||
message: string,
|
||||
type: "success" | "error" | "warning" | "info" = "success",
|
||||
) => {
|
||||
setToast({ show: true, message, type });
|
||||
};
|
||||
|
||||
// Fonction pour fermer le toast
|
||||
const handleCloseToast = () => {
|
||||
setToast({ ...toast, show: false });
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// 🔐 VÉRIFICATION AUTHENTIFICATION
|
||||
// ============================================
|
||||
@@ -249,11 +276,14 @@ function AdminAlerts() {
|
||||
setSelectedAlert(result.alert as Alert);
|
||||
setShowDetailsModal(true);
|
||||
} else {
|
||||
alert("Impossible de récupérer les détails");
|
||||
showToast(
|
||||
"Impossible de récupérer les détails de l'alerte",
|
||||
"error",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Erreur récupération détails:", error);
|
||||
alert("Erreur lors de la récupération des détails");
|
||||
showToast("Erreur lors de la récupération des détails", "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -281,15 +311,21 @@ function AdminAlerts() {
|
||||
setShowDeleteConfirm(false);
|
||||
setAlertToDelete(null);
|
||||
|
||||
// Message de succès
|
||||
alert("Alerte supprimée avec succès");
|
||||
// Afficher le toast de succès
|
||||
showToast(
|
||||
`Alerte #${alertToDelete} supprimée avec succès`,
|
||||
"success",
|
||||
);
|
||||
} else {
|
||||
console.error("❌ [DELETE_ALERT] Erreur:", result.error);
|
||||
alert(result.error || "Erreur lors de la suppression");
|
||||
showToast(
|
||||
result.error || "Erreur lors de la suppression",
|
||||
"error",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ [DELETE_ALERT] Erreur:", error);
|
||||
alert("Erreur lors de la suppression de l'alerte");
|
||||
showToast("Erreur lors de la suppression de l'alerte", "error");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -673,6 +709,16 @@ function AdminAlerts() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Toast Notifications */}
|
||||
{toast.show && (
|
||||
<Toast
|
||||
message={toast.message}
|
||||
type={toast.type}
|
||||
duration={3000}
|
||||
onClose={handleCloseToast}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -20,11 +20,10 @@ import AdminLayout from "../../components/AdminLayout";
|
||||
import "./AdminOrders.css";
|
||||
import {
|
||||
getAllCommands,
|
||||
getCommandItems,
|
||||
getDeliverymanLocationForCommand,
|
||||
isAdminAuthenticated,
|
||||
} from "../../api/api_admin";
|
||||
|
||||
import { getCommandItems } from "../../api/api_cabine";
|
||||
import type { DeliverymanLocationResponse } from "../../api/api_admin_types";
|
||||
|
||||
// Interface correspondant au backend
|
||||
|
||||
@@ -24,13 +24,13 @@ import SidebarCabine from "../../components/SidebarCabine";
|
||||
import "./CabineOrders.css";
|
||||
import {
|
||||
getAllCommands,
|
||||
getCommandItems,
|
||||
getDeliverymanLocationForCommand,
|
||||
} from "../../api/api_admin";
|
||||
|
||||
import {
|
||||
deleteCommand,
|
||||
isCabineAuthenticated, // ⭐ AJOUT
|
||||
isCabineAuthenticated,
|
||||
getCommandItems,
|
||||
} from "../../api/api_cabine";
|
||||
|
||||
import type { DeliverymanLocationResponse } from "../../api/api_admin_types";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user