diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index 4ed3093..4f792b7 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -4,6 +4,10 @@ export default { chat_initial_message: "Welcome to your technical assistant.\nPlease provide the Customer ID to get a diagnostic report", chat_placeholder: "Enter a Message", chat_thinking: "Thinking...", + error: { + NO_REPLY_RECEIVED: "encountered an error while waiting for chatbot to reply", + SEND_MESSAGE_FAILED: "unable to send message to chatbot", + }, }, dashboard: { @@ -67,7 +71,7 @@ export default { }, }, }, - + employee_list: { page_header: "Employee Directory", table: { diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index faad207..e31d03a 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -4,6 +4,10 @@ export default { chat_initial_message: "Bienvenue à votre assistant technique.\nVeuillez fournir le ID du Client pour avoir un diagnostique", chat_placeholder: "Entré un Message", chat_thinking: "Réflexion en cours...", + error: { + NO_REPLY_RECEIVED: "Une erreur est survenu lors de la réception de la réponse du chatbot", + SEND_MESSAGE_FAILED: "Une erreur est survenu lors de l'envoi de votre message", + }, }, dashboard: { diff --git a/src/modules/chatbot/components/conversation-box.vue b/src/modules/chatbot/components/conversation-box.vue index 930311c..b0608da 100644 --- a/src/modules/chatbot/components/conversation-box.vue +++ b/src/modules/chatbot/components/conversation-box.vue @@ -4,131 +4,71 @@ > import DialogueContent from "./dialogue-content.vue"; - import { computed, onMounted, ref, watch } from "vue"; + import { onMounted, ref } from "vue"; + import { useChatbotStore } from "src/stores/chatbot-store"; import { useChatbotApi } from "src/modules/chatbot/composables/chatbot-api"; - import { chatbotService } from "src/modules/chatbot/services/messages.service"; - import { pageContexts } from "src/page-contexts"; - import type { contextObject } from "src/page-contexts/pages/types/context-object"; -import { useChatbotStore } from "src/stores/chatbot-store"; // Block to enable editing the width of the drawer - const drawerWidth = ref(370); - let dragging = false - const startDrag = (e: MouseEvent) => { - dragging = true - e.preventDefault() - } - const onDrag = (e: MouseEvent) => { - if (!dragging) return - // calculate new width - const newWidth = window.innerWidth - e.clientX - drawerWidth.value = Math.max(350, Math.min(1000, newWidth)) // min/max width - } - const stopDrag = () => { - dragging = false - } - window.addEventListener('mousemove', onDrag) - window.addEventListener('mouseup', stopDrag) + // const drawerWidth = ref(370); + // let dragging = false; + // const startDrag = (e: MouseEvent) => { + // dragging = true + // e.preventDefault() + // } + // const onDrag = (e: MouseEvent) => { + // if (!dragging) return + // // calculate new width + // const newWidth = window.innerWidth - e.clientX + // drawerWidth.value = Math.max(350, Math.min(1000, newWidth)) // min/max width + // } + // const stopDrag = () => { + // dragging = false + // } + // window.addEventListener('mousemove', onDrag) + // window.addEventListener('mouseup', stopDrag) - // Block to handle the incomming and sending of the messages from the user and the ai - const text = ref(''); + const chatbot_api = useChatbotApi(); const chatbot_store = useChatbotStore(); - const chatbot_api = useChatApi(); - const chatStore = useChatStore(); - onMounted(() => { - chatStore.showInstructionsOnce(); - }) - const isSessionReady = ref(false); + const text = ref(''); + const handleSend = async () => { - const userMessage = text.value.trim(); - - + await chatbot_api.sendMessage(text.value.trim()); text.value = ''; - messages.push({ - text: userMessage, - sent: true, - isThinking: false, - }) - - const thinkingMessage = { - text: "Thinking...", - sent: false, - isThinking: true - } - messages.push(thinkingMessage) - - try { - const aiResponse = await sendMessage(userMessage); - - const index = messages.indexOf(thinkingMessage); - if (index !== -1) { - messages.splice(index, 1, { - text: aiResponse.text, - sent: false, - isThinking: false, - }) - } - } - catch (error) { - const index = messages.indexOf(thinkingMessage); - if (index !== -1) { - messages.splice(index, 1, { - text: "Sorry, Message wasn't able to sent.", - sent: false, - isThinking: false, - }); - } - throw error; - } }; - - - // Block to receive user from child - const userEmail = ref('') - const userRole = ref('') - - const HandleEmail = (email: string) => { - userEmail.value = email; - } - - const HandleRole = (role: string) => { - userRole.value = role; - } - - // Block to handle sending the url to n8n - const route = useRoute() - const sendPageContext = chatbotService.sendPageContext; // Capture and send page context to n8n - const currentContext = computed(() => - pageContexts.find(ctx => ctx.path === route.fullPath.replace('/', '')) - ) + // const currentContext = computed(() => + // pageContexts.find(ctx => ctx.path === route.fullPath.replace('/', '')) + // ) - // Function that sends the page context to n8n - watch([currentContext, userEmail, userRole], async ([ctx, email, role]) => { - if (!ctx || !email || !role) return; + // // Function that sends the page context to n8n + // watch([currentContext, userEmail, userRole], async ([ctx, email, role]) => { + // if (!ctx || !email || !role) return; - const contextPayload: contextObject = { - name: ctx.name, - description: ctx.description, - features: ctx.features, - path: ctx.path - } + // const contextPayload: contextObject = { + // name: ctx.name, + // description: ctx.description, + // features: ctx.features, + // path: ctx.path + // } - try { - await Promise.all([chatbotService.sendUserCredentials(email, role), - sendPageContext(contextPayload), - ]); - isSessionReady.value = true; - } catch (err) { - console.error("Error", err) - } - }, - { immediate: true } - ); + // try { + // await Promise.all([chatbotService.sendUserCredentials(email, role), + // sendPageContext(contextPayload), + // ]); + // is_session_ready.value = true; + // } catch (err) { + // console.error("Error", err) + // } + // }, + // { immediate: true } + // ); + onMounted(() => { + chatbot_store.showInstructionsOnce(); + }) // const custId = ref('') // const handleCustomerId = async () => { @@ -136,31 +76,19 @@ import { useChatbotStore } from "src/stores/chatbot-store"; // custId.value = ''; // await chatbotService.retrieveCustomerDiagnostics(cId); // } - - - - + --> diff --git a/src/modules/chatbot/components/dialogue-content.vue b/src/modules/chatbot/components/dialogue-content.vue index 5578c15..81cedca 100644 --- a/src/modules/chatbot/components/dialogue-content.vue +++ b/src/modules/chatbot/components/dialogue-content.vue @@ -1,52 +1,30 @@ -