@extends('layouts.app')

@section('content')
<div class="container mt-5">
    <h2>{{ isset($client) ? 'Edit client' : 'Create client' }}</h2>
    @include('commons.notifications')
    <form action="{{ isset($client) ? route('admin.clientupdate', $client->id) : route('admin.clientstore') }}" method="POST">
        <input type="hidden" name="user_id" value="{{ \Auth::user()->id }}">

        @csrf
        @if (isset($client))
            @method('PUT')
        @endif
        <div class="mb-3">
            <label for="name" class="form-label">Client Name</label>
            <input type="text" class="form-control" id="name" name="name" value="{{ $client->name ?? '' }}" required>
        </div>

        <div class="mb-3">
            <label for="description" class="form-label">Email</label>
            <input type="email" class="form-control" id="email" name="email" value="{{ $client->email ?? '' }}" required>
        </div>

        <div class="mb-3">
            <label for="phone" class="form-label">Phone</label>
            <input type="text" class="form-control" id="phone" name="phoneNumber" value="{{ $client->phone ?? '' }}" placeholder="e.g. 263 45 903 900" required>
        </div>
        <div class="mb-3">
            <label for="dependancy" class="form-label">Country</label>
            <input type="text" class="form-control" id="country" name="country" value="{{ $client->country ?? '' }}" placeholder="enter location" required>
        </div>
        @if(isset($client))
        <div class="mb-3">
            <label for="status" class="form-label">Status</label>
            <select class="form-select" id="status" name="status" required>
                <option value="" disabled selected>Select Status</option>
                <option value="Active" {{ (isset($client) && $client->status == 'active') ? 'selected' : '' }}>Active</option>
                <option value="inactive" {{ (isset($client) && $client->status == 'inactive') ? 'selected' : '' }}>Inactive</option>
            </select>
        </div>
        @endif

        <button type="submit" class="btn btn-primary">{{ isset($client) ? 'Update client' : 'Create client' }}</button>
    </form>
</div>

@endsection