@extends('layouts.user')
@section('title', __('customers.edit_adjust'))

@section('content')
<div class="max-w-3xl mx-auto border border-slate-200 bg-white p-4 shadow-sm text-[13px]">
  <div class="flex items-center justify-between border-b border-slate-200 pb-3">
    <div>
      <div class="text-base font-bold text-slate-800">{{ __('customers.edit_adjust') }}</div>
      <div class="mt-0.5 text-[11px] text-slate-500">{{ $customer->name }}</div>
    </div>
    <a class="border border-slate-300 px-3 py-1.5 text-[12px] text-slate-700 hover:bg-slate-50"
       href="{{ route('user.customers.ledger.index', $customer) }}">{{ __('customers.back') }}</a>
  </div>

  @if($errors->any())
    <div class="mt-4 border border-rose-200 bg-rose-50 p-3 text-[12px] text-rose-700">
      <ul class="ml-4 list-disc space-y-0.5">
        @foreach($errors->all() as $e)
          <li>{{ $e }}</li>
        @endforeach
      </ul>
    </div>
  @endif

  <form class="mt-4 grid gap-3" method="POST" action="{{ route('user.customers.ledger.update', [$customer, $trx]) }}">
    @csrf
    @method('PUT')

    <div>
      <label class="text-[11px] font-semibold text-slate-600">{{ __('customers.type') }}</label>
      <input class="mt-1 w-full border border-slate-300 bg-slate-50 px-3 py-2 text-[12px]"
             value="{{ __('customers.adjust') }}"
             disabled>
    </div>

    <div class="grid gap-3 md:grid-cols-2">
      <div>
        <label class="text-[11px] font-semibold text-slate-600">{{ __('customers.debit') }}</label>
        <input type="number"
               step="any"
               class="mt-1 w-full border border-slate-300 px-3 py-2 text-[12px]"
               name="debit"
               value="{{ old('debit', $trx->debit) }}">
      </div>

      <div>
        <label class="text-[11px] font-semibold text-slate-600">{{ __('customers.credit') }}</label>
        <input type="number"
               step="any"
               class="mt-1 w-full border border-slate-300 px-3 py-2 text-[12px]"
               name="credit"
               value="{{ old('credit', $trx->credit) }}">
      </div>
    </div>

    <div>
      <label class="text-[11px] font-semibold text-slate-600">{{ __('customers.posted_at') }}</label>
      <input type="datetime-local"
             class="mt-1 w-full border border-slate-300 px-3 py-2 text-[12px]"
             name="posted_at"
             value="{{ old('posted_at', optional($trx->posted_at)->format('Y-m-d\TH:i')) }}">
    </div>

    <div>
      <label class="text-[11px] font-semibold text-slate-600">{{ __('customers.note') }}</label>
      <textarea class="mt-1 w-full border border-slate-300 px-3 py-2 text-[12px]"
                name="note"
                rows="3"
                placeholder="{{ __('customers.write_note_about_adjust') }}">{{ old('note', $trx->note) }}</textarea>
    </div>

    <div class="border-t border-slate-200 pt-3">
      <button class="mt-1 bg-slate-900 px-4 py-2 text-[12px] font-medium text-white hover:bg-slate-800">
        {{ __('customers.update_adjust') }}
      </button>
    </div>
  </form>
</div>
@endsection