class Settings::CashierTerminalsController < ApplicationController
  load_and_authorize_resource except: [:create]
  before_action :set_settings_cashier_terminal, only: [:show, :edit, :update, :destroy]

  # GET /settings/cashier_terminals
  # GET /settings/cashier_terminals.json
  def index
    @settings_cashier_terminals = CashierTerminal.all
  end

  # GET /settings/cashier_terminals/1
  # GET /settings/cashier_terminals/1.json
  def show
  end

  # GET /settings/cashier_terminals/new
  def new
    @settings_cashier_terminal = CashierTerminal.new
  end

  # GET /settings/cashier_terminals/1/edit
  def edit
  end

  # POST /settings/cashier_terminals
  # POST /settings/cashier_terminals.json
  def create
    @settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params)

    respond_to do |format|
      if @settings_cashier_terminal.save
        format.html { redirect_to settings_cashier_terminals_path, notice: 'Cashier terminal was successfully created.' }
        format.json { render :show, status: :created, location: @settings_cashier_terminal }
      else
        format.html { render :new }
        format.json { render json: @settings_cashier_terminal.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /settings/cashier_terminals/1
  # PATCH/PUT /settings/cashier_terminals/1.json
  def update
    respond_to do |format|
      if @settings_cashier_terminal.update(settings_cashier_terminal_params)
        format.html { redirect_to settings_cashier_terminal_path(@settings_cashier_terminal), notice: 'Cashier terminal was successfully updated.' }
        format.json { render :show, status: :ok, location: @settings_cashier_terminal }
      else
        format.html { render :edit }
        format.json { render json: @settings_cashier_terminal.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /settings/cashier_terminals/1
  # DELETE /settings/cashier_terminals/1.json
  def destroy
    @settings_cashier_terminal.destroy
    respond_to do |format|
      format.html { redirect_to settings_cashier_terminals_path, notice: 'Cashier terminal was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_settings_cashier_terminal
      @settings_cashier_terminal = CashierTerminal.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def settings_cashier_terminal_params
      params.require(:cashier_terminal).permit(:name, :is_active, :is_currently_login, :auto_print_receipt, :printer_name, :header, :footer, :font, :font_size, :show_tax, :show_cashier, :show_guest_info)
    end
end
