Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

9.4 KB
Raw Blame
<div>
  <%= render NeoTitleBoxComponent.new(
    title: t('views.devise.registrations.edit.title'),
    variant: :project
  ) %>

  <%# Contextual help — this is where people land when the confirmation banner
      confuses them or the e-mail change does not seem to take effect. %>
  <div class="flex justify-end mb-4">
    <%= render 'common/contextual_help_menu', context: :account %>
  </div>

  <%# ── Group 1: Profile data (warm flat panel, S0 multi-group → section heading) ── %>
  <div class="mt-8 max-w-2xl">
    <h3 class="text-lg font-semibold text-cream-900 dark:text-white pb-3 border-b border-cream-200">
      <i class="bi bi-person-fill mr-2"></i>
      <%= t('views.devise.registrations.edit.profile_section') %>
    </h3>

    <div class="pt-6">
      <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "space-y-6", data: { turbo: false } }) do |f| %>
        <%= render "devise/shared/error_messages", resource: resource %>

        <!-- Name -->
        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
          <div>
            <%= f.label :first_name, t('views.devise.registrations.edit.first_name'), class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
            <%= f.text_field :first_name, autocomplete: "given-name",
                class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
          </div>
          <div>
            <%= f.label :last_name, t('views.devise.registrations.edit.last_name'), class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
            <%= f.text_field :last_name, autocomplete: "family-name",
                class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
          </div>
        </div>

        <%# The profile picture moved to Settings > Profil
            (user_preferences/display): it belongs next to the name-display
            choice, and this Devise form demands the current password for
            every change - unreasonable for a picture (04.09.2026). %>

        <!-- Email -->
        <div>
          <%= f.label :email, class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
          <%= f.email_field :email, autocomplete: "email",
              class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
          <%# Said BEFORE the change, not only after (the pending_confirmation
              box below): with reconfirmable the address does not switch on
              save, which reads as a bug if nobody announced it. %>
          <% if devise_mapping.confirmable? %>
            <small class="mt-2 block text-xs text-cream-700 dark:text-gray-300 leading-snug">
              <%= t('views.devise.registrations.edit.email_change_hint') %>
            </small>
          <% end %>
          <%# Devise re-renders an unsaved resource after a rejected update.
              The hint must describe the saved user, not the submitted address. %>
          <small class="mt-1 block break-words text-xs text-cream-700 dark:text-gray-300 leading-snug" data-shown-email-hint>
            <%= t("views.devise.registrations.edit.shown_email.#{current_user.email_visibility}", email: current_user.shown_email) %>
            <%= link_to t('views.devise.registrations.edit.shown_email.change'), display_user_preferences_path, class: 'underline' %>
          </small>
        </div>

        <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
          <div class="p-4 bg-cream-100 dark:bg-yellow-900/20 border border-cream-300 rounded">
            <p class="text-sm font-medium text-cream-800 dark:text-yellow-200">
              <%= t('views.devise.registrations.edit.pending_confirmation', email: resource.unconfirmed_email) %>
            </p>
          </div>
        <% end %>

        <!-- Current password -->
        <div>
          <%= f.label :current_password, t('views.devise.registrations.edit.current_password'),
              class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
          <%= f.password_field :current_password, autocomplete: "current-password",
              class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
          <p class="text-xs text-cream-600 dark:text-gray-400 mt-2">
            (<%= t('views.devise.registrations.edit.current_password_hint') %>)
          </p>
        </div>

        <!-- Actions -->
        <div class="flex justify-end gap-3 pt-4">
          <%# P4: ButtonComponent instead of hand-built. Dirty-disabling removed (P9/AP4, decision 8/12 — the shared
              user-preferences controller had long since removed submitButton/formChanged, this view was forgotten in
              the sweep → buttons were permanently disabled). Decorative checkmark removed (AP2/P3). %>
          <%= render Neo::Buttons::ButtonComponent.new(
            variant: :primary,
            size: :large,
            tag: :button,
            type: 'submit'
          ) do %>
            <%= t('views.devise.registrations.edit.save_profile') %>
          <% end %>
        </div>
      <% end %>
    </div>
  </div>

  <%# ── Group 2: Change password (warm flat panel, S0 multi-group → section heading) ── %>
  <div class="mt-10 max-w-2xl">
    <h3 class="text-lg font-semibold text-cream-900 dark:text-white pb-3 border-b border-cream-200">
      <i class="bi bi-shield-lock mr-2"></i>
      <%= t('views.devise.registrations.edit.password_section') %>
    </h3>

    <div class="pt-6">
      <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "space-y-6", data: { turbo: false } }) do |f| %>
        <!-- New password -->
        <div>
          <%= f.label :password, t('views.devise.registrations.edit.new_password'), class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
          <%= f.password_field :password, autocomplete: "new-password",
              class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
          <p class="text-xs text-cream-600 dark:text-gray-400 mt-2">
            (<%= t('views.devise.registrations.edit.leave_blank_password') %>)
          </p>
        </div>

        <!-- Password confirmation -->
        <div>
          <%= f.label :password_confirmation, t('views.devise.registrations.edit.confirm_new_password'),
              class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
          <%= f.password_field :password_confirmation, autocomplete: "new-password",
              class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
        </div>

        <!-- Current password -->
        <div>
          <%= f.label :current_password, t('views.devise.registrations.edit.current_password'),
              class: "block text-sm font-bold mb-2 text-cream-900 dark:text-white" %>
          <%= f.password_field :current_password, autocomplete: "current-password",
              class: "w-full h-10 px-4 rounded border border-cream-300 focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink transition-all bg-white dark:bg-gray-500 dark:text-white" %>
          <p class="text-xs text-cream-600 dark:text-gray-400 mt-2">
            (<%= t('views.devise.registrations.edit.current_password_hint') %>)
          </p>
        </div>

        <!-- Actions -->
        <div class="flex justify-end gap-3 pt-4">
          <%= render Neo::Buttons::ButtonComponent.new(
            variant: :primary,
            size: :large,
            tag: :button,
            type: 'submit'
          ) do %>
            <%= t('views.devise.registrations.edit.save_password') %>
          <% end %>
        </div>
      <% end %>
    </div>
  </div>

  <%# ── Card 3: Delete account (S3 danger zone = only emphasis card, red accent) ── %>
  <div class="mt-10 max-w-2xl border border-red-300 dark:border-red-700 rounded bg-cream-50 dark:bg-gray-600">
    <div class="border-b border-red-300 dark:border-red-700 bg-red-50 dark:bg-red-900/20 px-6 py-4">
      <h3 class="text-lg font-semibold text-red-800 dark:text-red-300">
        <i class="bi bi-exclamation-triangle mr-2"></i>
        <%= t('views.devise.registrations.edit.danger_zone') %>
      </h3>
    </div>

    <div class="p-6">
      <p class="text-sm text-cream-600 dark:text-gray-400 mb-4">
        <%= t('views.devise.registrations.edit.delete_warning') %>
      </p>
      <%# P8/C4: irreversible deletion → danger_zone variant (inverts on hover, white text on red).
          Trash icon per role convention (delete 🗑, decision 9). %>
      <%= render Neo::Buttons::ButtonComponent.new(
        variant: :danger_zone,
        size: :large,
        icon: "trash3",
        url: new_account_deletion_path
      ) do %>
        <%= t('views.devise.registrations.edit.delete_account') %>
      <% end %>
    </div>
  </div>
</div>