Merge pull request #471 from R0m1k3/1.1

1.1
This commit is contained in:
LogiFlow authored and GitHub committed 2025-09-28 10:55:14 +02:00
commit b34c5ff288
3 files changed
+293 -266

No files matched your search

+4
View File
@@ -47,6 +47,10 @@ externalPort = 6000
localPort = 44549 localPort = 44549
externalPort = 5173 externalPort = 5173
[[ports]]
localPort = 44965
externalPort = 6800
[workflows] [workflows]
runButton = "Project" runButton = "Project"
+56 -42
View File
@@ -660,39 +660,53 @@ export default function CustomerOrders() {
return matchesSearch && matchesSupplier && matchesStatus; return matchesSearch && matchesSupplier && matchesStatus;
}) : []; }) : [];
// Sort orders // Sort orders - Active orders first, then "Retiré" orders last
const sortedOrders = [...filteredOrders].sort((a, b) => { const sortedOrders = (() => {
let aValue: string | number; // Séparer les commandes en deux groupes
let bValue: string | number; const activeOrders = filteredOrders.filter(order => order.status !== "Retiré");
const retiredOrders = filteredOrders.filter(order => order.status === "Retiré");
switch (sortBy) { // Fonction de tri commune
case "date": const sortFunction = (a: any, b: any) => {
const dateA = safeDate(a.createdAt); let aValue: string | number;
const dateB = safeDate(b.createdAt); let bValue: string | number;
aValue = dateA ? dateA.getTime() : 0;
bValue = dateB ? dateB.getTime() : 0;
break;
case "status":
aValue = a.status;
bValue = b.status;
break;
case "supplier":
aValue = a.supplier?.name || "";
bValue = b.supplier?.name || "";
break;
default:
const defaultDateA = safeDate(a.createdAt);
const defaultDateB = safeDate(b.createdAt);
aValue = defaultDateA ? defaultDateA.getTime() : 0;
bValue = defaultDateB ? defaultDateB.getTime() : 0;
}
if (sortOrder === "desc") { switch (sortBy) {
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0; case "date":
} else { const dateA = safeDate(a.createdAt);
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0; const dateB = safeDate(b.createdAt);
} aValue = dateA ? dateA.getTime() : 0;
}); bValue = dateB ? dateB.getTime() : 0;
break;
case "status":
aValue = a.status;
bValue = b.status;
break;
case "supplier":
aValue = a.supplier?.name || "";
bValue = b.supplier?.name || "";
break;
default:
const defaultDateA = safeDate(a.createdAt);
const defaultDateB = safeDate(b.createdAt);
aValue = defaultDateA ? defaultDateA.getTime() : 0;
bValue = defaultDateB ? defaultDateB.getTime() : 0;
}
if (sortOrder === "desc") {
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
} else {
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
}
};
// Trier chaque groupe séparément
const sortedActiveOrders = [...activeOrders].sort(sortFunction);
const sortedRetiredOrders = [...retiredOrders].sort(sortFunction);
// Concaténer : commandes actives d'abord, puis retiré en dernier
return [...sortedActiveOrders, ...sortedRetiredOrders];
})();
// Pagination // Pagination
const { const {
@@ -819,13 +833,13 @@ export default function CustomerOrders() {
{paginatedOrders.map((order) => ( {paginatedOrders.map((order) => (
<TableRow <TableRow
key={order.id} key={order.id}
className={isGrayedOut(order.status) ? "opacity-50" : ""} className={isGrayedOut(order.status) ? "bg-gray-50 dark:bg-gray-900" : ""}
> >
<TableCell className="font-medium"> <TableCell className={`font-medium ${isGrayedOut(order.status) ? "line-through text-gray-500" : ""}`}>
{order.customerName} {order.customerName}
</TableCell> </TableCell>
<TableCell>{order.customerPhone}</TableCell> <TableCell className={isGrayedOut(order.status) ? "line-through text-gray-500" : ""}>{order.customerPhone}</TableCell>
<TableCell> <TableCell className={isGrayedOut(order.status) ? "line-through text-gray-500" : ""}>
<div> <div>
<div className="font-medium">{order.productDesignation}</div> <div className="font-medium">{order.productDesignation}</div>
{order.productReference && ( {order.productReference && (
@@ -835,30 +849,30 @@ export default function CustomerOrders() {
)} )}
</div> </div>
</TableCell> </TableCell>
<TableCell className="text-center"> <TableCell className={`text-center ${isGrayedOut(order.status) ? "line-through text-gray-500" : ""}`}>
<Badge variant="secondary" className="font-mono"> <Badge variant="secondary" className={`font-mono ${isGrayedOut(order.status) ? "line-through text-gray-500" : ""}`}>
{order.quantity || 1} {order.quantity || 1}
</Badge> </Badge>
</TableCell> </TableCell>
<TableCell> <TableCell className={isGrayedOut(order.status) ? "line-through text-gray-500" : ""}>
<div className="font-medium text-sm"> <div className="font-medium text-sm">
{order.supplier?.name || "N/A"} {order.supplier?.name || "N/A"}
</div> </div>
</TableCell> </TableCell>
<TableCell> <TableCell className={isGrayedOut(order.status) ? "line-through text-gray-500" : ""}>
<code className="bg-gray-100 px-2 py-1 rounded text-sm"> <code className={`bg-gray-100 px-2 py-1 rounded text-sm ${isGrayedOut(order.status) ? "line-through text-gray-500" : ""}`}>
{order.gencode || "-"} {order.gencode || "-"}
</code> </code>
</TableCell> </TableCell>
<TableCell> <TableCell>
<Badge <Badge
className={`${getStatusColor(order.status)} cursor-pointer hover:opacity-80 transition-opacity rounded-none`} className={`${isGrayedOut(order.status) ? "bg-gray-200 text-gray-600 line-through border border-gray-300" : getStatusColor(order.status)} cursor-pointer hover:opacity-80 transition-opacity rounded-none`}
onClick={() => openStatusModal(order)} onClick={() => openStatusModal(order)}
> >
{order.status} {order.status}
</Badge> </Badge>
</TableCell> </TableCell>
<TableCell> <TableCell className={isGrayedOut(order.status) ? "line-through text-gray-500" : ""}>
{safeFormat(order.createdAt, 'dd/MM/yyyy')} {safeFormat(order.createdAt, 'dd/MM/yyyy')}
</TableCell> </TableCell>
<TableCell> <TableCell>