mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-22 06:28:19 +02:00
3 files changed
+293
-266
No files matched your search
@@ -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"
|
||||||
|
|
||||||
|
|||||||
+233
-224
File diff suppressed because it is too large.
Load diff
@@ -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é");
|
||||||
|
|
||||||
|
// Fonction de tri commune
|
||||||
|
const sortFunction = (a: any, b: any) => {
|
||||||
|
let aValue: string | number;
|
||||||
|
let bValue: string | number;
|
||||||
|
|
||||||
switch (sortBy) {
|
switch (sortBy) {
|
||||||
case "date":
|
case "date":
|
||||||
const dateA = safeDate(a.createdAt);
|
const dateA = safeDate(a.createdAt);
|
||||||
const dateB = safeDate(b.createdAt);
|
const dateB = safeDate(b.createdAt);
|
||||||
aValue = dateA ? dateA.getTime() : 0;
|
aValue = dateA ? dateA.getTime() : 0;
|
||||||
bValue = dateB ? dateB.getTime() : 0;
|
bValue = dateB ? dateB.getTime() : 0;
|
||||||
break;
|
break;
|
||||||
case "status":
|
case "status":
|
||||||
aValue = a.status;
|
aValue = a.status;
|
||||||
bValue = b.status;
|
bValue = b.status;
|
||||||
break;
|
break;
|
||||||
case "supplier":
|
case "supplier":
|
||||||
aValue = a.supplier?.name || "";
|
aValue = a.supplier?.name || "";
|
||||||
bValue = b.supplier?.name || "";
|
bValue = b.supplier?.name || "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
const defaultDateA = safeDate(a.createdAt);
|
const defaultDateA = safeDate(a.createdAt);
|
||||||
const defaultDateB = safeDate(b.createdAt);
|
const defaultDateB = safeDate(b.createdAt);
|
||||||
aValue = defaultDateA ? defaultDateA.getTime() : 0;
|
aValue = defaultDateA ? defaultDateA.getTime() : 0;
|
||||||
bValue = defaultDateB ? defaultDateB.getTime() : 0;
|
bValue = defaultDateB ? defaultDateB.getTime() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortOrder === "desc") {
|
if (sortOrder === "desc") {
|
||||||
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
|
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
|
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>
|
||||||
|
|||||||
Reference in new issue
Block a user