dhi-copilot-ai 3.1.3 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21238,7 +21238,8 @@ const ConfigProvider = ({ children, value }) => {
21238
21238
  ].join("\n");
21239
21239
  const defaultConfig = {
21240
21240
  apiUrl: void 0,
21241
- // Explicitement absent par défaut (pas de chaîne vide)
21241
+ companyId: void 0,
21242
+ // ← Ajouté ici
21242
21243
  userToken: void 0,
21243
21244
  userId: void 0,
21244
21245
  userName: "Utilisateur",
@@ -24273,8 +24274,8 @@ const apiService = {
24273
24274
  * headers minimaux évite ce preflight et contourne les erreurs CORS
24274
24275
  * rencontrées avec la route /chat.
24275
24276
  */
24276
- sendMessage: async (apiUrl, token, payload) => {
24277
- const url = `${cleanUrl(apiUrl)}/chat`;
24277
+ sendMessage: async (apiUrl, companyId, token, payload) => {
24278
+ const url = `${cleanUrl(apiUrl)}/chat/fluxxon/${companyId}`;
24278
24279
  const headers = {
24279
24280
  "Content-Type": "application/json"
24280
24281
  };
@@ -37265,6 +37266,7 @@ const ChatView = () => {
37265
37266
  const { initialMessage, botName, userName } = configContext;
37266
37267
  const apiUrl = (configContext == null ? void 0 : configContext.apiUrl) || (storeConfig == null ? void 0 : storeConfig.apiUrl);
37267
37268
  const userToken = (configContext == null ? void 0 : configContext.userToken) || (storeConfig == null ? void 0 : storeConfig.userToken);
37269
+ const companyId = (configContext == null ? void 0 : configContext.companyId) || (storeConfig == null ? void 0 : storeConfig.companyId);
37268
37270
  const scrollRef = reactExports.useRef(null);
37269
37271
  reactExports.useEffect(() => {
37270
37272
  if (scrollRef.current) {
@@ -37276,6 +37278,25 @@ const ChatView = () => {
37276
37278
  }, [messages, isLoading]);
37277
37279
  const handleSendMessage = async (text2, files = []) => {
37278
37280
  if (!text2.trim() && files.length === 0 || isLoading) return;
37281
+ if (!companyId) {
37282
+ addMessage({
37283
+ id: Date.now().toString(),
37284
+ role: "user",
37285
+ content: text2.trim(),
37286
+ timestamp: /* @__PURE__ */ new Date()
37287
+ });
37288
+ setLoading(true);
37289
+ setTimeout(() => {
37290
+ addMessage({
37291
+ id: "err-company-" + Date.now(),
37292
+ role: "assistant",
37293
+ content: "⚠️ **Identifiant d'entreprise manquant.**\n\nVeuillez configurer l'identifiant de l'entreprise`. Cette information est indispensable pour acheminer vos messages vers le bon assistant.",
37294
+ timestamp: /* @__PURE__ */ new Date()
37295
+ });
37296
+ setLoading(false);
37297
+ }, 600);
37298
+ return;
37299
+ }
37279
37300
  if (!apiUrl) {
37280
37301
  console.error(
37281
37302
  "[DHI Copilot] apiUrl manquant. Vérifiez la prop `config` sur <dhi-copilot-ai>."
@@ -37315,7 +37336,7 @@ ${fileList}`;
37315
37336
 
37316
37337
  (Contexte : L'utilisateur a joint les fichiers suivants pour analyse : ${fileNames})` : `Analyse les documents suivants que je viens de t'envoyer : ${fileNames}.`;
37317
37338
  }
37318
- const data = await apiService.sendMessage(apiUrl, userToken, {
37339
+ const data = await apiService.sendMessage(apiUrl, companyId, userToken, {
37319
37340
  message: finalPrompt,
37320
37341
  thread_id: currentThreadId
37321
37342
  });