Worker Details

Name <%= @worker.first_name %> <%= @worker.last_name %>
Address <%= [@worker.address_line_1, @worker.address_line_2, @worker.city, @worker.state, @worker.zip].reject(&:blank?).join(', ') %>
Phone <%= @worker.phone %>
Email <%= @worker.email %>
DOB <%= @worker.dob %>
SSN <%= mask_ssn (@worker.ssn) %>
Gender <%= @worker.gender %>
<%= link_to 'Edit', edit_worker_path(@worker), class: "btn btn-dark" %> <%= link_to 'Back to List', workers_path, class: "btn btn-secondary" %>

Linked Participants

<% if @employments.present? %> <% @employments.each do |employment| %> <% participant = employment.participant %> <% end %>
Participant Name Start Date End Date Actions
<%= participant ? "#{participant.first_name} #{participant.last_name}" : 'No Participant Assigned' %> <%= employment.start_date.strftime('%B %d, %Y') if employment.start_date.present? %> <%= employment.end_date.strftime('%B %d, %Y') if employment.end_date.present? %> <%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %> <% end %> <%= link_to edit_employment_path(employment), class: 'btn btn-sm btn-info' do %> <% end %>
<% else %>

No employments available.

<% end %>
<%= form_with(model: [@worker, @employment], url: link_participant_worker_path(@worker), method: :post, class: 'row g-3') do |form| %>
<%= form.label :participant_name, "Add New Participant", class: 'form-label' %> <%= text_field_tag :participant_name, nil, id: 'participant-autocomplete', class: 'form-control', placeholder: 'Start typing participant name...' %> <%= hidden_field_tag 'employment[participant_id]', nil, id: 'selected-participant-id' %>
<%= form.label :start_date, class: 'form-label' %> <%= form.date_field :start_date, class: 'form-control' %>
<%= form.label :end_date, class: 'form-label' %> <%= form.date_field :end_date, class: 'form-control' %>
<%= form.submit "Link Participant", class: 'btn btn-dark' %>
<% end %>

Linked Employers

<% if @worker.participants.any? %> <% @worker.participants.each do |participant| %> <% participant.employer_records.each do |employer_record| %> <% end %> <% end %>
Employer Name Start Date End Date Actions
<%= employer_record.employer.full_name %> <%= employer_record.start_date.strftime('%B %d, %Y') if employer_record.start_date %> <%= employer_record.end_date.strftime('%B %d, %Y') if employer_record.end_date %> <%= link_to 'View', employer_path(employer_record.employer), class: 'btn btn-sm btn-secondary' %> <%= link_to 'Edit', edit_employer_record_path(employer_record), class: 'btn btn-sm btn-info' %>
<% else %>

No linked employers.

<% end %>
<%# JavaScript for Participant Autocomplete %>