mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Update product sorting to show active items first
Modify the database query in `server/storage.ts` to prioritize active products (status not 'valides' and not processed/stock épuisé) to appear before processed, stock épuisé, or valides products in the results. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 427b5397-73ab-43e6-8938-8421d3c5aef4 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/LXHtbOp
This commit is contained in:
1 parent
a7f2d3448e
commit
c55ee2aabe
1 file changed
+9
-6
+9
-6
@@ -1948,14 +1948,17 @@ export class DatabaseStorage implements IStorage {
|
||||
query = query.where(and(...conditions));
|
||||
}
|
||||
|
||||
// Tri intelligent : produits traités/validés en premier (grisés), puis produits actifs
|
||||
// Tri intelligent : produits actifs (non grisés) EN PREMIER, puis lignes grisées en dernier
|
||||
const results = await query.orderBy(
|
||||
// Priorité 1 : Produits traités/validés d'abord (affichés en grisé)
|
||||
// Priorité : Actifs → Traités → Stock épuisé → Validés
|
||||
sql`CASE
|
||||
WHEN ${dlcProducts.processedUntilExpiry} = true THEN 1
|
||||
WHEN ${dlcProducts.status} = 'valides' THEN 1
|
||||
WHEN ${dlcProducts.stockEpuise} = true THEN 1
|
||||
ELSE 2
|
||||
WHEN ${dlcProducts.status} != 'valides'
|
||||
AND (${dlcProducts.processedUntilExpiry} IS NULL OR ${dlcProducts.processedUntilExpiry} = false)
|
||||
AND (${dlcProducts.stockEpuise} IS NULL OR ${dlcProducts.stockEpuise} = false) THEN 1
|
||||
WHEN ${dlcProducts.processedUntilExpiry} = true THEN 2
|
||||
WHEN ${dlcProducts.stockEpuise} = true THEN 3
|
||||
WHEN ${dlcProducts.status} = 'valides' THEN 4
|
||||
ELSE 1
|
||||
END`,
|
||||
// Priorité 2 : Date d'expiration (croissante)
|
||||
asc(dlcProducts.expiryDate)
|
||||
|
||||
Reference in new issue
Block a user