diff --git a/extension/sidepanels/sidepanel.js b/extension/sidepanels/sidepanel.js index b4c34a4..98a4d02 100644 --- a/extension/sidepanels/sidepanel.js +++ b/extension/sidepanels/sidepanel.js @@ -84,60 +84,58 @@ async function fetchAINotes() { }; // Make API request - const response = await fetch( - `${AMUREX_CONFIG.BASE_URL_BACKEND}/end_meeting`, - { - method: "POST", - headers: { - "Content-Type": "application/json", - Accept: "application/json", - }, - body: JSON.stringify(body), - } - ); - - if (!response.ok) { - throw new Error(`Server responded with ${response.status}`); - } - - const data = await response.json(); - - // Display the Notion link and meeting notes - summaryDiv.innerHTML = ` -
${ - data.notes_content - ? data.notes_content - .trim() - .split("\n") - .filter((line) => line.trim() !== "") - .map((line) => - line.startsWith("- ") - ? `
  • ${line.substring(2)}
  • ` // Handle list items - : line // Keep other lines as is - .replace(/\*\*(.*?)\*\*/g, "$1") - .replace(/\*(.*?)\*/g, "$1") - .replace(/\[(.*?)\]\((.*?)\)/g, '$1') - ) - .join("\n") // Restore newlines - .replace( - /(
  • .*?<\/li>)\n?(
  • .*?<\/li>)+/g, - (list) => `` - ) // Wrap consecutive list items - .replace(/\n/g, "
    ") // Convert remaining newlines to
    - : "No meeting notes available." - }
  • - `; - - // Display the action items with markdown formatting - actionItemsDiv.innerHTML = ` -
    ${ - data.action_items || "No action items available." - }
    - `; - - // Add this after the actionItemsDiv.innerHTML line: - generateEmailOptions(data); - deleteKeysFromStorage(); + fetch(`${AMUREX_CONFIG.BASE_URL_BACKEND}/end_meeting`, { + method: "POST", + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify(body), + }) + .then(response => response.json()) + .then(data => { + // Display the Notion link and meeting notes + summaryDiv.innerHTML = ` +
    ${ + data.notes_content + ? data.notes_content + .trim() + .split("\n") + .filter((line) => line.trim() !== "") + .map((line) => + line.startsWith("- ") + ? `
  • ${line.substring(2)}
  • ` // Handle list items + : line // Keep other lines as is + .replace(/\*\*(.*?)\*\*/g, "$1") + .replace(/\*(.*?)\*/g, "$1") + .replace(/\[(.*?)\]\((.*?)\)/g, '$1') + ) + .join("\n") // Restore newlines + .replace( + /(
  • .*?<\/li>)\n?(
  • .*?<\/li>)+/g, + (list) => `` + ) // Wrap consecutive list items + .replace(/\n/g, "
    ") // Convert remaining newlines to
    + : "No meeting notes available." + }
  • + `; + + // Display the action items with markdown formatting + actionItemsDiv.innerHTML = ` +
    ${ + data.action_items || "No action items available." + }
    + `; + + // Add this after the actionItemsDiv.innerHTML line: + generateEmailOptions(data); + deleteKeysFromStorage(); + }) + .catch(error => { + console.error("Error fetching or parsing meeting notes:", error); + summaryDiv.innerHTML = "

    Failed to generate meeting notes. Please try again later.

    "; + actionItemsDiv.innerHTML = "

    Error: Failed to process server response

    "; + }); } catch (error) { console.error("Error generating notes:", error); summaryDiv.innerHTML =