# frozen_string_literal: true

module Production
  module Runs
    module ProductionRun
      class EnterBinTippingGrossWeight
        def self.call(bin_number, device, form_values: nil, form_errors: nil)
          ui_rule = UiRules::Compiler.new(:tip_bin, :enter_gross_weight, form_values: form_values)
          rules   = ui_rule.compile

          Crossbeams::Layout::Page.build(rules) do |page|
            page.form_object ui_rule.form_object
            page.form_values form_values
            page.form_errors form_errors
            page.form do |form|
              form.caption 'Scan Gross Weight'
              form.action "/production/runs/tip_bin_submit/#{bin_number}/#{device}"
              form.row do |row|
                row.column do |col|
                  col.add_field :production_line_label
                  col.add_field :production_line_id
                  col.add_field :bin_asset_number
                  col.add_field :gross_weight
                end
                row.blank_column
              end
            end
          end
        end
      end
    end
  end
end
