From 3617d4078ce30dffc53e868070fd9f13b134f9a6 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 24 Jan 2024 17:00:13 -0600 Subject: [PATCH] end conversation --- src/lib/scss/custom/pages/_conversation.scss | 2 +- .../[conversationId]/chat-box.svelte | 26 ++++++++++++++++--- src/routes/page/conversation/+page.svelte | 2 +- .../[conversationId]/+page.svelte | 5 ++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/lib/scss/custom/pages/_conversation.scss b/src/lib/scss/custom/pages/_conversation.scss index 972693ee..84e86b15 100644 --- a/src/lib/scss/custom/pages/_conversation.scss +++ b/src/lib/scss/custom/pages/_conversation.scss @@ -1,4 +1,4 @@ -.conv-delete-modal { +.delete-modal { button { outline: none !important; box-shadow: none !important; diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 7b03b2cf..188e6a44 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -22,6 +22,8 @@ import ContentLog from './content-log.svelte'; import { replaceNewLine } from '$lib/helpers/http'; import _ from "lodash"; + import Swal from 'sweetalert2/dist/sweetalert2.js'; + import "sweetalert2/src/sweetalert2.scss"; const options = { scrollbars: { @@ -148,8 +150,26 @@ await sendMessageToHub(params.agentId, params.conversationId, text); } - function close() { - window.parent.postMessage({ action: "close" }, "*"); + function endChat() { + if (window.location === window.parent.location) { + // @ts-ignore + Swal.fire({ + title: 'Are you sure?', + text: "You will exit this conversation.", + icon: 'warning', + customClass: 'delete-modal', + showCancelButton: true, + confirmButtonText: 'Yes', + cancelButtonText: 'No' + // @ts-ignore + }).then((result) => { + if (result.value) { + window.close(); + } + }); + } else { + window.parent.postMessage({ action: "close" }, "*"); + } } function closeLog() { @@ -186,7 +206,7 @@ {/if}
  • diff --git a/src/routes/page/conversation/+page.svelte b/src/routes/page/conversation/+page.svelte index d8fdb997..cef4872a 100644 --- a/src/routes/page/conversation/+page.svelte +++ b/src/routes/page/conversation/+page.svelte @@ -123,7 +123,7 @@ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', - customClass: 'conv-delete-modal', + customClass: 'delete-modal', showCancelButton: true, confirmButtonText: 'Yes, delete it!' // @ts-ignore diff --git a/src/routes/page/conversation/[conversationId]/+page.svelte b/src/routes/page/conversation/[conversationId]/+page.svelte index 24ed7833..9e1b7b1b 100644 --- a/src/routes/page/conversation/[conversationId]/+page.svelte +++ b/src/routes/page/conversation/[conversationId]/+page.svelte @@ -21,17 +21,18 @@ }); function handleConversationDeletion() { + // @ts-ignore Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, - customClass: 'conv-delete-modal', + customClass: 'delete-modal', confirmButtonText: 'Yes, delete it!' + // @ts-ignore }).then(async (result) => { if (result.value) { await deleteConversation(conversation.id); - // Swal.fire('Deleted!', 'Your file has been deleted.', 'success'); window.location.href = "/page/conversation"; } });