@extends('layouts.master')
@section('content')

<div class="container-fluid px-4">

    <div class="card mt-4">
                   <div class="card-header">
                                  <h1 class="">{{__('basicSetup')}}</h1>
                   </div>

                   <div class="card-body">
                    <p><a href="{{ asset('assets/pdf_instruction/line.pdf') }}" target="_blank">{{__('Download Line setup instructions PDF')}}</a></p>
                     @if ($errors->any())
                     <div class="alert alert-danger">
                     
                         @foreach ($errors->all() as $error )
                         <div>{{$error}}</div>

                         @endforeach

                     </div>
                   

                     @endif

                        <form id="basicSettingForm" action="{{ url('admin/add-basic-setting') }}" method="POST" enctype="multipart/form-data">

                                                 @csrf

                                                  <h3 style="margin-top: 20px" class="">{{__('LineSetup')}}</h3>

                                                  <div class="row">
                                                    <div class="mb-3 col-md-6">
                                                        <label  for="line_key" class="form-label">{{__('LineApi')}}</label>
                                                        <input
                                                          type="text"
                                                          class="form-control"
                                                          id="line_key"
                                                          name="line_key"
                                                          value="{{ $basicSetting->line_key }}"

                                                        />
                                                      </div>
                                                      <div class="mb-3 col-md-6">
                                                        <label  class="form-label">{{__('Liff')}}</label>
                                                        <input
                                                          type="text"
                                                          class="form-control"
                                                          id="liff_id"
                                                          name="liff_id"
                                                          value="{{$basicSetting->liff_id }}"

                                                        />
                                                      </div>
                                                      <div class="mb-3 col-md-6">
                                                        <label  class="form-label">{{__('Bot Id')}}</label>
                                                        <input
                                                          type="text"
                                                          class="form-control"
                                                          id="bot_id"
                                                          name="bot_id"
                                                          value="{{$basicSetting->bot_id }}"

                                                        />
                                                      </div>
                                               

                                                  </div>

                                                   

                                                    <button type="b_submit" id="updateButton" class="btn btn-primary">{{__('updateSetup')}}</button>





                                  </form>


                   </div>

    </div>

</div>
<div class="modal fade" id="confirmupdate" tabindex="-1" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">{{ __('Warning') }}</h5>
        </div>

        <div class="modal-body">


            <div class="form-popup-inputs">
                <label style="color: red" for="addNote">{{ __('warningLine') }}</label>
            </div>
         

        </div>

        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ __('Cancel') }}</button>
          <a href="javascript:void(0)" onclick="updatesetup()" class="btn btn-primary">{{__('updateSetup')}}</a>
   
            {{-- <a href="" onclick="sendallmessages()" class="btn btn-primary">{{ __('send') }}</a> --}}

        </div>

      
    </div>
</div>
</div>
@endsection
<script>
  document.addEventListener('DOMContentLoaded', function() {
    @if(isset($basicSetting->line_key) && $basicSetting->line_key  && isset($basicSetting->liff_id) && $basicSetting->liff_id &&isset($basicSetting->bot_id) && $basicSetting->bot_id)
      document.getElementById('updateButton').addEventListener('click', function(e) {
          e.preventDefault(); // Prevent the form from submitting
            var modal = new bootstrap.Modal(document.getElementById('confirmupdate'));
            modal.show();
      });
      @endif
  });
  function updatesetup() {
     
        document.getElementById('basicSettingForm').submit();
        var modal = new bootstrap.Modal(document.getElementById('confirmupdate'));
            modal.hide();

    }
</script>
