22 lines
670 B
TypeScript
22 lines
670 B
TypeScript
import { defineStore } from 'pinia';
|
|
import { ref } from 'vue';
|
|
import { fetchDealsCount } from '../api/deals';
|
|
|
|
/**
|
|
* Счётчик сделок tenant'а для бейджа «Сделки» в AppSidebar (audit B2).
|
|
* count=null до загрузки или на fail → бейдж скрыт (resolveCount → 0).
|
|
*/
|
|
export const useDealsCountStore = defineStore('dealsCount', () => {
|
|
const count = ref<number | null>(null);
|
|
|
|
async function load(tenantId: number): Promise<void> {
|
|
try {
|
|
count.value = await fetchDealsCount(tenantId);
|
|
} catch {
|
|
count.value = null;
|
|
}
|
|
}
|
|
|
|
return { count, load };
|
|
});
|