Add a refresh button to reload the sales analysis iframe

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
This commit is contained in:
michaelschal committed 2025-11-03 11:12:04 +00:00
1 parent 9750bb1139
commit ae80aa3f0f
1 file changed
+27 -2
+27 -2
View File
@@ -1,6 +1,7 @@
import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Loader2, TrendingUp, AlertCircle } from "lucide-react";
import { Loader2, TrendingUp, AlertCircle, RefreshCw } from "lucide-react";
import { Link } from "wouter";
import { Button } from "@/components/ui/button";
@@ -12,10 +13,18 @@ interface UtilitiesConfig {
}
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 (
@@ -52,8 +61,24 @@ export default function SalesAnalysisPage() {
}
return (
<div className="w-full h-screen">
<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"