@extends('layout.app')

@section('content')
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card shadow-sm">
                    <div class="card-header bg-white py-3">
                        <h4 class="card-title m-0 font-weight-bold text-primary">Create New Line Request</h4>
                    </div>
                    <div class="card-body">
                        @if ($errors->any())
                            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                <strong>Please fix the following errors:</strong>
                                <ul class="mb-0 mt-2">
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                        @endif

                        <form action="{{ route('newline.newStore') }}" method="POST">
                            @csrf
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="mobile">Mobile Number<span class="text-danger">*</span></label>
                                        <input type="text" name="mobile" id="mobile" class="form-control @error('mobile') is-invalid @enderror"
                                            placeholder="Enter Mobile Number" value="{{ old('mobile') }}" required>
                                        @error('mobile')
                                            <span class="invalid-feedback" role="alert">{{ $message }}</span>
                                        @enderror
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="address">Source List<span class="text-danger">*</span></label>
                                        <select name="source_id" id="source_id" class="form-control select2 @error('source_id') is-invalid @enderror" required>
                                            <option value="">Select Source List</option>
                                            @foreach ($client_source as $sourceList)
                                                <option value="{{ $sourceList->id }}" {{ old('source_id') == $sourceList->id ? 'selected' : '' }}>{{ $sourceList->name }}</option>
                                            @endforeach
                                        </select>
                                        @error('source_id')
                                            <span class="invalid-feedback" role="alert">{{ $message }}</span>
                                        @enderror
                                    </div>
                                </div>
                                <div class="col-md-12 text-right">
                                    <button type="submit" class="btn btn-primary">Create New Line Request</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection


@push('js')
@endpush
