fix(autocall): в истории заказа слот тоже показываем датой
Таймлайн заказа дублировал ту же подпись «завтра/послезавтра»; теперь берёт дату из общей функции (chosen_date строки лога или дата заказа).
This commit is contained in:
parent
3a4cceb9a4
commit
21eade5d3f
|
|
@ -1,5 +1,6 @@
|
|||
import React, { useEffect, useState, useMemo } from "react";
|
||||
import { supabase } from "../../supabaseClient";
|
||||
import { autocallSlotText } from "./autocallSlot";
|
||||
|
||||
// ─── Status labels ──────────────────────────────────────────────────
|
||||
const STATUS_LABELS = {
|
||||
|
|
@ -115,18 +116,6 @@ const AUTOCALL_OUTCOME_LABELS = {
|
|||
error: { label: "Автодозвон: ошибка звонка", tone: "danger", icon: "🤖" },
|
||||
};
|
||||
|
||||
const AUTOCALL_DAY_LABEL = { 1: "завтра", 2: "послезавтра" };
|
||||
const AUTOCALL_HALF_LABEL = { 1: "первая половина дня", 2: "вторая половина дня" };
|
||||
|
||||
const autocallSlotText = (l) => {
|
||||
if (!l) return null;
|
||||
const day = AUTOCALL_DAY_LABEL[l.dtmf_day];
|
||||
const half = AUTOCALL_HALF_LABEL[l.dtmf_half];
|
||||
if (day && half) return `${day}, ${half}`;
|
||||
if (day) return day;
|
||||
return null;
|
||||
};
|
||||
|
||||
const fmtTimestamp = (ts) => {
|
||||
if (!ts) return "—";
|
||||
try {
|
||||
|
|
@ -388,7 +377,7 @@ const StatusSummary = ({ order, smsLogs = [], autocallLogs = [] }) => {
|
|||
const lastAutocall = confirmedAutocall || (autocallLogs && autocallLogs.length > 0 ? autocallLogs[0] : null);
|
||||
if (lastAutocall) {
|
||||
const acMeta = AUTOCALL_OUTCOME_LABELS[lastAutocall.outcome] || { label: lastAutocall.outcome || "—", tone: "muted" };
|
||||
const acSlot = autocallSlotText(lastAutocall);
|
||||
const acSlot = autocallSlotText(lastAutocall, order);
|
||||
const acValue = acSlot ? `${acMeta.label} · ${acSlot}` : acMeta.label;
|
||||
items.push({
|
||||
icon: "🤖",
|
||||
|
|
@ -495,7 +484,7 @@ export const OrderHistoryTimeline = ({ order, userRole }) => {
|
|||
try {
|
||||
const { data: acData, error: acError } = await supabase
|
||||
.from("autocall_log")
|
||||
.select("id, outcome, attempt_no, scenario, dtmf_day, dtmf_half, changed, was_test_mode, sip_code, duration_sec, created_at")
|
||||
.select("id, outcome, attempt_no, scenario, dtmf_day, dtmf_half, chosen_date, changed, was_test_mode, sip_code, duration_sec, created_at")
|
||||
.eq("order_group_id", order.id)
|
||||
.order("created_at", { ascending: false })
|
||||
.limit(50);
|
||||
|
|
@ -627,7 +616,7 @@ export const OrderHistoryTimeline = ({ order, userRole }) => {
|
|||
if (autocallLogs && autocallLogs.length > 0) {
|
||||
for (const ac of autocallLogs) {
|
||||
const meta = AUTOCALL_OUTCOME_LABELS[ac.outcome] || { label: `Автодозвон: ${ac.outcome || "—"}`, tone: "muted", icon: "🤖" };
|
||||
const slot = autocallSlotText(ac);
|
||||
const slot = autocallSlotText(ac, order);
|
||||
events.push({
|
||||
id: `autocall-${ac.id}`,
|
||||
created_at: ac.created_at,
|
||||
|
|
|
|||
Loading…
Reference in New Issue