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:
@@ -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 }
|
||||
})
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
Reference in New Issue
Block a user