@extends('layouts.app')

@php
  /** @var \App\Models\TeleRecord|null $record */
  $r = $record ?? null;
  $action = $r ? route('tele.records.update', $r) : route('tele.records.store');
@endphp

@section('content')
  <div class="flex items-center justify-between mb-6">
    <h1 class="text-2xl font-bold tracking-tight">{{ $r ? 'Edit Record' : 'New Record' }}</h1>
    <a href="{{ route('tele.records.index') }}" class="px-3 py-2 rounded-lg border text-sm hover:bg-ink-50">Back</a>
  </div>

  <form method="POST" action="{{ $action }}" enctype="multipart/form-data"
        class="bg-white rounded-2xl p-6 shadow-card border space-y-4">
    @csrf
    @if($r) @method('PUT') @endif

    @include('telecalling.records.form', ['record' => $r, 'outlets' => $outlets])

    <div class="pt-2 flex items-center gap-2">
      <button class="px-4 py-2 rounded-xl bg-brand-500 hover:bg-brand-600 text-white">
        {{ $r ? 'Update' : 'Save' }}
      </button>
      <a href="{{ route('tele.records.index') }}" class="px-4 py-2 rounded-xl border hover:bg-ink-50">Cancel</a>
    </div>
  </form>
@endsection
