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,
ReportsViewFilters,
SavedViewDto,
TahesabConnectionDto,
TeamDto,
} from '@mento/shared';
import {
@@ -107,6 +108,14 @@ const builderResult = ref<ReportsBuilderResultDto | null>(null);
const orgUsers = ref<OrgUserDto[]>([]);
const orgTeams = ref<TeamDto[]>([]);
const teamsAvailable = ref(true);
/** ماژول ته‌حساب فعال + حداقل یک اتصال تنظیم‌شده */
const hasTahesabSetup = ref(false);
const showTahesabSalesReport = computed(
() =>
Boolean(auth.user?.enabledModules?.includes('tahesab')) &&
hasTahesabSetup.value,
);
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() {
await Promise.all([loadSavedViews(), loadFilterOptions()]);
await Promise.all([
loadSavedViews(),
loadFilterOptions(),
loadTahesabSetup(),
]);
const viewId =
typeof route.query.view === 'string' ? route.query.view.trim() : '';
if (viewId) {
@@ -1140,7 +1168,7 @@ const activityMax = computed(() =>
>
<template #actions>
<UiButton
v-if="auth.user?.enabledModules?.includes('tahesab')"
v-if="showTahesabSalesReport"
variant="secondary"
@click="router.push({ name: 'tahesab-sales-report' })"
>