<div class="row py-5">
  <div class="col-12 col-lg-10 col-xl-8 mx-auto form-container">
    <div class="card">
      <div class="card-body">
        <h5 class="card-title"><i class="fas fa-edit"></i> Edit {{type}}</h5>
        <hr>

        <form class="row g-3" action="/records/{{ record.id }}?_method=PUT" method="POST">
          {{!-- Ledger (display only) --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label class="col-md-4 col-form-label">Ledger</label>
            <div class="col-md-8 d-flex align-items-center">
              <span class="badge {{#if (eq record.ledger 'Business')}}badge-primary{{else}}badge-info{{/if}}" style="font-size: 0.9rem;">
                {{ record.ledger }}
              </span>
              <input type="hidden" name="ledger" value="{{ record.ledger }}">
            </div>
          </div>
          {{!-- Name --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="name" class="col-md-4 col-form-label">Name<span class="field-required">*</span> </label>
            <input type="text" name="name" class="form-control col-md-8" id="name" value="{{ record.name }}" required
              maxlength="15">
          </div>
          {{!-- Date --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="date" class="col-md-4 col-form-label">Date<span class="field-required">*</span></label>
            <input type="date" name="date" class="form-control col-md-8" id="date" value="{{ record.date }}" required>
          </div>
          {{!-- Category --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="category" class="col-md-4 col-form-label">Category<span class="field-required">*</span></label>
            <select class="custom-select col-md-8" name="categoryId">

              {{#each categoryList}}
              <option value="{{ this.id }}" {{#if (eq ../record.category_name this.name)}}selected{{/if}}>{{
                this.name }}</option>
              {{/each}}

            </select>
          </div>
          {{!-- Merchant --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="merchant" class="col-md-4 col-form-label">Merchant</label>
            <input type="text" name="merchant" class="form-control col-md-8" id="merchant"
              value="{{ record.merchant }}">
          </div>
          {{!-- Amount --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="amount" class="col-md-4 col-form-label">Amount<span class="field-required">*</span></label>
            <input type="number" name="amount" class="form-control col-md-8" id="amount" value="{{ record.amount }}"
              required min="1" max="999999">
          </div>
          {{!-- Must Pay --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="mustPay" class="col-md-4 col-form-label">Non-negotiable</label>
            <div class="col-md-8 d-flex align-items-center">
              <input type="checkbox" name="mustPay" class="form-check-input" id="mustPay" style="width: 20px; height: 20px;" {{#if record.must_pay}}checked{{/if}}>
              <label class="form-check-label ml-2" for="mustPay">Must-pay (rent, food, statutory)</label>
            </div>
          </div>
          {{!-- Recurring --}}
          <div class="col-md-12 row mb-3 ml-1 mr-4">
            <label for="recurring" class="col-md-4 col-form-label">Recurring</label>
            <div class="col-md-8 d-flex align-items-center">
              <input type="checkbox" name="recurring" class="form-check-input" id="recurring" style="width: 20px; height: 20px;" {{#if record.recurring}}checked{{/if}}>
              <label class="form-check-label ml-2" for="recurring">Monthly recurring</label>
            </div>
          </div>
          {{!-- type --}}
          <input type="text" name="type" class="form-control col-md-8" value="{{type}}" style="display: none;">
          {{!-- Button --}}
          <div class="col-md-12 d-flex justify-content-end mr-4">
            <button class="btn btn-success" type="submit">Save</button>
          </div>
        </form>

      </div>
    </div>
  </div>
</div>