@extends('adminmodule::layouts.master')

@section('title',translate('withdraw_request_list'))

@section('content')
    <div class="main-content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <div
                        class="page-title-wrap d-flex justify-content-between flex-wrap align-items-center gap-3 mb-3">
                        <h2 class="page-title">{{translate('withdraw_request_list')}}</h2>
                    </div>

                    <div
                        class="d-flex flex-wrap justify-content-between align-items-center border-bottom mx-lg-4 mb-10 gap-3">
                        <ul class="nav nav--tabs">
                            <li class="nav-item">
                                <a class="nav-link {{$status=='all'?'active':''}}"
                                   href="{{url()->current()}}?status=all">
                                    {{translate('All')}}
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link {{$status=='pending'?'active':''}}"
                                   href="{{url()->current()}}?status=pending">
                                    {{translate('Pending')}}
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link {{$status=='approved'?'active':''}}"
                                   href="{{url()->current()}}?status=approved">
                                    {{translate('Approved')}}
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link {{$status=='denied'?'active':''}}"
                                   href="{{url()->current()}}?status=denied">
                                    {{translate('Denied')}}
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link {{$status=='settled'?'active':''}}"
                                   href="{{url()->current()}}?status=settled">
                                    {{translate('Settled')}}
                                </a>
                            </li>
                        </ul>

                        <div class="d-flex gap-2 fw-medium">
                            <span class="opacity-75">{{translate('total_withdraw')}}:</span>
                            <span class="title-color">{{$withdrawRequests->total()}}</span>
                        </div>
                    </div>

                    <div class="tab-content">
                        <div class="tab-pane fade show active" id="all-tab-pane">
                            <div class="card">
                                <div class="card-body">
                                    <div class="data-table-top d-flex flex-wrap gap-10 justify-content-between">
                                        <form action="{{url()->current()}}?status={{$status}}"
                                              class="search-form search-form_style-two"
                                              method="POST">
                                            @csrf
                                            <div class="input-group search-form__input_group">
                                            <span class="search-form__icon">
                                                <span class="material-icons">search</span>
                                            </span>
                                                <input type="search" class="theme-input-style search-form__input"
                                                       value="{{$search}}" name="search"
                                                       placeholder="{{translate('Search by provider')}}">
                                            </div>
                                            <button type="submit"
                                                    class="btn btn--primary">{{translate('search')}}</button>
                                        </form>

                                        <div class="d-flex flex-wrap align-items-center gap-3">
                                            @can('withdraw_update')
                                                <button type="button" class="btn btn--success" data-bs-toggle="modal"
                                                        data-bs-target="#uploadFileModal">{{translate('Bulk_Status_Update')}}</button>
                                            @endcan
                                            @can('withdraw_export')
                                                <div class="dropdown">
                                                    <button type="button"
                                                            class="btn btn--secondary text-capitalize dropdown-toggle"
                                                            data-bs-toggle="dropdown">
                                                    <span
                                                        class="material-icons">file_download</span> {{translate('download')}}
                                                    </button>
                                                    <ul class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                                                        <li>
                                                            <a class="dropdown-item"
                                                               href="{{route('admin.withdraw.request.download', ['status'=>$status])}}">
                                                                {{translate('excel')}}
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            @endcan
                                        </div>
                                    </div>

                                    <div class="select-table-wrap">
                                        @can('withdraw_manage_status')
                                            <div class="multiple-select-actions multiple-select-actions-customize gap-3 flex-wrap align-items-center justify-content-between">
                                                <div class="d-flex align-items-center flex-wrap gap-2 gap-lg-4">
                                                    <div class="ms-sm-1">
                                                        <input type="checkbox" class="multi-checker">
                                                    </div>
                                                    <p><span class="checked-count">2</span> {{translate('Item_Selected')}}
                                                    </p>
                                                </div>

                                                <div class="d-flex align-items-center flex-wrap gap-3">
                                                    <select class="js-select theme-input-style w-100"
                                                            id="multi-status__select" required>
                                                        <option selected disabled>{{translate('Update_status')}}</option>
                                                        <option value="denied">{{translate('Deny')}}</option>
                                                        <option value="approved">{{translate('Approve')}}</option>
                                                        <option value="settled">{{translate('Settle')}}</option>
                                                    </select>
                                                </div>
                                            </div>
                                        @endcan

                                        <div class="table-responsive position-relative">
                                            <table id="example" class="table align-middle multi-select-table">
                                                <thead class="text-nowrap">
                                                <tr>
                                                    @can('withdraw_manage_status')
                                                        <th></th>
                                                    @endcan
                                                    <th>{{translate('SL')}}</th>
                                                    <th>{{translate('Provider')}}</th>
                                                    <th>{{translate('Amount')}}</th>
                                                    <th>{{translate('Provider_Note')}}</th>
                                                    <th>{{translate('Admin_Note')}}</th>
                                                    <th>{{translate('Request_Time')}}</th>
                                                    <th class="text-center">{{translate('Status')}}</th>
                                                    @can('withdraw_manage_status')
                                                        <th class="text-center">{{translate('Action')}}</th>
                                                    @endcan
                                                </tr>
                                                </thead>
                                                <tbody>
                                                @foreach($withdrawRequests as $key=>$withdrawRequest)
                                                    <tr>
                                                        @can('withdraw_manage_status')
                                                            <td><input type="checkbox" class="multi-check" value="{{$withdrawRequest->id}}"></td>
                                                        @endcan
                                                        <td>{{$withdrawRequests->firstitem()+$key}}</td>
                                                        <td class="text-capitalize">
                                                            @if($withdrawRequest?->user?->provider)
                                                                <a href="{{route('admin.provider.details',[$withdrawRequest->user->provider->id, 'web_page'=>'overview'])}}">
                                                                    {{Str::limit($withdrawRequest->user->provider->company_name, 30)}}
                                                                </a>
                                                            @else
                                                                {{translate('Not_available')}}
                                                            @endif
                                                        </td>
                                                        <td>{{with_currency_symbol($withdrawRequest->amount)}}</td>
                                                        <td>
                                                            <div class="max-w320 min-w120 text-two-line"
                                                                 data-bs-toggle="tooltip" data-bs-placement="top"
                                                                 @if($withdrawRequest->note)
                                                                     data-bs-title="{{$withdrawRequest->note}}"
                                                                @endif>
                                                                @if($withdrawRequest->note)
                                                                    {{ Str::limit($withdrawRequest->note, 100) }}
                                                                @else
                                                                    <span
                                                                        class="badge badge-primary">{{ translate('Not provided yet') }}</span>
                                                                @endif
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <div class="max-w320 min-w120 text-two-line"
                                                                 data-bs-toggle="tooltip" data-bs-placement="top"
                                                                 @if($withdrawRequest->admin_note)
                                                                     data-bs-title="{{$withdrawRequest->admin_note }}"
                                                                @endif>
                                                                @if($withdrawRequest->admin_note)
                                                                    {{  Str::limit($withdrawRequest->admin_note, 100)}}
                                                                @else
                                                                    <span
                                                                        class="badge badge-primary">{{ translate('Not provided yet') }}</span>
                                                                @endif
                                                            </div>
                                                        </td>
                                                        <td>
                                                            <div>
                                                                <div>{{date('d-M-y', strtotime($withdrawRequest->created_at))}}</div>
                                                                <div>{{date('H:iA', strtotime($withdrawRequest->created_at))}}</div>
                                                            </div>
                                                        </td>
                                                        <td class="text-center">
                                                            @if($withdrawRequest->request_status == 'pending')
                                                                <label
                                                                    class="badge badge-info">{{translate('pending')}}</label>
                                                            @elseif($withdrawRequest->request_status == 'approved')
                                                                <label
                                                                    class="badge badge-success">{{translate('approved')}}</label>
                                                            @elseif($withdrawRequest->request_status == 'settled')
                                                                <label
                                                                    class="badge badge-success">{{translate('Settled')}}</label>
                                                            @elseif($withdrawRequest->request_status == 'denied')
                                                                <label
                                                                    class="badge badge-danger">{{translate('denied')}}</label>
                                                            @endif
                                                        </td>
                                                        <td>
                                                            <div class="d-flex gap-2 justify-content-center">
                                                                @can('withdraw_manage_status')
                                                                    @if($withdrawRequest->request_status=='pending')
                                                                        <button type="button"
                                                                                class="action-btn btn--danger"
                                                                                style="--size: 30px"
                                                                                data-bs-toggle="modal"
                                                                                data-bs-target="#denyModal-{{$withdrawRequest->id}}">
                                                                            <span
                                                                                class="material-icons m-0">close</span>
                                                                        </button>

                                                                        <div class="modal fade"
                                                                             id="denyModal-{{$withdrawRequest->id}}"
                                                                             tabindex="-1"
                                                                             aria-labelledby="exampleModalLabel"
                                                                             aria-hidden="true">
                                                                            <div class="modal-dialog modal-lg">
                                                                                <div class="modal-content">
                                                                                    <div class="modal-body">
                                                                                        <form
                                                                                            action="{{route('admin.withdraw.request.update_status',[$withdrawRequest->id, 'status'=>'denied'])}}"
                                                                                            method="POST">
                                                                                            @csrf
                                                                                            <button type="button"
                                                                                                    class="btn-close"
                                                                                                    data-bs-dismiss="modal"
                                                                                                    aria-label="Close"></button>
                                                                                            <div class="text-center">
                                                                                                <img width="75"
                                                                                                     class="my-3"
                                                                                                     src="{{asset('public/assets/admin-module/img/media/deny.png')}}"
                                                                                                     alt="{{ translate('deny') }}">
                                                                                                <h3 class="mb-3">{{translate('Deny_this_request')}}
                                                                                                    ?</h3>
                                                                                            </div>

                                                                                            <div
                                                                                                class="py-3 d-flex flex-wrap flex-md-nowrap gap-3 mb-2">
                                                                                                <div
                                                                                                    class="c1-light-bg radius-10 py-3 px-4 flex-grow-1">
                                                                                                    <h4 class="mb-2">{{translate('Provider_Information')}}</h4>
                                                                                                    @if($withdrawRequest->provider)
                                                                                                        <h5 class="c1 mb-2">{{$withdrawRequest->provider->company_name}}</h5>
                                                                                                        <ul class="list-info">
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="material-icons">phone_iphone</span>
                                                                                                                <a href="tel:{{$withdrawRequest->provider->company_phone}}">{{$withdrawRequest->provider->company_phone}}</a>
                                                                                                            </li>
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="material-icons">map</span>
                                                                                                                <p>{{$withdrawRequest->provider->company_address}}</p>
                                                                                                            </li>
                                                                                                        </ul>
                                                                                                    @endif
                                                                                                </div>

                                                                                                <div
                                                                                                    class="c1-light-bg radius-10 py-3 px-4 flex-grow-1">
                                                                                                    <h4 class="mb-2">{{translate('Withdraw_Method_Information')}}</h4>
                                                                                                    <ul class="list-info gap-1">
                                                                                                        @forelse($withdrawRequest->withdrawal_method_fields as $key=>$value)
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="font-weight-bold"><b>{{translate($key)}}</b>: </span>
                                                                                                                <span>{{$value}}</span>
                                                                                                            </li>
                                                                                                        @empty
                                                                                                            <li>
                                                                                                                <span>{{translate('Information_unavailable')}}</span>
                                                                                                            </li>
                                                                                                        @endforelse
                                                                                                    </ul>
                                                                                                </div>
                                                                                            </div>

                                                                                            <textarea
                                                                                                class="form-control h-140 resize-none"
                                                                                                placeholder="{{translate('Note')}}"
                                                                                                name="note"></textarea>

                                                                                            <div
                                                                                                class="mb-3 mt-4 d-flex justify-content-center gap-3">
                                                                                                <button type="button"
                                                                                                        class="btn btn--secondary"
                                                                                                        data-bs-dismiss="modal">{{translate('Cancel')}}</button>
                                                                                                <button type="submit"
                                                                                                        class="btn btn--primary">{{translate('Yes')}}</button>
                                                                                            </div>
                                                                                        </form>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>

                                                                        <button type="button"
                                                                                class="action-btn btn--success"
                                                                                style="--size: 30px"
                                                                                data-bs-toggle="modal"
                                                                                data-bs-target="#approveModal-{{$withdrawRequest->id}}">
                                                                            <span
                                                                                class="material-icons">done_outline</span>
                                                                        </button>
                                                                        <div class="modal fade"
                                                                             id="approveModal-{{$withdrawRequest->id}}"
                                                                             tabindex="-1"
                                                                             aria-labelledby="exampleModalLabel"
                                                                             aria-hidden="true">
                                                                            <div class="modal-dialog modal-lg">
                                                                                <div class="modal-content">
                                                                                    <div class="modal-body">
                                                                                        <form
                                                                                            action="{{route('admin.withdraw.request.update_status',[$withdrawRequest->id, 'status'=>'approved'])}}"
                                                                                            method="POST">
                                                                                            @csrf
                                                                                            <button type="button"
                                                                                                    class="btn-close"
                                                                                                    data-bs-dismiss="modal"
                                                                                                    aria-label="Close"></button>
                                                                                            <div class="text-center">
                                                                                                <img width="75"
                                                                                                     class="my-3"
                                                                                                     src="{{asset('public/assets/admin-module/img/media/accept.png')}}"
                                                                                                     alt="{{ translate('accept') }}">
                                                                                                <h3 class="mb-3">{{translate('Accept_this_request')}}
                                                                                                    ?</h3>
                                                                                            </div>

                                                                                            <div
                                                                                                class="py-3 d-flex flex-wrap flex-md-nowrap gap-3 mb-2">
                                                                                                <div
                                                                                                    class="c1-light-bg radius-10 py-3 px-4 flex-grow-1">
                                                                                                    <h4 class="mb-2">{{translate('Provider_Information')}}</h4>
                                                                                                    @if($withdrawRequest->provider)
                                                                                                        <h5 class="c1 mb-2">{{$withdrawRequest->provider->company_name}}</h5>
                                                                                                        <ul class="list-info">
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="material-icons">phone_iphone</span>
                                                                                                                <a href="tel:{{$withdrawRequest->provider->company_phone}}">{{$withdrawRequest->provider->company_phone}}</a>
                                                                                                            </li>
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="material-icons">map</span>
                                                                                                                <p>{{$withdrawRequest->provider->company_address}}</p>
                                                                                                            </li>
                                                                                                        </ul>
                                                                                                    @endif
                                                                                                </div>

                                                                                                <div
                                                                                                    class="c1-light-bg radius-10 py-3 px-4 flex-grow-1">
                                                                                                    <h4 class="mb-2">{{translate('Withdraw_Method_Information')}}</h4>
                                                                                                    <ul class="list-info gap-1">
                                                                                                        @forelse($withdrawRequest->withdrawal_method_fields as $key=>$value)
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="font-weight-bold"><b>{{translate($key)}}</b>: </span>
                                                                                                                <span>{{$value}}</span>
                                                                                                            </li>
                                                                                                        @empty
                                                                                                            <li>
                                                                                                                <span>{{translate('Information_unavailable')}}</span>
                                                                                                            </li>
                                                                                                        @endforelse
                                                                                                    </ul>
                                                                                                </div>
                                                                                            </div>

                                                                                            <textarea
                                                                                                class="form-control h-140 resize-none"
                                                                                                placeholder="{{translate('Note')}}"
                                                                                                name="note"></textarea>

                                                                                            <div
                                                                                                class="mb-3 mt-4 d-flex justify-content-center gap-3">
                                                                                                <button type="button"
                                                                                                        class="btn btn--secondary"
                                                                                                        data-bs-dismiss="modal">{{translate('Cancel')}}</button>
                                                                                                <button type="submit"
                                                                                                        class="btn btn--primary">{{translate('Yes')}}</button>
                                                                                            </div>
                                                                                        </form>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>

                                                                    @elseif($withdrawRequest->request_status=='approved')
                                                                        <button type="button" class="btn btn--success"
                                                                                data-bs-toggle="modal"
                                                                                data-bs-target="#approveModal-{{$withdrawRequest->id}}">
                                                                            {{translate('Settle')}}
                                                                        </button>
                                                                        <div class="modal fade"
                                                                             id="approveModal-{{$withdrawRequest->id}}"
                                                                             tabindex="-1"
                                                                             aria-labelledby="exampleModalLabel"
                                                                             aria-hidden="true">
                                                                            <div class="modal-dialog modal-lg">
                                                                                <div class="modal-content">
                                                                                    <div class="modal-body">
                                                                                        <form
                                                                                            action="{{route('admin.withdraw.request.update_status',[$withdrawRequest->id, 'status'=>'settled'])}}"
                                                                                            method="POST">
                                                                                            @csrf
                                                                                            <button type="button"
                                                                                                    class="btn-close"
                                                                                                    data-bs-dismiss="modal"
                                                                                                    aria-label="Close"></button>
                                                                                            <div class="text-center">
                                                                                                <img width="75"
                                                                                                     class="my-3"
                                                                                                     src="{{asset('public/assets/admin-module/img/media/settle.png')}}"
                                                                                                     alt="{{ translate('settle') }}">
                                                                                                <h3 class="mb-3">{{translate('Settled_this_request')}}
                                                                                                    ?</h3>
                                                                                            </div>

                                                                                            <div
                                                                                                class="py-3 d-flex flex-wrap flex-md-nowrap gap-3 mb-2">
                                                                                                <div
                                                                                                    class="c1-light-bg radius-10 py-3 px-4 flex-grow-1">
                                                                                                    <h4 class="mb-2">{{translate('Provider_Information')}}</h4>
                                                                                                    @if($withdrawRequest->provider)
                                                                                                        <h5 class="c1 mb-2">{{$withdrawRequest->provider->company_name}}</h5>
                                                                                                        <ul class="list-info">
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="material-icons">phone_iphone</span>
                                                                                                                <a href="tel:{{$withdrawRequest->provider->company_phone}}">{{$withdrawRequest->provider->company_phone}}</a>
                                                                                                            </li>
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="material-icons">map</span>
                                                                                                                <p>{{$withdrawRequest->provider->company_address}}</p>
                                                                                                            </li>
                                                                                                        </ul>
                                                                                                    @endif
                                                                                                </div>

                                                                                                <div
                                                                                                    class="c1-light-bg radius-10 py-3 px-4 flex-grow-1">
                                                                                                    <h4 class="mb-2">{{translate('Withdraw_Method_Information')}}</h4>
                                                                                                    <ul class="list-info gap-1">
                                                                                                        @forelse($withdrawRequest->withdrawal_method_fields as $key=>$value)
                                                                                                            <li>
                                                                                                            <span
                                                                                                                class="font-weight-bold"><b>{{translate($key)}}</b>: </span>
                                                                                                                <span>{{$value}}</span>
                                                                                                            </li>
                                                                                                        @empty
                                                                                                            <li>
                                                                                                                <span>{{translate('Information_unavailable')}}</span>
                                                                                                            </li>
                                                                                                        @endforelse
                                                                                                    </ul>
                                                                                                </div>
                                                                                            </div>

                                                                                            <textarea
                                                                                                class="form-control h-140 resize-none"
                                                                                                placeholder="{{translate('Note')}}"
                                                                                                name="note"></textarea>

                                                                                            <div
                                                                                                class="mb-3 mt-4 d-flex justify-content-center gap-3">
                                                                                                <button type="button"
                                                                                                        class="btn btn--secondary"
                                                                                                        data-bs-dismiss="modal">{{translate('Cancel')}}</button>
                                                                                                <button type="submit"
                                                                                                        class="btn btn--primary">{{translate('Yes')}}</button>
                                                                                            </div>
                                                                                        </form>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    @elseif($withdrawRequest->request_status=='denied')
                                                                        <label
                                                                            class="badge badge-danger">{{translate('already_denied')}}</label>
                                                                    @elseif($withdrawRequest->request_status=='settled')
                                                                        <label
                                                                            class="badge badge-success">{{translate('already_settled')}}</label>
                                                                    @endif
                                                                @endcan
                                                            </div>
                                                        </td>
                                                    </tr>
                                                @endforeach
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                    <div class="d-flex justify-content-end">
                                        {!! $withdrawRequests->links() !!}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="uploadFileModal" tabindex="-1" aria-labelledby="uploadFileModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body py-5">
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    <div class="text-center mw-340 mx-auto">
                        <h3 class="text-uppercase text-center mb-4">{{translate('Upload_files')}} </h3>
                        <ul class="text-start text-muted d-flex flex-column gap-2">
                            <li>{{translate('Download Excel File From Withdraw list')}}</li>
                            <li>{{translate('Update  the request status column with the request status (approved, denied, settled)')}}</li>
                        </ul>
                        <p class="title-color fz-12 mb-5">{{translate('NB: Do not modify the initial row of the excel file')}}</p>
                        <form action="{{route('admin.withdraw.request.import')}}" id="uploadProgressForm" method="post"
                              enctype="multipart/form-data">
                            @csrf
                            <div class="d-flex justify-content-center">
                                <div class="upload-file w-auto">
                                    <input type="file" id="fileInput" class="upload-file__input"
                                           name="withdraw_request_file" accept=".xlsx" required>
                                    <div class="upload-file__img">
                                        <img src="{{asset('public/assets/admin-module/img/media/upload-file.png')}}"
                                             alt="{{translate('image')}}">
                                    </div>
                                    <span class="upload-file__edit">
                                        <span class="material-icons">edit</span>
                                    </span>
                                </div>
                            </div>

                            <div class="mt-5 card p-3">
                                <div class="d-flex flex-wrap align-items-center gap-3">
                                    <div class="">
                                        <img width="24"
                                             src="{{asset('public/assets/admin-module')}}/img/media/excel.png"
                                             alt="">
                                    </div>
                                    <div class="flex-grow-1 text-start">
                                        <div
                                            class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-1">
                                            <span id="name_of_file"
                                                  class="text-truncate">{{translate('file_name')}}</span>
                                            <span class="text-muted" id="progress-label">0%</span>
                                        </div>
                                        <progress id="uploadProgress" class="w-100" value="0" max="100"></progress>
                                    </div>
                                    <button type="reset"
                                            class="btn-close position-static border rounded-circle border-secondary p-2 fz-10"
                                            aria-label="Close"></button>
                                </div>
                            </div>
                            <button type="submit" class="btn btn--primary mt-4 w-100">{{translate('Submit')}}</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection

@push('script')
    <script>
        "use strict"

        $('#multi-status__select').change(function () {
            var request_ids = [];
            $('input:checkbox.multi-check').each(function () {
                if (this.checked) {
                    request_ids.push($(this).val());
                }
            });

            Swal.fire({
                title: "{{translate('are_you_sure')}}?",
                text: '',
                type: 'warning',
                showCloseButton: true,
                showCancelButton: true,
                cancelButtonColor: 'var(--bs-secondary)',
                confirmButtonColor: 'var(--bs-primary)',
                cancelButtonText: 'Cancel',
                confirmButtonText: 'Yes',
                reverseButtons: true

            }).then((result) => {
                if (result.value) {
                    $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                    });
                    $.ajax({
                        url: "{{route('admin.withdraw.request.update_multiple_status')}}",
                        data: {
                            request_ids: request_ids,
                            status: $(this).val()
                        },
                        type: 'put',
                        success: function (response) {
                            toastr.success(response.message)
                            setTimeout(location.reload.bind(location), 1000);
                        },
                        error: function () {

                        }
                    });
                }
            })

        });

        $(window).on('load', function () {
            $(".upload-file__input").on("change", function () {
                if (this.files && this.files[0]) {
                    let reader = new FileReader();
                    let img = $(this).siblings(".upload-file__img").find('img');

                    let file = this.files[0];
                    let isImage = file['type'].split('/')[0] == 'image';

                    if (isImage) {
                        reader.onload = function (e) {
                            img.attr("src", e.target.result);
                        };
                    } else {
                        reader.onload = function (e) {
                            img.attr("src", "{{asset('public/assets/admin-module/img/media/excel.png')}}");
                        };
                    }

                    reader.readAsDataURL(file);

                    reader.addEventListener('progress', (event) => {
                        if (event.loaded && event.total) {
                            const percent = (event.loaded / event.total) * 100;
                            $('#uploadProgress').val(percent);
                            $('#progress-label').html(Math.round(percent) + '%');
                            $('#name_of_file').html(file.name);
                        }
                    });
                }
            });
        })
    </script>
@endpush
