require "rqrcode"

class QrCodeModalComponent < ViewComponent::Base
  def initialize(qr_content:, description: nil)
    @description = description
    @qr_code_svg = qr_code_svg(qr_content)
  end

  private

  def qr_code_svg(content)
    qr_code = RQRCode::QRCode.new(content)
    qr_code.as_svg(
      color: "000",
      shape_rendering: "crispEdges",
      module_size: 6,
      standalone: true,
      use_path: true,
      svg_attributes: {
        class: 'inline-block'
      }
    )
  end
end
