пароль на семьи

This commit is contained in:
arrelin
2025-12-15 16:51:09 +03:00
parent 1e393c79b5
commit 27d8d8ff4c
12 changed files with 330 additions and 28 deletions

View File

@@ -97,18 +97,25 @@ export default function FamilyView() {
const handleResetLimit = async (categoryId: number) => {
if (!familyId) return;
const newLimit = prompt('Введите новый лимит:');
if (!newLimit) return;
if (!confirm('Удалить все траты по этой категории?')) return;
try {
await categoryApi.resetLimit(
const expensesResponse = await expenseApi.getAllByCategory(
parseInt(familyId),
categoryId,
parseFloat(newLimit)
categoryId
);
for (const expense of expensesResponse.data) {
await expenseApi.delete(
parseInt(familyId),
categoryId,
expense.id
);
}
loadCategories();
} catch (err) {
alert('Ошибка сброса лимита');
alert('Ошибка сброса трат');
console.error(err);
}
};
@@ -280,7 +287,7 @@ export default function FamilyView() {
onClick={() => handleResetLimit(category.id)}
className="px-4 py-1 bg-yellow-500 text-white rounded hover:bg-yellow-600"
>
Сбросить лимит
Обнулить траты
</button>
<button
onClick={() => handleDeleteCategory(category.id)}