diff --git a/app/components/form_elements/fieldset_component.html.erb b/app/components/form_elements/fieldset_component.html.erb
index 143da70..dce6ccb 100644
--- a/app/components/form_elements/fieldset_component.html.erb
+++ b/app/components/form_elements/fieldset_component.html.erb
@@ -12,7 +12,7 @@
<% end %>
- <%= tag.p class: "flex gap-x-1", data: {
+ <%= tag.div class: "flex gap-x-1", data: {
controller: @resettable ? "settings--resettable-field" : nil,
} do %>
<%= content %>
diff --git a/app/components/settings/nostr_edit_profile_component.html.erb b/app/components/settings/nostr_edit_profile_component.html.erb
index cb7472e..5862434 100644
--- a/app/components/settings/nostr_edit_profile_component.html.erb
+++ b/app/components/settings/nostr_edit_profile_component.html.erb
@@ -24,13 +24,125 @@
<% end %>
<% end %>
<%= render FormElements::FieldsetComponent.new(tag: "div", title: "Nostr address (NIP-05)") do %>
- <%= f.text_field :nip05_address, value: @profile["nip05"], class: "w-full sm:w-3/5" %>
+ <% if @nip05_state[:status] == :added %>
+
+
+ <%= f.text_field :nip05_address, value: @nip05_state[:value],
+ data: {
+ :'field-suggestion-target' => "input",
+ action: "input->field-suggestion#checkAdded"
+ },
+ class: "w-full pr-16 border-emerald-500 ring-1 ring-emerald-500 focus:border-emerald-500 focus:ring-emerald-500 bg-emerald-50/20" %>
+
+
+ added
+
+
+
+
+ Account address: <%= @user.address %>
+
+
+
+ <% elsif @nip05_state[:status] == :different %>
+
+
+ <%= f.text_field :nip05_address, value: @nip05_state[:value],
+ data: {
+ :'field-suggestion-target' => "input",
+ action: "input->field-suggestion#checkAdded"
+ },
+ class: "w-full pr-20 border-amber-400 ring-1 ring-amber-400 focus:border-amber-400 focus:ring-amber-400" %>
+
+
+ different
+
+
+
+
+ Account address: <%= @nip05_state[:suggested] %>
+
+
+
+ <% else %>
+ <%= f.text_field :nip05_address, value: @nip05_state[:value], class: "w-full sm:w-3/5" %>
+ <% end %>
<% if @validation_errors.present? && @validation_errors[:nip05_address].present? %>
<%= @validation_errors[:nip05_address].first %>
<% end %>
<% end %>
- <%= render FormElements::FieldsetComponent.new(tag: "div", title: "Ligtning address for Zaps") do %>
- <%= f.text_field :lud16_address, value: @profile["lud16"], class: "w-full sm:w-3/5" %>
+ <%= render FormElements::FieldsetComponent.new(tag: "div", title: "Lightning address for Zaps") do %>
+ <% if @lud16_state[:status] == :added %>
+
+
+ <%= f.text_field :lud16_address, value: @lud16_state[:value],
+ data: {
+ :'field-suggestion-target' => "input",
+ action: "input->field-suggestion#checkAdded"
+ },
+ class: "w-full pr-16 border-emerald-500 ring-1 ring-emerald-500 focus:border-emerald-500 focus:ring-emerald-500 bg-emerald-50/20" %>
+
+
+ added
+
+
+
+
+ Account address: <%= @user.address %>
+
+
+
+ <% elsif @lud16_state[:status] == :different %>
+
+
+ <%= f.text_field :lud16_address, value: @lud16_state[:value],
+ data: {
+ :'field-suggestion-target' => "input",
+ action: "input->field-suggestion#checkAdded"
+ },
+ class: "w-full pr-20 border-amber-400 ring-1 ring-amber-400 focus:border-amber-400 focus:ring-amber-400" %>
+
+
+ different
+
+
+
+
+ Account address: <%= @lud16_state[:suggested] %>
+
+
+
+ <% else %>
+ <%= f.text_field :lud16_address, value: @lud16_state[:value], class: "w-full sm:w-3/5" %>
+ <% end %>
<% if @validation_errors.present? && @validation_errors[:lud16_address].present? %>
<%= @validation_errors[:lud16_address].first %>
<% end %>
diff --git a/app/components/settings/nostr_edit_profile_component.rb b/app/components/settings/nostr_edit_profile_component.rb
index edf040f..d905896 100644
--- a/app/components/settings/nostr_edit_profile_component.rb
+++ b/app/components/settings/nostr_edit_profile_component.rb
@@ -2,9 +2,12 @@
module Settings
class NostrEditProfileComponent < ViewComponent::Base
- def initialize(user:, profile_event:)
+ attr_reader :user, :profile, :profile_event, :display_name, :nip05_state, :lud16_state
+
+ def initialize(user:, profile_event: nil, validation_errors: nil)
@user = user
@profile_event = profile_event
+ @validation_errors = validation_errors
@profile = {}
@display_name = nil
@@ -12,6 +15,25 @@ module Settings
@profile = JSON.parse(profile_event["content"]) rescue {}
@display_name = @profile["display_name"] || @profile["displayName"]
end
+
+ @display_name ||= @user.display_name
+
+ @nip05_state = compute_field_state(@profile["nip05"])
+ @lud16_state = compute_field_state(@profile["lud16"])
+ end
+
+ private
+
+ def compute_field_state(current_value)
+ target_value = @user.address
+
+ if current_value.blank?
+ { status: :added, value: target_value, suggested: nil }
+ elsif current_value == target_value
+ { status: :matched, value: current_value, suggested: nil }
+ else
+ { status: :different, value: current_value, suggested: target_value }
+ end
end
end
end
diff --git a/app/components/settings/nostr_edit_relays_component.html.erb b/app/components/settings/nostr_edit_relays_component.html.erb
index 1cf6762..2f68143 100644
--- a/app/components/settings/nostr_edit_relays_component.html.erb
+++ b/app/components/settings/nostr_edit_relays_component.html.erb
@@ -5,8 +5,23 @@
<% @relays.each do |relay| %>
-
-
-