<%= @family.name %>

<%= t('families.show.created_by', default: 'Created by') %> <%= @family.creator.email %> <%= t('families.show.on_date', default: 'on') %> <%= @family.created_at.strftime('%B %d, %Y') %>

<% if policy(@family).update? %> <%= link_to edit_family_path, class: "btn btn-outline btn-info" do %> <%= icon 'square-pen', class: "inline-block w-4" %><%= t('families.show.edit', default: 'Edit') %> <% end %> <% end %> <% if !current_user.family_owner? && current_user.family_membership %> <%= link_to family_member_path(current_user.family_membership), method: :delete, data: { turbo_confirm: 'Are you sure you want to leave this family?' }, class: "btn btn-outline btm-sm btn-warning" do %> Leave Family <% end %> <% end %> <% if policy(@family).destroy? %> <%= link_to family_path, method: :delete, data: { turbo_confirm: 'Are you sure you want to delete this family? This action cannot be undone.' }, class: "btn btn-outline btm-sm btn-error" do %> <%= icon 'trash-2', class: "inline-block w-4" %> Delete <% end %> <% end %>

<%= t('families.show.members_title', default: 'Family Members') %> (<%= @members.count %>)

<% @members.each do |member| %>
<%= member.email&.first&.upcase || '?' %>

<%= member.email %>

<% if member.family_membership.role == 'owner' %>
<%= t('families.show.owner_badge', default: 'Owner') %>
<% else %> <%= member.family_membership.role.humanize %> <% end %>
<%= t('families.show.joined_on', default: 'Joined') %> <%= member.family_membership.created_at.strftime('%b %d, %Y') %>
<% if member == current_user %>
Location sharing: data-location-sharing-toggle-target="checkbox" data-action="change->location-sharing-toggle#toggle">
<% if member.family_sharing_enabled? && member.family_sharing_expires_at.present? %>
• Expires <%= time_ago_in_words(member.family_sharing_expires_at) %> from now
<% end %>
<% else %>
Location sharing: <% if member.family_sharing_enabled? %>
<%= member.family_sharing_duration == 'permanent' ? 'Always' : member.family_sharing_duration&.upcase %> <% if member.family_sharing_expires_at.present? %> • Expires <%= time_ago_in_words(member.family_sharing_expires_at) %> from now <% end %> <% else %>
Disabled <% end %>
<% end %>
<% end %>

<%= t('families.show.invitations_title', default: 'Pending Invitations') %> (<%= @pending_invitations.count %>)

<% if @pending_invitations.any? %>
<% @pending_invitations.each do |invitation| %>
<%= invitation.email %>
<%= t('families.show.invited_on', default: 'Invited') %> <%= invitation.created_at.strftime('%b %d, %Y') %>
<%= t('families.show.expires_on', default: 'Expires') %> <%= invitation.expires_at.strftime('%b %d, %Y at %I:%M %p') %>
<% if policy(@family).manage_invitations? %>
<%= link_to family_invitation_path(invitation.token), method: :delete, data: { turbo_confirm: 'Are you sure you want to cancel this invitation?' }, class: "btn btn-outline btn-warning btn-sm" do %> Cancel <% end %>
<% end %>
<% end %>
<% else %>

<%= t('families.show.no_pending_invitations', default: 'No pending invitations') %>

<% end %> <% if policy(@family).invite? && @family.can_add_members? %>

<%= t('families.show.invite_member', default: 'Invite New Member') %>

<%= form_with model: [@family, Family::Invitation.new], url: family_invitations_path(@family), local: true, class: "space-y-3" do |form| %>
<%= form.label :email, t('families.show.email_label', default: 'Email Address'), class: "label label-text font-medium mb-1" %> <%= form.email_field :email, placeholder: t('families.show.email_placeholder', default: 'Enter email address'), class: "input input-bordered w-full" %>
<%= form.submit t('families.show.send_invitation', default: 'Send Invitation'), class: "btn btn-primary" %>
<% end %>
<% elsif policy(@family).invite? %>
<%= icon 'triangle-alert', class: "inline-block w-6 mr-2 flex-shrink-0" %>

Family at Capacity

Your family has reached the maximum of <%= @family.class::MAX_MEMBERS %> members (including pending invitations). Cancel existing invitations or wait for them to expire to invite new members.

<% end %>