mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Adds a refresh button to the Sales Analysis page that allows users to force a full reload of the embedded sales analysis iframe by incrementing a state key which is used as the iframe's `key` prop. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 514e3cfa-4217-4b22-ae44-47651cf2b253 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/7RN8LqE
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import { useState } from "react";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Loader2, TrendingUp, AlertCircle, RefreshCw } from "lucide-react";
|
|
import { Link } from "wouter";
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
interface UtilitiesConfig {
|
|
id?: number;
|
|
salesAnalysisUrl?: string | null;
|
|
createdAt?: Date;
|
|
updatedAt?: Date;
|
|
}
|
|
|
|
export default function SalesAnalysisPage() {
|
|
// State pour forcer le rechargement de l'iframe
|
|
const [iframeKey, setIframeKey] = useState(0);
|
|
|
|
// Récupérer l'URL configurée
|
|
const { data: config, isLoading } = useQuery<UtilitiesConfig>({
|
|
queryKey: ['/api/utilities']
|
|
});
|
|
|
|
// Fonction pour recharger l'iframe
|
|
const handleRefresh = () => {
|
|
setIframeKey(prev => prev + 1);
|
|
};
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="flex-1 flex items-center justify-center">
|
|
<Loader2 className="w-8 h-8 animate-spin text-blue-600" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const salesAnalysisUrl = config?.salesAnalysisUrl;
|
|
|
|
if (!salesAnalysisUrl) {
|
|
return (
|
|
<div className="flex-1 flex items-center justify-center">
|
|
<Card className="w-96">
|
|
<CardHeader className="text-center">
|
|
<AlertCircle className="w-12 h-12 text-orange-500 mx-auto mb-4" />
|
|
<CardTitle>URL non configurée</CardTitle>
|
|
<CardDescription>
|
|
L'URL d'analyse des ventes n'a pas encore été configurée.
|
|
Veuillez la définir dans les utilitaires.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="flex justify-center">
|
|
<Link href="/utilities">
|
|
<Button variant="default" data-testid="button-configure-url">
|
|
Configurer l'URL
|
|
</Button>
|
|
</Link>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="w-full h-screen relative">
|
|
{/* Bouton de rechargement flottant */}
|
|
<div className="absolute top-4 right-4 z-10">
|
|
<Button
|
|
onClick={handleRefresh}
|
|
variant="default"
|
|
size="sm"
|
|
className="shadow-lg"
|
|
data-testid="button-refresh-iframe"
|
|
>
|
|
<RefreshCw className="w-4 h-4 mr-2" />
|
|
Recharger
|
|
</Button>
|
|
</div>
|
|
|
|
{/* iframe avec clé pour forcer le rechargement */}
|
|
<iframe
|
|
key={iframeKey}
|
|
src={salesAnalysisUrl}
|
|
className="w-full h-full border-0"
|
|
title="Analyse des Ventes"
|
|
data-testid="iframe-sales-analysis"
|
|
allow="fullscreen"
|
|
/>
|
|
</div>
|
|
);
|
|
}
|