Sha256: ff8ad6439ce817896a1702a187fe9325d9389a6644717bbe408c66c58d45f26a

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Maquina
  module AcceptInvitations
    class NewView < Phlex::HTML
      include Maquina::ApplicationView
      include Phlex::Rails::Helpers::FormWith
      include Phlex::Rails::Helpers::HiddenField
      include Phlex::Rails::Helpers::Routes

      def initialize(resource:)
        @resource = resource
      end

      def view_template
        div(class: "mt-8 sm:mx-auto sm:w-full sm:max-w-md") do
          div(class: "bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10") do
            @resource.new_record? ? invalid_invitation : build_form
          end
        end
      end

      private

      def invalid_invitation
        p(class: "text-center text-skin-muted") { t("maquina.accept_invitations.new.expired") }
      end

      def build_form
        form_with(model: @resource, url: accept_invitations_path, method: :patch, local: true, class: "space-y-6", data: {"turbo-frame": "_top"}) do |form|
          form.hidden_field :invitation_token
          div(class: "field") do
            div(class: "control") do
              form.submit t("form.accept_invitations.submit"), class: "button button-accented w-full"
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
maquina-0.7.2 app/views/maquina/accept_invitations/new_view.rb
maquina-0.7.1 app/views/maquina/accept_invitations/new_view.rb
maquina-0.5.2 app/views/maquina/accept_invitations/new_view.rb
maquina-0.5.1 app/views/maquina/accept_invitations/new_view.rb