пароль на семьи
This commit is contained in:
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user