fix spaces
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<!-- {{ tg_id }}-->
|
||||
<Button label="Sub" :class="checkNotif ? 'flex' : '!hidden'" @click="checkSubscribe"/>
|
||||
|
||||
<!-- <router-view/>-->
|
||||
<router-view/>
|
||||
<div class="bg-gray-100 h-12 block lg:hidden"></div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import DatePicker from "primevue/datepicker";
|
||||
import {onMounted, ref} from "vue";
|
||||
import {getMonthName} from "@/utils/utils";
|
||||
import {Budget} from "@/models/Budget";
|
||||
import {getCategories} from "@/services/categoryService";
|
||||
|
||||
const props = defineProps({
|
||||
opened: {
|
||||
@@ -34,6 +35,10 @@ const create = async () => {
|
||||
}
|
||||
|
||||
}
|
||||
const categories = ref([])
|
||||
const fetchCategories = async () => {
|
||||
await getCategories().then(res => categories.value = res.data)
|
||||
}
|
||||
|
||||
const cancel = () => {
|
||||
emits("close-modal");
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
getBudgetTransactions,
|
||||
updateBudgetCategoryRequest,
|
||||
getWarns,
|
||||
hideWarnRequest
|
||||
hideWarnRequest, getBudgetInfos
|
||||
} from "@/services/budgetsService";
|
||||
import {Budget, BudgetCategory, Warn} from "@/models/Budget";
|
||||
import {useRoute} from "vue-router";
|
||||
@@ -24,6 +24,7 @@ import Divider from "primevue/divider";
|
||||
import {useDrawerStore} from "@/stores/drawerStore";
|
||||
import {EventBus} from '@/utils/EventBus.ts';
|
||||
import {useToast} from "primevue/usetoast";
|
||||
import {useSpaceStore} from "@/stores/spaceStore";
|
||||
|
||||
// Зарегистрируем плагин
|
||||
ChartJS.register(ChartDataLabels);
|
||||
@@ -719,17 +720,38 @@ watch([budget, plannedExpenses], () => {
|
||||
calendar.value = result;
|
||||
}, {immediate: true});
|
||||
|
||||
const spaceStore = useSpaceStore()
|
||||
const selectedSpace = computed(() => spaceStore.space)
|
||||
|
||||
watch(
|
||||
() => selectedSpace.value,
|
||||
async (newValue, oldValue) => {
|
||||
|
||||
if (newValue != oldValue || !oldValue) {
|
||||
try {
|
||||
loading.value = true;
|
||||
// Если выбранный space изменился, получаем новую информацию о бюджете
|
||||
fetchBudgetInfo()
|
||||
} catch (error) {
|
||||
console.error('Error fetching budget infos:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
updateLoading.value = true;
|
||||
|
||||
if (selectedSpace.value) {
|
||||
fetchBudgetInfo()
|
||||
fetchWarns()
|
||||
}
|
||||
EventBus.on('transactions-updated', fetchBudgetInfo, true);
|
||||
})
|
||||
|
||||
onUnmounted(async () => {
|
||||
onUnmounted(async () => {
|
||||
EventBus.off('transactions-updated', fetchBudgetInfo);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -185,10 +185,10 @@ const createTransaction = async (): Promise<void> => {
|
||||
loading.value = false;
|
||||
|
||||
// Фокусируем поле ввода суммы (при наличии)
|
||||
const inputEl = amountInput.value.$el.querySelector('input') as HTMLInputElement | null;
|
||||
if (inputEl) {
|
||||
inputEl.focus();
|
||||
}
|
||||
// const inputEl = amountInput.value.$el.querySelector('input') as HTMLInputElement | null;
|
||||
// if (inputEl) {
|
||||
// inputEl.focus();
|
||||
// }
|
||||
|
||||
// Вызываем событие создания транзакции и обновляем список транзакций
|
||||
emit('create-transaction', editedTransaction.value);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import apiClient from '@/services/axiosSetup';
|
||||
import {Budget, BudgetCategory} from "@/models/Budget";
|
||||
import {format} from "date-fns";
|
||||
import {useSpaceStore} from "@/stores/spaceStore";
|
||||
// Импортируете настроенный экземпляр axios
|
||||
|
||||
export const getBudgetInfos = async () => {
|
||||
@@ -62,8 +63,8 @@ export const getBudgetCategoriesSums = async (budgetId) => {
|
||||
}
|
||||
|
||||
export const getBudgetInfo = async (budget_id: string) => {
|
||||
|
||||
let budgetInfo = await apiClient.get('/budgets/' + budget_id);
|
||||
const spaceStore = useSpaceStore()
|
||||
let budgetInfo = await apiClient.get(`/spaces/${spaceStore.space?.id}/budgets/${budget_id}`);
|
||||
budgetInfo = budgetInfo.data;
|
||||
|
||||
budgetInfo.dateFrom = new Date(budgetInfo.dateFrom)
|
||||
@@ -87,7 +88,8 @@ export const hideWarnRequest = async (budgetId: string, warnId: string) => {
|
||||
}
|
||||
|
||||
export const updateBudgetCategoryRequest = async (budget_id, category: BudgetCategory) => {
|
||||
return await apiClient.post('/budgets/' + budget_id + '/categories/' + category.category.id + "/limit", {"limit": category.currentLimit}).then(i => i.data);
|
||||
const spaceStore = useSpaceStore()
|
||||
return await apiClient.post(`/spaces/${spaceStore.space?.id}/budgets/${budget_id}/categories/${category.category.id}/limit`, {"limit": category.currentLimit}).then(i => i.data);
|
||||
}
|
||||
|
||||
export const createBudget = async (budget: Budget, createRecurrent: Boolean) => {
|
||||
@@ -113,7 +115,8 @@ export const createBudget = async (budget: Budget, createRecurrent: Boolean) =>
|
||||
export const deleteBudgetRequest = async (budgetId: string) => {
|
||||
try {
|
||||
// throw Error("test")
|
||||
let response = await apiClient.delete(`/budgets/${budgetId}`);
|
||||
const spaceStore = useSpaceStore()
|
||||
let response = await apiClient.delete(`/spaces/${spaceStore.space?.id}/budgets/${budgetId}`);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user