@extends('user_type.auth', ['parentFolder' => 'web', 'childFolder' => ''])

@section('content')
<main class="main-content mt-1 border-radius-lg">
    <div class="container-fluid py-4">
        @if($errors->get('msgError'))
          <div class="m-3  alert alert-warning alert-dismissible fade show" role="alert">
            <span class="alert-text text-white">
              {{$errors->first()}}</span>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
              <i class="fa fa-close" aria-hidden="true"></i>
            </button>
          </div>
          @endif
          @if(session('success'))
          <div class="m-3  alert alert-success alert-dismissible fade show" id="alert-success" role="alert">
            <span class="alert-text text-white">
              {{ session('success') }}</span>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
              <i class="fa fa-close" aria-hidden="true"></i>
            </button>
          </div>
          @endif
        <div class="row">
            <div class="col-9 mx-auto">
                <div class="card card-body mt-4">
                    <h6 class="mb-0">New Campaign</h6>
                    <p class="text-sm mb-0">Create New Article Task</p>
                    <hr class="horizontal dark my-3">
                    <form action="/article/store" method="POST">
                        @csrf
                        <div>
                            <label for="categoryName" class="form-label">Title</label>
                            <div class="">
                                <input type="text" class="form-control " value="{{ old('title') }}"  placeholder="How to" name="title" onfocus="focused(this)" onfocusout="defocused(this)" required>
                                @error('name')
                                    <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                                @enderror
                            </div>
                        </div>

                        <hr class="horizontal dark my-2">
                        <label for="projectName" class="form-label"> Thumbnail URL</label>
                        <input type="text" class="form-control" name="thumb"  value="{{old('thumb')}}" placeholder="https://">
                        @error('thumb')
                            <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                        @enderror
             <hr class="horizontal dark my-2">
                        <div>
                            <label for="categoryName" class="form-label">Article Link</label>
                            <div class="">
                                <input type="text" class="form-control "  placeholder="http" name="url" onfocus="focused(this)" onfocusout="defocused(this)" required>
                                @error('name')
                                    <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                                @enderror
                            </div>
                        </div>

                        <div>
                            <label for="categoryName" class="form-label">Time in Second</label>
                            <div class="">
                                <input type="number" class="form-control " value="{{ old('timer') }}" placeholder="1" name="timer" onfocus="focused(this)" onfocusout="defocused(this)" required>
                                @error('name')
                                    <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                                @enderror
                            </div>
                        </div>

                        <div>
                            <label for="categoryName" class="form-label">Coin</label>
                            <div class="">
                                <input type="number" class="form-control " placeholder="5" name="point" onfocus="focused(this)" onfocusout="defocused(this)" required>
                                @error('name')
                                    <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                                @enderror
                            </div>
                        </div>

                        <div>
                            <label for="categoryName" class="form-label">Count of Users, who will Visit Website (Note: 0 = unlimited)</label>
                            <div class="">
                                <input type="number" class="form-control " value="0" placeholder="0" name="task_limit" onfocus="focused(this)" onfocusout="defocused(this)" required>
                                @error('name')
                                    <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                                @enderror
                            </div>
                        </div>

                        <div>
                            <label for="categoryName" class="form-label">Article Available in Country (For All Country just use = all)</label>
                            <div class="">
                                <input type="text" class="form-control " value="all" placeholder="IN,US" name="country" onfocus="focused(this)" onfocusout="defocused(this)" required>
                                @error('name')
                                    <p class="text-danger text-xs mt-2 mb-2">{{ $message }}</p>
                                @enderror
                            </div>
                        </div>
                        
                          <hr class="horizontal dark my-2">
                        <label class="form-label">Article Expire Date</label>
                          <div class="input-group">
                                <input type="date" class="form-control" name="expire_at"  placeholder="Pick a date" required>
                          </div> 
                        
                        <hr class="horizontal dark my-2">
                        <label class="form-label">Select AdNetwork</label>
                          <div class="input-group">
                            <select name="ad_type" class="form-control" required>
                              @foreach($ad as $item)
                              <option value="{{$item->type}}" {{($item->type == '1' ? 'selected' : '')}}>{{$item->title}}</option>
                              @endforeach
                            </select>
                          </div>
                          
                        <hr class="horizontal dark my-2">
                        <label class="form-label">Play Video in ?</label>
                          <div class="input-group">
                            <select name="action_type" class="form-control" required>
                              <option value="browser" >Browser (if app installed it will be open in app)</option>
                              <option value="custom" >Google Chrome Custom Tab(in App)</option>
                            </select>
                          </div>
              
                        <div class="d-flex justify-content-end mt-4">
                            <a href="{{ url('/article/active') }}" type="button" name="button" class="btn btn-light m-0">BACK TO LIST</a>
                            <button type="submit" name="button" class="btn bg-gradient-primary m-0 ms-2">Create  Article</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</main>
@endsection