<div>
    <form method="POST" wire:submit.prevent="{{$id != null ? 'update' : 'add'}}">
        <div class="row mb-2">
            <div class="col-md-6">
                <div class="input-cont @error('company') is-invalid @enderror">
                    <label for="nameLarge" class="form-label">Company<span>*</span></label>
                    <select class="form-select form-control" wire:model.defer="company">
                        <option value="">Select</option>
                        @foreach($companies as $comp)
                            <option value="{{$comp->id}}">{{$comp->name}}</option>
                        @endforeach
                    </select>
                </div>
                @error('company')
                    <span class="invalid-feedback"><strong>{{$message}}</strong></span>
                @enderror
            </div>

            <div class="col-md-6">
                <div class="input-cont @error('title') is-invalid @enderror">
                    <label for="nameLarge" class="form-label">Title<span>*</span></label>
                    <input type="text" wire:model.defer="title" class="nameField form-control" placeholder="Enter Title" data-required maxlength="100"/>
                </div>
                @error('title')
                    <span class="invalid-feedback"><strong>{{$message}}</strong></span>
                @enderror
            </div>
        </div>
        <div class="row mb-2">
            <div class="col-md-6">
                <div class="input-cont @error('location') is-invalid @enderror">
                    <label for="nameLarge" class="form-label">Location<span>*</span></label>
                    <select class="form-select form-control" wire:model.defer="location">
                        <option value="">Select</option>
                        @foreach($countries as $country)
                            <option value="{{$country}}">{{$country}}</option>
                        @endforeach
                    </select>
                </div>
                @error('location')
                    <span class="invalid-feedback"><strong>{{$message}}</strong></span>
                @enderror
            </div>
            <div class="col-md-6">
                <div class="input-cont @error('type') is-invalid @enderror">
                    <label for="nameLarge" class="form-label">Type of Employment<span>*</span></label>
                    <select class="form-control form-select" wire:model.defer="type">
                        <option value="">Select</option>
                        @foreach(config()->get('constants.job_types') as $jobType)
                        <option value="{{$jobType}}">{{$jobType}}</option>
                        @endforeach
                    </select>
                </div>
                @error('type')
                    <span class="invalid-feedback"><strong>{{$message}}</strong></span>
                @enderror
            </div>
        </div>

        <div class="row mb-2">
            <div class="input-cont @error('description') is-invalid @enderror">
                <label for="nameLarge" class="form-label">Job Description<span>*</span></label>
                <textarea class="form-control" placeholder="Write Here" wire:model.defer="description">{{old('description')}}</textarea>
            </div>
            @error('description') 
                <span class="invalid-feedback"><strong>{{$message}}</strong></span> 
            @enderror
        </div>
        <div class="row mb-2">
            <div class="input-cont @error('roles') is-invalid @enderror">
                <label for="nameLarge" class="form-label">Roles and Responsibilities<span>*</span></label>
                <textarea class="form-control" placeholder="Write Here" wire:model.defer="roles">{{old('roles')}}</textarea>
            </div>
            @error('roles') 
                <span class="invalid-feedback"><strong>{{$message}}</strong></span> 
            @enderror
        </div>
        <div class="row mb-2">
            <div class="input-cont @error('how_to_apply') is-invalid @enderror">
                <label for="nameLarge" class="form-label">How to Apply<span>*</span></label>
                <textarea class="form-control" placeholder="Write Here" wire:model.defer="how_to_apply">{{old('how_to_apply')}}</textarea>
            </div>
            @error('how_to_apply') 
                <span class="invalid-feedback"><strong>{{$message}}</strong></span> 
            @enderror
        </div>
        <button type="submit" class="btn btn-primary post-btn my-3">{{$id != null ? 'Save Changes' : 'Post Job'}}</button>
    </form>
</div>
