|
19 | 19 | import RcQuickReply from './rc-quick-reply.svelte'; |
20 | 20 | import { PUBLIC_LIVECHAT_ENTRY_ICON } from '$env/static/public'; |
21 | 21 | import ContentLog from './content-log.svelte'; |
| 22 | + import Swal from 'sweetalert2/dist/sweetalert2.js'; |
| 23 | + import "sweetalert2/src/sweetalert2.scss"; |
| 24 | + import { replaceNewLine } from '$lib/helpers/http'; |
22 | 25 |
|
23 | 26 | const options = { |
24 | 27 | scrollbars: { |
|
135 | 138 |
|
136 | 139 | /** @param {any} e */ |
137 | 140 | async function onSendMessage(e) { |
138 | | - if (e.key !== 'Enter') return; |
| 141 | + if ((e.key === 'Enter' && !!e.shiftKey) || e.key !== 'Enter') return; |
139 | 142 | await sendMessageToHub(params.agentId, params.conversationId, text); |
140 | 143 | } |
141 | 144 |
|
142 | | - function close() { |
143 | | - window.parent.postMessage({ action: "close" }, "*"); |
| 145 | + function endChat() { |
| 146 | + // @ts-ignore |
| 147 | + Swal.fire({ |
| 148 | + title: 'Are you sure?', |
| 149 | + text: "You will exit this conversation.", |
| 150 | + icon: 'warning', |
| 151 | + customClass: 'conv-delete-modal', |
| 152 | + showCancelButton: true, |
| 153 | + confirmButtonText: 'Yes', |
| 154 | + cancelButtonText: 'No' |
| 155 | + // @ts-ignore |
| 156 | + }).then((result) => { |
| 157 | + if (result.value) { |
| 158 | + window.close(); |
| 159 | + } |
| 160 | + }); |
144 | 161 | } |
145 | 162 |
|
146 | 163 | function closeLog() { |
|
176 | 193 | {/if} |
177 | 194 | <li class="list-inline-item d-sm-inline-block"> |
178 | 195 | <button type="submit" class="btn btn-primary btn-rounded chat-send waves-effect waves-light" |
179 | | - on:click={close} |
| 196 | + on:click={() => endChat()} |
180 | 197 | > |
181 | 198 | <span class="d-none d-sm-inline-block me-2" >End Conversation</span> <i class="mdi mdi-window-close"></i> |
182 | 199 | </button> |
|
186 | 203 | </div> |
187 | 204 | </div> |
188 | 205 |
|
189 | | - <div class="scrollbar" style="height: 80vh"> |
| 206 | + <div class="scrollbar" style="height: 75vh"> |
190 | 207 | <div class="chat-conversation p-3"> |
191 | 208 | <ul class="list-unstyled mb-0"> |
192 | 209 | <li> |
|
221 | 238 | {#if message.sender.id === currentUser.id} |
222 | 239 | <div class="ctext-wrap float-end"> |
223 | 240 | <!--<div class="conversation-name">{message.sender.full_name}</div>--> |
224 | | - <span>{message.text}</span> |
| 241 | + <span>{@html replaceNewLine(message.text)}</span> |
225 | 242 | <p class="chat-time mb-0"> |
226 | 243 | <i class="bx bx-time-five align-middle me-1" /> |
227 | 244 | <!-- {format(message.created_at, 'short-time')} --> |
|
252 | 269 | </div> |
253 | 270 | </div> |
254 | 271 |
|
255 | | - <div class="p-3 chat-input-section" style="height: 10vh"> |
| 272 | + <div class="p-3 chat-input-section" style="height: 15vh"> |
256 | 273 | <div class="row"> |
257 | 274 | <div class="col-auto"> |
258 | 275 | <button |
|
264 | 281 | </div> |
265 | 282 | <div class="col"> |
266 | 283 | <div class="position-relative"> |
267 | | - <textarea rows={1} class="form-control chat-input" bind:value={text} on:keydown={e => { onSendMessage(e); }} placeholder="Enter Message..." /> |
| 284 | + <textarea rows={3} maxlength={500} class="form-control chat-input" bind:value={text} on:keydown={e => onSendMessage(e)} placeholder="Enter Message..." /> |
268 | 285 | <div class="chat-input-links" id="tooltip-container"> |
269 | 286 | <ul class="list-inline mb-0"> |
270 | 287 | <li class="list-inline-item"> |
|
0 commit comments