mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-20 05:28:22 +02:00
Remove manual sync button from the calendar
Remove the manual "Sync Status" button and its related functionality from the Calendar page. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/KuIk8gU
This commit is contained in:
1 parent
687a1b41d4
commit
041891baf0
2 files changed
+92
-126
No files matched your search
@@ -0,0 +1,90 @@
|
|||||||
|
# Suppression du Bouton "Sync Status" - Production
|
||||||
|
|
||||||
|
## Modifications à Appliquer sur Votre Serveur de Production
|
||||||
|
|
||||||
|
Pour supprimer le bouton "Sync Status" qui n'est plus nécessaire avec la synchronisation automatique :
|
||||||
|
|
||||||
|
### Fichier : `client/src/pages/Calendar.tsx`
|
||||||
|
|
||||||
|
#### 1. Supprimer le bouton "Sync Status"
|
||||||
|
**Localisez et supprimez (lignes ~319-329) :**
|
||||||
|
```typescript
|
||||||
|
{user?.role === 'admin' && (
|
||||||
|
<Button
|
||||||
|
onClick={handleSyncOrderDeliveryStatus}
|
||||||
|
disabled={isSyncing}
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="text-blue-600 border-blue-600 hover:bg-blue-50"
|
||||||
|
>
|
||||||
|
<RefreshCw className={`w-4 h-4 mr-2 ${isSyncing ? 'animate-spin' : ''}`} />
|
||||||
|
{isSyncing ? 'Sync...' : 'Sync Status'}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Supprimer la variable d'état isSyncing
|
||||||
|
**Localisez et supprimez :**
|
||||||
|
```typescript
|
||||||
|
const [isSyncing, setIsSyncing] = useState(false);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Supprimer la fonction handleSyncOrderDeliveryStatus
|
||||||
|
**Localisez et supprimez toute la fonction (environ 100 lignes) :**
|
||||||
|
```typescript
|
||||||
|
// Fonction pour synchroniser les statuts commandes/livraisons
|
||||||
|
const handleSyncOrderDeliveryStatus = async () => {
|
||||||
|
// ... toute la fonction complète
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## Étapes de Déploiement
|
||||||
|
|
||||||
|
### 1. Sauvegarde
|
||||||
|
```bash
|
||||||
|
cp client/src/pages/Calendar.tsx client/src/pages/Calendar.tsx.backup
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Application des Modifications
|
||||||
|
Éditez le fichier `client/src/pages/Calendar.tsx` et appliquez les trois suppressions ci-dessus.
|
||||||
|
|
||||||
|
### 3. Reconstruction du Frontend
|
||||||
|
```bash
|
||||||
|
# Si vous utilisez un build process
|
||||||
|
npm run build
|
||||||
|
# ou
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
# Si vous utilisez Vite en production
|
||||||
|
npm run build && npm run preview
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Redémarrage de l'Application
|
||||||
|
```bash
|
||||||
|
# Via PM2
|
||||||
|
pm2 restart your-app-name
|
||||||
|
|
||||||
|
# Via systemctl
|
||||||
|
sudo systemctl restart your-service
|
||||||
|
|
||||||
|
# Via Docker
|
||||||
|
docker-compose restart
|
||||||
|
```
|
||||||
|
|
||||||
|
## Vérification
|
||||||
|
|
||||||
|
Après déploiement :
|
||||||
|
- Le bouton "Sync Status" ne devrait plus apparaître dans l'interface
|
||||||
|
- La synchronisation automatique fonctionnera toujours (lors des validations de livraisons)
|
||||||
|
- L'interface sera plus propre et simplifiée
|
||||||
|
|
||||||
|
## Rollback si Nécessaire
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp client/src/pages/Calendar.tsx.backup client/src/pages/Calendar.tsx
|
||||||
|
# Puis reconstruire et redémarrer
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Résultat** : Interface calendrier simplifiée sans le bouton de synchronisation manuelle, la synchronisation se fait maintenant automatiquement lors des validations de livraisons.
|
||||||
@@ -27,7 +27,7 @@ export default function Calendar() {
|
|||||||
const [showCreateOrder, setShowCreateOrder] = useState(false);
|
const [showCreateOrder, setShowCreateOrder] = useState(false);
|
||||||
const [showCreateDelivery, setShowCreateDelivery] = useState(false);
|
const [showCreateDelivery, setShowCreateDelivery] = useState(false);
|
||||||
const [selectedItem, setSelectedItem] = useState<any>(null);
|
const [selectedItem, setSelectedItem] = useState<any>(null);
|
||||||
const [isSyncing, setIsSyncing] = useState(false);
|
|
||||||
|
|
||||||
const monthStart = startOfMonth(currentDate);
|
const monthStart = startOfMonth(currentDate);
|
||||||
const monthEnd = endOfMonth(currentDate);
|
const monthEnd = endOfMonth(currentDate);
|
||||||
@@ -141,120 +141,7 @@ export default function Calendar() {
|
|||||||
setShowCreateDelivery(true);
|
setShowCreateDelivery(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fonction pour synchroniser les statuts commandes/livraisons
|
|
||||||
const handleSyncOrderDeliveryStatus = async () => {
|
|
||||||
if (user?.role !== 'admin') return;
|
|
||||||
|
|
||||||
setIsSyncing(true);
|
|
||||||
try {
|
|
||||||
console.log('🔄 Starting manual sync of order-delivery status...');
|
|
||||||
|
|
||||||
// Solution temporaire : récupérer TOUTES les données sans filtres de dates
|
|
||||||
console.log('📡 Fetching ALL orders (no date filter)...');
|
|
||||||
const ordersResponse = await fetch('/api/orders', { credentials: 'include' });
|
|
||||||
const filteredOrders = await ordersResponse.json();
|
|
||||||
|
|
||||||
// Récupérer aussi toutes les livraisons pour avoir une vue complète
|
|
||||||
console.log('📡 Fetching ALL deliveries (no date filter)...');
|
|
||||||
const deliveriesResponse = await fetch('/api/deliveries', { credentials: 'include' });
|
|
||||||
const allDeliveries = await deliveriesResponse.json();
|
|
||||||
|
|
||||||
// Enrichir les commandes avec leurs livraisons pour avoir les bonnes relations
|
|
||||||
const enrichedOrders = filteredOrders.map((order: any) => {
|
|
||||||
const orderDeliveries = allDeliveries.filter((delivery: any) => delivery.orderId === order.id);
|
|
||||||
return {
|
|
||||||
...order,
|
|
||||||
deliveries: orderDeliveries
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('📊 Data loaded for sync:', {
|
|
||||||
filteredOrders: filteredOrders.length,
|
|
||||||
enrichedOrders: enrichedOrders.length,
|
|
||||||
allDeliveries: allDeliveries.length,
|
|
||||||
deliveredDeliveries: allDeliveries.filter((d: any) => d.status === 'delivered').length
|
|
||||||
});
|
|
||||||
|
|
||||||
// Chercher spécifiquement CMD-55
|
|
||||||
const cmd55 = enrichedOrders.find((o: any) => o.id === 55);
|
|
||||||
const cmd55Deliveries = allDeliveries.filter((d: any) => d.orderId === 55);
|
|
||||||
|
|
||||||
console.log('🎯 CMD-55 Analysis:', {
|
|
||||||
foundInOrders: !!cmd55,
|
|
||||||
cmd55Status: cmd55?.status || 'NOT_FOUND',
|
|
||||||
cmd55Deliveries: cmd55Deliveries.length,
|
|
||||||
deliveryStatuses: cmd55Deliveries.map((d: any) => ({
|
|
||||||
id: d.id,
|
|
||||||
status: d.status,
|
|
||||||
deliveredDate: d.deliveredDate,
|
|
||||||
scheduledDate: d.scheduledDate
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
let problematicOrders = 0;
|
|
||||||
let fixedOrders = 0;
|
|
||||||
|
|
||||||
// Parcourir les commandes enrichies et identifier celles à corriger
|
|
||||||
for (const order of enrichedOrders) {
|
|
||||||
console.log(`🔍 Analyzing order #CMD-${order.id}:`, {
|
|
||||||
status: order.status,
|
|
||||||
deliveries: order.deliveries?.length || 0,
|
|
||||||
deliveryStatuses: order.deliveries?.map((d: any) => ({ id: d.id, status: d.status, deliveredDate: d.deliveredDate })) || []
|
|
||||||
});
|
|
||||||
|
|
||||||
if (order.deliveries && order.deliveries.length > 0) {
|
|
||||||
const hasDeliveredDeliveries = order.deliveries.some((d: any) => d.status === 'delivered');
|
|
||||||
|
|
||||||
if (hasDeliveredDeliveries && order.status !== 'delivered') {
|
|
||||||
problematicOrders++;
|
|
||||||
console.log(`🔍 Found problematic order: #CMD-${order.id} (status: ${order.status}) with delivered deliveries:`,
|
|
||||||
order.deliveries.filter((d: any) => d.status === 'delivered').map((d: any) => `#LIV-${d.id}`)
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Corriger la commande via fetch direct
|
|
||||||
const response = await fetch(`/api/orders/${order.id}`, {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
credentials: 'include',
|
|
||||||
body: JSON.stringify({ status: 'delivered' })
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
fixedOrders++;
|
|
||||||
console.log(`✅ Fixed order #CMD-${order.id} status to 'delivered'`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`❌ Failed to fix order #CMD-${order.id}:`, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('🔄 Sync completed:', { problematicOrders, fixedOrders });
|
|
||||||
|
|
||||||
toast({
|
|
||||||
title: "Synchronisation terminée",
|
|
||||||
description: `${fixedOrders} commande(s) corrigée(s) sur ${problematicOrders} problématique(s)`,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Rafraîchir les données du calendrier
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['/api/orders'] });
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('❌ Sync failed:', error);
|
|
||||||
toast({
|
|
||||||
title: "Erreur de synchronisation",
|
|
||||||
description: "Impossible de synchroniser les statuts. Vérifiez la console.",
|
|
||||||
variant: "destructive"
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setIsSyncing(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const isLoading = loadingOrders || loadingDeliveries;
|
const isLoading = loadingOrders || loadingDeliveries;
|
||||||
|
|
||||||
@@ -316,18 +203,7 @@ export default function Calendar() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
{user?.role === 'admin' && (
|
|
||||||
<Button
|
|
||||||
onClick={handleSyncOrderDeliveryStatus}
|
|
||||||
disabled={isSyncing}
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
className="text-blue-600 border-blue-600 hover:bg-blue-50"
|
|
||||||
>
|
|
||||||
<RefreshCw className={`w-4 h-4 mr-2 ${isSyncing ? 'animate-spin' : ''}`} />
|
|
||||||
{isSyncing ? 'Sync...' : 'Sync Status'}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setShowQuickCreate(true)}
|
onClick={() => setShowQuickCreate(true)}
|
||||||
className="bg-accent hover:bg-orange-600 text-white"
|
className="bg-accent hover:bg-orange-600 text-white"
|
||||||
|
|||||||
Reference in new issue
Block a user