fix(captain-reports): remove units filter, keep inbox-only filter

Replace unit+inbox combined dropdown with inbox-only select.
Add ALL_INBOXES i18n key in pt_BR and en. Units (Pix) are unrelated
to conversation reports.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Rodrigo Borba 2026-02-27 07:31:32 -03:00
parent 87bff8126c
commit a67d164e8f
3 changed files with 22 additions and 49 deletions

View File

@ -1024,9 +1024,10 @@
}, },
"CAPTAIN_REPORTS": { "CAPTAIN_REPORTS": {
"TITLE": "AI Reports", "TITLE": "AI Reports",
"DESC": "Weekly AI-generated insights based on conversations from each unit.", "DESC": "Weekly AI-generated insights based on conversations from each inbox.",
"LOADING": "Loading reports...", "LOADING": "Loading reports...",
"ALL_UNITS": "All units", "ALL_UNITS": "All units",
"ALL_INBOXES": "All inboxes",
"TABS": { "TABS": {
"INSIGHTS": "AI Insights", "INSIGHTS": "AI Insights",
"OPERATIONAL": "Operational" "OPERATIONAL": "Operational"

View File

@ -824,6 +824,7 @@
"DESC": "Análises semanais geradas por IA com base nas conversas de cada unidade.", "DESC": "Análises semanais geradas por IA com base nas conversas de cada unidade.",
"LOADING": "Carregando relatórios...", "LOADING": "Carregando relatórios...",
"ALL_UNITS": "Todas as unidades", "ALL_UNITS": "Todas as unidades",
"ALL_INBOXES": "Todas as caixas de entrada",
"TABS": { "TABS": {
"INSIGHTS": "Insights IA", "INSIGHTS": "Insights IA",
"OPERATIONAL": "Operacional" "OPERATIONAL": "Operacional"

View File

@ -10,53 +10,33 @@ import Button from 'dashboard/components-next/button/Button.vue';
const { t } = useI18n(); const { t } = useI18n();
const store = useStore(); const store = useStore();
const units = useMapGetter('captainUnits/getUnits');
const inboxes = useMapGetter('inboxes/getInboxes'); const inboxes = useMapGetter('inboxes/getInboxes');
const insights = useMapGetter('captainReports/getInsights'); const insights = useMapGetter('captainReports/getInsights');
const uiFlags = useMapGetter('captainReports/getUIFlags'); const uiFlags = useMapGetter('captainReports/getUIFlags');
const activeTab = ref('insights'); const activeTab = ref('insights');
const selectedFilter = ref({ type: 'unit', id: null }); const selectedInboxId = ref(null);
const tabs = [{ key: 'insights' }, { key: 'operational' }]; const tabs = [{ key: 'insights' }, { key: 'operational' }];
onMounted(async () => { onMounted(async () => {
await store.dispatch('captainUnits/get');
await store.dispatch('inboxes/get'); await store.dispatch('inboxes/get');
await store.dispatch('captainReports/fetchInsights', { await store.dispatch('captainReports/fetchInsights', {});
unit_id: null,
});
}); });
const onFilterChange = async event => { const onFilterChange = async event => {
const value = event.target.value; const value = event.target.value;
if (!value) { selectedInboxId.value = value ? Number(value) : null;
selectedFilter.value = { type: 'unit', id: null }; await store.dispatch('captainReports/fetchInsights', {
} else { inbox_id: selectedInboxId.value,
const [type, id] = value.split(':'); });
selectedFilter.value = { type, id: Number(id) };
}
const params = {};
if (selectedFilter.value.type === 'unit') {
params.unit_id = selectedFilter.value.id;
} else {
params.inbox_id = selectedFilter.value.id;
}
await store.dispatch('captainReports/fetchInsights', params);
}; };
const onGenerateInsight = async () => { const onGenerateInsight = async () => {
const params = {};
if (selectedFilter.value.type === 'unit') {
params.unit_id = selectedFilter.value.id;
} else {
params.inbox_id = selectedFilter.value.id;
}
try { try {
await store.dispatch('captainReports/generateInsight', params); await store.dispatch('captainReports/generateInsight', {
inbox_id: selectedInboxId.value,
});
useAlert(t('CAPTAIN_REPORTS.GENERATE.SUCCESS')); useAlert(t('CAPTAIN_REPORTS.GENERATE.SUCCESS'));
} catch { } catch {
useAlert(t('CAPTAIN_REPORTS.GENERATE.ERROR')); useAlert(t('CAPTAIN_REPORTS.GENERATE.ERROR'));
@ -108,25 +88,16 @@ const periodLabel = insight =>
class="rounded-lg border border-n-weak bg-n-alpha-1 px-3 py-2 text-sm text-n-slate-12 focus:outline-none focus:ring-2 focus:ring-n-brand" class="rounded-lg border border-n-weak bg-n-alpha-1 px-3 py-2 text-sm text-n-slate-12 focus:outline-none focus:ring-2 focus:ring-n-brand"
@change="onFilterChange" @change="onFilterChange"
> >
<option value="">{{ t('CAPTAIN_REPORTS.ALL_UNITS') }}</option> <option value="">
<optgroup :label="t('CAPTAIN_REPORTS.UNITS_GROUP')"> {{ t('CAPTAIN_REPORTS.ALL_INBOXES') }}
<option </option>
v-for="unit in units" <option
:key="unit.id" v-for="inbox in inboxes"
:value="`unit:${unit.id}`" :key="inbox.id"
> :value="inbox.id"
{{ unit.name }} >
</option> {{ inbox.name }}
</optgroup> </option>
<optgroup :label="t('CAPTAIN_REPORTS.INBOXES_GROUP')">
<option
v-for="inbox in inboxes"
:key="inbox.id"
:value="`inbox:${inbox.id}`"
>
{{ inbox.name }}
</option>
</optgroup>
</select> </select>
<Button <Button