feat: excluir transações de extrato + delete em lote por mês

Remove restrição que bloqueava delete de transações importadas.
Adiciona DELETE /transactions?month=YYYY-MM para exclusão em lote
e botão "EXCLUIR MÊS" na view de transações.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
2026-05-27 16:41:26 -03:00
co-authored by Claude Sonnet 4.6
parent 0507d7bff3
commit 88461a4aea
6 changed files with 50 additions and 5 deletions
+8 -1
View File
@@ -60,5 +60,12 @@ export const useTransactionsStore = defineStore('transactions', () => {
transactions.value = transactions.value.filter((x) => x.id !== id)
}
return { transactions, loading, error, fetchAll, create, update, remove }
async function removeByMonth(month: string) {
await api.delete(`/transactions?month=${month}`)
transactions.value = transactions.value.filter(
(x) => x.date.slice(0, 7) !== month,
)
}
return { transactions, loading, error, fetchAll, create, update, remove, removeByMonth }
})
+11
View File
@@ -73,6 +73,12 @@ async function remove(id: number) {
try { await store.remove(id) } catch (e: any) { alert(e.message) }
}
async function removeMonth() {
const label = monthLabel(currentMonth.value)
if (!confirm(`Excluir TODAS as transações de ${label}?`)) return
try { await store.removeByMonth(currentMonth.value) } catch (e: any) { alert(e.message) }
}
function fmt(v: number) {
return v.toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' })
}
@@ -98,6 +104,11 @@ function monthLabel(ym: string) {
@prev="changeMonth(-1)"
@next="changeMonth(1)"
/>
<button
v-if="store.transactions.length > 0"
class="fc-btn fc-btn--sm fc-btn--danger"
@click="removeMonth"
>EXCLUIR MÊS</button>
</div>
<!-- Form -->