fix(reports): inbox_id reativo + nome da inbox visível na tab Novas × Retorno

Bugs originais (tabela Reports → Inbox → unidade específica → Novas × Retorno):
1. Backend recebia sempre inbox_id=1 — useFunctionGetter('inboxes/getInboxById', route.params.id)
   passava string crua, não Ref reativa, então o getter ficava travado no ID inicial
2. UX: tab não mostrava qual unidade estava sendo filtrada

Correções:
- InboxReportsShow.vue: passa inboxIdParam computed pra useFunctionGetter (reativo agora)
- Passa inbox.name como prop pro InboxLeadsReport
- InboxLeadsReport.vue: header com título + label "Caixa de entrada: <nome>" no topo

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rodribm10 2026-04-26 09:14:44 -03:00
parent 3897db325e
commit 429567495f
4 changed files with 25 additions and 3 deletions

View File

@ -286,6 +286,8 @@
"LEADS": "New × Returning" "LEADS": "New × Returning"
}, },
"LEADS": { "LEADS": {
"TITLE": "New × Returning",
"INBOX_LABEL": "Inbox:",
"EMPTY": "No conversations in this period.", "EMPTY": "No conversations in this period.",
"TOTAL": "Total conversations in the period: {count}", "TOTAL": "Total conversations in the period: {count}",
"METRICS": { "METRICS": {

View File

@ -276,6 +276,8 @@
"LEADS": "Novas × Retorno" "LEADS": "Novas × Retorno"
}, },
"LEADS": { "LEADS": {
"TITLE": "Novas × Retorno",
"INBOX_LABEL": "Caixa de entrada:",
"EMPTY": "Sem conversas no período.", "EMPTY": "Sem conversas no período.",
"TOTAL": "Total de conversas no período: {count}", "TOTAL": "Total de conversas no período: {count}",
"METRICS": { "METRICS": {

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref } from 'vue'; import { computed, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useFunctionGetter } from 'dashboard/composables/store'; import { useFunctionGetter } from 'dashboard/composables/store';
@ -8,7 +8,8 @@ import InboxLeadsReport from './components/InboxLeadsReport.vue';
import Spinner from 'dashboard/components-next/spinner/Spinner.vue'; import Spinner from 'dashboard/components-next/spinner/Spinner.vue';
const route = useRoute(); const route = useRoute();
const inbox = useFunctionGetter('inboxes/getInboxById', route.params.id); const inboxIdParam = computed(() => route.params.id);
const inbox = useFunctionGetter('inboxes/getInboxById', inboxIdParam);
const TABS = { const TABS = {
OVERVIEW: 'overview', OVERVIEW: 'overview',
@ -63,6 +64,7 @@ const activeTab = ref(TABS.OVERVIEW);
v-else-if="activeTab === TABS.LEADS" v-else-if="activeTab === TABS.LEADS"
:key="`leads-${inbox.id}`" :key="`leads-${inbox.id}`"
:inbox-id="inbox.id" :inbox-id="inbox.id"
:inbox-name="inbox.name"
/> />
</div> </div>
</div> </div>

View File

@ -13,6 +13,10 @@ const props = defineProps({
type: [Number, String], type: [Number, String],
required: true, required: true,
}, },
inboxName: {
type: String,
default: '',
},
}); });
const store = useStore(); const store = useStore();
@ -85,7 +89,7 @@ const chartOptions = {
}; };
const fetchData = () => { const fetchData = () => {
if (!filters.value.from || !filters.value.to) return; if (!filters.value.from || !filters.value.to || !props.inboxId) return;
store.dispatch('fetchInboxLeadsSummary', { store.dispatch('fetchInboxLeadsSummary', {
inboxId: props.inboxId, inboxId: props.inboxId,
from: filters.value.from, from: filters.value.from,
@ -111,6 +115,18 @@ watch(
<template> <template>
<div class="flex flex-col gap-6"> <div class="flex flex-col gap-6">
<div class="flex items-center justify-between">
<div>
<h2 class="text-base font-semibold text-n-slate-12 m-0">
{{ $t('INBOX_REPORTS.LEADS.TITLE') }}
</h2>
<p v-if="inboxName" class="text-sm text-n-slate-11 mt-1 mb-0">
<span>{{ $t('INBOX_REPORTS.LEADS.INBOX_LABEL') }}</span>
<span class="font-medium text-n-slate-12 ms-1">{{ inboxName }}</span>
</p>
</div>
</div>
<ReportFilters <ReportFilters
filter-type="inboxes" filter-type="inboxes"
:selected-item="{ id: Number(inboxId) }" :selected-item="{ id: Number(inboxId) }"