<%= form_with model: [:agent_portal, @customer], local: true, data: { turbo: false } do |f| %>
Customer Information
<%= f.hidden_field :registration_date %>
<%= f.label :customer_type_id, class: "form-label small text-muted" %> <%= f.collection_select :customer_type_id, CustomerType.all, :id, :name, { prompt: "Select type" }, class: "form-select form-select-sm rounded-pill" %>
<%= f.label :customer_group_id, class: "form-label small text-muted" %> <%= f.collection_select :customer_group_id, CustomerGroup.all, :id, :name, { prompt: "Select group" }, class: "form-select form-select-sm rounded-pill" %>
<%= f.label :firstname, class: "form-label small text-muted" %> <%= f.text_field :firstname, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :middlename, class: "form-label small text-muted" %> <%= f.text_field :middlename, placeholder: "N/A if none", class: "form-control form-control-sm rounded-pill" %>
<%= f.label :lastname, class: "form-label small text-muted" %> <%= f.text_field :lastname, class: "form-control form-control-sm rounded-pill" %>
Identification Type
<%= f.radio_button :id_type, 'nationalid', id: 'id_type_nationalid', class: "form-check-input", data: { action: "change->customer#idTypeChanged" } %> <%= f.label :id_type, 'National ID', for: 'id_type_nationalid', class: "form-check-label small" %>
<%= f.radio_button :id_type, 'passport', id: 'id_type_passport', class: "form-check-input", data: { action: "change->customer#idTypeChanged" } %> <%= f.label :id_type, 'Passport', for: 'id_type_passport', class: "form-check-label small" %>
<%= f.label :idnumber, "Identification Number", class: "form-label small text-muted" %> <%= f.text_field :idnumber, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :issuing_country, class: "form-label small text-muted" %> <%= f.text_field :issuing_country, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :dob, class: "form-label small text-muted" %> <%= f.date_field :dob, class: "form-control form-control-sm rounded-pill", data: { action: "change->customer#dobChanged" } %>
Gender
<%= f.radio_button :sex, true, id: 'sex_male', class: "form-check-input" %> <%= f.label :sex, 'Male', for: 'sex_male', class: "form-check-label small" %>
<%= f.radio_button :sex, false, id: 'sex_female', class: "form-check-input" %> <%= f.label :sex, 'Female', for: 'sex_female', class: "form-check-label small" %>
<%= f.label :mobile_1, class: "form-label small text-muted" %> <%= f.text_field :mobile_1, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :mobile_2, class: "form-label small text-muted" %> <%= f.text_field :mobile_2, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :email, class: "form-label small text-muted" %> <%= f.email_field :email, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :address_1, class: "form-label small text-muted" %> <%= f.text_field :address_1, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :address_2, class: "form-label small text-muted" %> <%= f.text_field :address_2, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :city, class: "form-label small text-muted" %> <%= f.text_field :city, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :country, class: "form-label small text-muted" %> <%= f.text_field :country, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :source_of_funds, class: "form-label small text-muted" %> <%= f.text_area :source_of_funds, rows: 3, class: "form-control form-control-sm rounded-3" %>
Employment Details
<%= f.label :employment_type, class: "form-label small text-muted" %> <%= f.select :employment_type, [["Permanent", "Full-time"], ["Temporary", "Part-time"], ["Self Employed", "Self-employed"]], { include_blank: true }, class: "form-select form-select-sm rounded-pill" %>
<%= f.label :employer_name, class: "form-label small text-muted" %> <%= f.text_field :employer_name, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :salary, class: "form-label small text-muted" %> <%= f.number_field :salary, step: 0.01, class: "form-control form-control-sm rounded-pill" %>
<%= f.label :referral, class: "form-label small text-muted" %> <%= f.text_field :referral, class: "form-control form-control-sm rounded-pill" %>
Next of Kin
<%= f.fields_for :next_of_kins do |n| %> <%= render "agent_portal/customers/next_of_kin_fields", f: n %> <% end %>
Representatives / Guardians
<%= f.fields_for :representatives do |r| %> <%= render "agent_portal/customers/representative_fields", f: r %> <% end %>
<%= link_to "➕ Add Representative", "#", class: "btn btn-outline-primary btn-sm rounded-pill mt-3", data: { action: "click->representatives#add" } %>
Customer Documents
<% if @customer.documents.any? { |d| d.file.attached? } %> Complete <% else %> Pending <% end %>
<%= f.fields_for :documents do |d| %> <%= render "agent_portal/customers/document_fields", f: d, required_docs: @mandatory_customer_docs, controller_name: "documents" %> <% end %>
<%= link_to "➕ Add Document", "#", class: "btn btn-outline-primary btn-sm rounded-pill mt-3", data: { action: "click->documents#add" } %>
<%= f.submit "Save Customer", data: { turbo: false }, class: "btn btn-success rounded-pill px-4" %> <%= link_to "Cancel", agent_portal_customers_path, class: "btn btn-outline-secondary rounded-pill px-4" %>
<% end %>