@extends('layout.v3.session')
@section('content')
    <div class="row">
        <div class="col-lg-6 offset-lg-3 col-md-12 col-sm-12">
            <div class="card card-danger card-outline">
                <div class="card-header">
                    <h3 class="card-title">{{ trans('form.delete_webhook', ['title' => $webhook->title]) }}</h3>
                </div>
                <div class="card-body">
                    <p class="text-danger">
                        {{ trans('form.permDeleteWarning') }}
                    </p>

                    <p>
                        {{ trans('form.webhook_areYouSure', ['title' => $webhook->title]) }}
                    </p>
                </div>
                <div class="card-footer text-end">
                    <input type="submit" id="button" name="submit" value="{{ trans('form.deletePermanently') }}"
                           class="btn btn-danger"/>
                    <a href="{{ URL::previous() }}" class="btn-outline-secondary btn">{{ trans('form.cancel') }}</a>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('scripts')
    <script nonce="{{ $JS_NONCE }}">
        $(function () {
            "use strict";
            $('#button').click(function() {
                var url = "{{ route('index') }}/api/v1/webhooks/{{ $webhook->id }}";
                $.ajax({url: url, type: 'DELETE'}).done(function() {
                    window.location = "{{ URL::previous() }}?webhook_id={{ $webhook->id }}&message=deleted";
                });
            });
        });
    </script>
@endsection
