fix(reports): show Tahesab sales link only when connection exists

Require both the tahesab org module and at least one enabled accounting connection.
This commit is contained in:
2026-10-24 09:39:45 +03:30
parent 5be0bc6f5e
commit 7d9fc8447f
+30 -2
View File
@@ -38,6 +38,7 @@ import type {
ReportsPeriodCompareRowDto, ReportsPeriodCompareRowDto,
ReportsViewFilters, ReportsViewFilters,
SavedViewDto, SavedViewDto,
TahesabConnectionDto,
TeamDto, TeamDto,
} from '@mento/shared'; } from '@mento/shared';
import { import {
@@ -107,6 +108,14 @@ const builderResult = ref<ReportsBuilderResultDto | null>(null);
const orgUsers = ref<OrgUserDto[]>([]); const orgUsers = ref<OrgUserDto[]>([]);
const orgTeams = ref<TeamDto[]>([]); const orgTeams = ref<TeamDto[]>([]);
const teamsAvailable = ref(true); const teamsAvailable = ref(true);
/** ماژول ته‌حساب فعال + حداقل یک اتصال تنظیم‌شده */
const hasTahesabSetup = ref(false);
const showTahesabSalesReport = computed(
() =>
Boolean(auth.user?.enabledModules?.includes('tahesab')) &&
hasTahesabSetup.value,
);
const currency = computed( const currency = computed(
() => () =>
@@ -597,8 +606,27 @@ async function copyShareLink() {
} }
} }
async function loadTahesabSetup() {
if (!auth.user?.enabledModules?.includes('tahesab')) {
hasTahesabSetup.value = false;
return;
}
try {
const { data } = await api.get<TahesabConnectionDto[]>(
'/integrations/tahesab/connections/public',
);
hasTahesabSetup.value = (data ?? []).some((c) => c.enabled);
} catch {
hasTahesabSetup.value = false;
}
}
async function bootstrap() { async function bootstrap() {
await Promise.all([loadSavedViews(), loadFilterOptions()]); await Promise.all([
loadSavedViews(),
loadFilterOptions(),
loadTahesabSetup(),
]);
const viewId = const viewId =
typeof route.query.view === 'string' ? route.query.view.trim() : ''; typeof route.query.view === 'string' ? route.query.view.trim() : '';
if (viewId) { if (viewId) {
@@ -1140,7 +1168,7 @@ const activityMax = computed(() =>
> >
<template #actions> <template #actions>
<UiButton <UiButton
v-if="auth.user?.enabledModules?.includes('tahesab')" v-if="showTahesabSalesReport"
variant="secondary" variant="secondary"
@click="router.push({ name: 'tahesab-sales-report' })" @click="router.push({ name: 'tahesab-sales-report' })"
> >