diff --git a/src/config/moduleConfig.js b/src/config/moduleConfig.js index dc80dad..2009ab4 100644 --- a/src/config/moduleConfig.js +++ b/src/config/moduleConfig.js @@ -27,7 +27,8 @@ import { Calculator, ListTodo, ShieldCheck, - PanelLeft + PanelLeft, + MessageSquare, } from 'lucide-react'; export const MODULE_GESTION = 'gestion'; @@ -113,6 +114,12 @@ export const getMenuForModule = (currentModule) => { { to: "/home/sage-builder", icon: PanelLeft, label: "Tableau des ventes" }, ] }, + { + title: "Modules", + items: [ + { to: "/home/ask-ia", icon: MessageSquare, label: "Sage Ask.AI" }, + ] + }, // { // title: "Signature", // items: [ diff --git a/src/pages/AskIaPage.tsx b/src/pages/AskIaPage.tsx new file mode 100644 index 0000000..ecaf5b2 --- /dev/null +++ b/src/pages/AskIaPage.tsx @@ -0,0 +1,395 @@ +import { ModalLoading } from '@/components/modal/ModalLoading'; +import { askIaStatus, getAskIaHtmlContent } from '@/store/features/ask-ia/selectors'; +import { getAskIa } from '@/store/features/ask-ia/thunk'; +import { sageBuilderError } from '@/store/features/sage-builder/selectors'; +import { useAppDispatch, useAppSelector } from '@/store/hooks'; +import React, { useEffect, useRef } from 'react'; + +const AskIaPage = () => { + const dispatch = useAppDispatch(); + const iframeRef = useRef(null); + + const htmlContent = useAppSelector(getAskIaHtmlContent); + const status = useAppSelector(askIaStatus); + const error = useAppSelector(sageBuilderError); + + useEffect(() => { + // Charger le dashboard au montage du composant + if (status === 'idle') { + dispatch(getAskIa()); + } + }, [dispatch, status]); + + useEffect(() => { + // Injecter le HTML dans l'iframe quand il est disponible + if (htmlContent && iframeRef.current && status === 'succeeded') { + const iframeDoc = iframeRef.current.contentDocument || iframeRef.current.contentWindow?.document; + if (iframeDoc) { + iframeDoc.open(); + iframeDoc.write(htmlContent); + iframeDoc.close(); + } + } + }, [htmlContent, status]); + + const handleRetry = () => { + dispatch(getAskIa()); + }; + + return ( +
+ {/* Loading Overlay */} + {status === 'loading' && } + + {/* Error State */} + {status === 'failed' && error && ( +
+
+
+ + + +
+

+ Erreur de chargement +

+

+ {error} +

+ +
+
+ )} + + {/* Iframe */} +