1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-23 15:19:38 +02:00

fix: remove transaction form controller (#2279)

This commit is contained in:
Luan Estradioto 2025-05-22 12:30:33 -03:00 committed by GitHub
parent a7438e5c78
commit 2fbd6cbc5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 24 deletions

View file

@ -1,22 +0,0 @@
import {Controller} from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["expenseCategories", "incomeCategories"]
connect() {
this.updateCategories()
}
updateCategories(event) {
const natureField = this.element.querySelector('input[name="account_entry[nature]"]:checked')
const natureValue = natureField ? natureField.value : 'outflow'
if (natureValue === 'inflow') {
this.expenseCategoriesTarget.classList.add('hidden')
this.incomeCategoriesTarget.classList.remove('hidden')
} else {
this.expenseCategoriesTarget.classList.remove('hidden')
this.incomeCategoriesTarget.classList.add('hidden')
}
}
}

View file

@ -1,6 +1,6 @@
<%# locals: (entry:, income_categories:, expense_categories:) %> <%# locals: (entry:, income_categories:, expense_categories:) %>
<%= styled_form_with model: entry, url: transactions_path, class: "space-y-4", data: { controller: "transaction-form" } do |f| %> <%= styled_form_with model: entry, url: transactions_path, class: "space-y-4" do |f| %>
<% if entry.errors.any? %> <% if entry.errors.any? %>
<%= render "shared/form_errors", model: entry %> <%= render "shared/form_errors", model: entry %>
<% end %> <% end %>
@ -8,7 +8,7 @@
<section> <section>
<%= render "shared/transaction_type_tabs", active_tab: params[:nature] == "inflow" ? "income" : "expense", account_id: params[:account_id] %> <%= render "shared/transaction_type_tabs", active_tab: params[:nature] == "inflow" ? "income" : "expense", account_id: params[:account_id] %>
<%= f.hidden_field :nature, value: params[:nature] || "outflow", data: { "transaction-form-target": "natureField" } %> <%= f.hidden_field :nature, value: params[:nature] || "outflow" %>
<%= f.hidden_field :entryable_type, value: "Transaction" %> <%= f.hidden_field :entryable_type, value: "Transaction" %>
</section> </section>