|
@@ -1296,14 +1296,15 @@
|
|
|
<textarea
|
|
<textarea
|
|
|
v-model="chatReply"
|
|
v-model="chatReply"
|
|
|
class="chat-reply-input"
|
|
class="chat-reply-input"
|
|
|
- placeholder="Type a reply…"
|
|
|
|
|
|
|
+ :placeholder="chatSendReady ? 'Type a reply…' : 'Sending not available for this service.'"
|
|
|
|
|
+ :disabled="!chatSendReady"
|
|
|
rows="6"
|
|
rows="6"
|
|
|
></textarea>
|
|
></textarea>
|
|
|
<div class="chat-reply-footer">
|
|
<div class="chat-reply-footer">
|
|
|
<span v-if="chatSendError" class="chat-send-err">{{ chatSendError }}</span>
|
|
<span v-if="chatSendError" class="chat-send-err">{{ chatSendError }}</span>
|
|
|
<button
|
|
<button
|
|
|
class="chat-send-btn"
|
|
class="chat-send-btn"
|
|
|
- :disabled="!chatReply.trim() || chatSending"
|
|
|
|
|
|
|
+ :disabled="!chatSendReady || !chatReply.trim() || chatSending"
|
|
|
@click="sendChatMessage"
|
|
@click="sendChatMessage"
|
|
|
>{{ chatSending ? 'Sending…' : 'Send' }}</button>
|
|
>{{ chatSending ? 'Sending…' : 'Send' }}</button>
|
|
|
</div>
|
|
</div>
|
|
@@ -1412,12 +1413,13 @@ createApp({
|
|
|
const healthStatus = ref('idle');
|
|
const healthStatus = ref('idle');
|
|
|
|
|
|
|
|
// ── Chat ───────────────────────────────────────────────
|
|
// ── Chat ───────────────────────────────────────────────
|
|
|
- const chatThread = ref(null);
|
|
|
|
|
- const chatLoading = ref(false);
|
|
|
|
|
- const chatError = ref(null);
|
|
|
|
|
- const chatReply = ref('');
|
|
|
|
|
- const chatSending = ref(false);
|
|
|
|
|
- const chatSendError = ref(null);
|
|
|
|
|
|
|
+ const chatThread = ref(null);
|
|
|
|
|
+ const chatLoading = ref(false);
|
|
|
|
|
+ const chatError = ref(null);
|
|
|
|
|
+ const chatReply = ref('');
|
|
|
|
|
+ const chatSending = ref(false);
|
|
|
|
|
+ const chatSendError = ref(null);
|
|
|
|
|
+ const chatSendReady = ref(true);
|
|
|
const syncEnabled = ref(false);
|
|
const syncEnabled = ref(false);
|
|
|
const bulkEnabled = ref(false);
|
|
const bulkEnabled = ref(false);
|
|
|
const bulkDays = ref(new Set());
|
|
const bulkDays = ref(new Set());
|
|
@@ -1475,11 +1477,23 @@ createApp({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ async function loadChatSendReady(serviceKey) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const resp = await apiFetch(`${API_BASE}/chat/${serviceKey}/ready`);
|
|
|
|
|
+ if (!resp) return;
|
|
|
|
|
+ const data = await resp.json();
|
|
|
|
|
+ chatSendReady.value = data.ready ?? true;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ chatSendReady.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function loadChat() {
|
|
async function loadChat() {
|
|
|
const sel = selection.value;
|
|
const sel = selection.value;
|
|
|
if (!sel?.chat_id || !sel?.service) return;
|
|
if (!sel?.chat_id || !sel?.service) return;
|
|
|
chatLoading.value = true;
|
|
chatLoading.value = true;
|
|
|
chatError.value = null;
|
|
chatError.value = null;
|
|
|
|
|
+ loadChatSendReady(sel.service);
|
|
|
try {
|
|
try {
|
|
|
const resp = await apiFetch(`${API_BASE}/chat/${sel.service}/${sel.chat_id}`);
|
|
const resp = await apiFetch(`${API_BASE}/chat/${sel.service}/${sel.chat_id}`);
|
|
|
if (!resp) { chatLoading.value = false; return; }
|
|
if (!resp) { chatLoading.value = false; return; }
|
|
@@ -1564,8 +1578,9 @@ createApp({
|
|
|
|
|
|
|
|
watch(selection, (sel) => {
|
|
watch(selection, (sel) => {
|
|
|
if (sel?.type === 'res' && sel.chat_id && selectionSupportsChat.value) {
|
|
if (sel?.type === 'res' && sel.chat_id && selectionSupportsChat.value) {
|
|
|
- chatThread.value = null;
|
|
|
|
|
- chatError.value = null;
|
|
|
|
|
|
|
+ chatThread.value = null;
|
|
|
|
|
+ chatError.value = null;
|
|
|
|
|
+ chatSendReady.value = true;
|
|
|
loadChat();
|
|
loadChat();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -1908,9 +1923,10 @@ createApp({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function selectReservation(span) {
|
|
function selectReservation(span) {
|
|
|
- chatThread.value = null;
|
|
|
|
|
- chatError.value = null;
|
|
|
|
|
- chatReply.value = '';
|
|
|
|
|
|
|
+ chatThread.value = null;
|
|
|
|
|
+ chatError.value = null;
|
|
|
|
|
+ chatReply.value = '';
|
|
|
|
|
+ chatSendReady.value = true;
|
|
|
selection.value = {
|
|
selection.value = {
|
|
|
type: 'res',
|
|
type: 'res',
|
|
|
key: span.resKey,
|
|
key: span.resKey,
|
|
@@ -2436,7 +2452,7 @@ createApp({
|
|
|
bulkEnabled, bulkDays, bulkSortedKeys, bulkPriceSummary, bulkDiscountSummary,
|
|
bulkEnabled, bulkDays, bulkSortedKeys, bulkPriceSummary, bulkDiscountSummary,
|
|
|
bulkStatusSummary, bulkActiveDiscountType, bulkToggleClosed,
|
|
bulkStatusSummary, bulkActiveDiscountType, bulkToggleClosed,
|
|
|
CAT, DAYS,
|
|
CAT, DAYS,
|
|
|
- chatThread, chatLoading, chatError, chatReply, chatSending, chatSendError,
|
|
|
|
|
|
|
+ chatThread, chatLoading, chatError, chatReply, chatSending, chatSendError, chatSendReady,
|
|
|
selectionSupportsChat, visibleChatMessages, chatSenderLabel, chatMessagesEl,
|
|
selectionSupportsChat, visibleChatMessages, chatSenderLabel, chatMessagesEl,
|
|
|
loadChat, sendChatMessage, fmtChatTime,
|
|
loadChat, sendChatMessage, fmtChatTime,
|
|
|
runHealthCheck, toggleSync, toggleBulk, fetchDiff, fixDay, fixResChanges, fixBusy, fixDayBusy, fixMonthBusy, FIX,
|
|
runHealthCheck, toggleSync, toggleBulk, fetchDiff, fixDay, fixResChanges, fixBusy, fixDayBusy, fixMonthBusy, FIX,
|