<form class="modal-form form-prevent-multiple-submits" action="{{ route('address.store') }}" method="POST">
    @csrf
    @if((new \Jenssegers\Agent\Agent())->isDesktop())
        <div class="form-title">
            <h3>결제 QR 코드 스캔</h3>
        </div>

        <div class="form-group text-center">
            <img src="{{ $prepare['url'] }}" alt="qrcode">
        </div>

        <div class="mb-2 text-center text-danger">
            <em>MSQUARE MARKET 어플을 이용해서 QR 코드 스캔을 하세요</em>
        </div>

    @else
        <div class="form-title">
            <h3>모바일 지갑으로 QR 코드 전달</h3>
        </div>

        <div class="mb-2 text-center text-danger">
            <a href="{{ $prepare['deep_link'] }}"><em>결제 화면으로 이동</em></a>
        </div>
    @endif
</form>

@once
    <script>
        // TODO: medium-modal 각각 분리해서 hidden 이벤트 체크해야함
        $('#medium-modal').on('hidden.bs.modal', function () {
            clearInterval(send_timer)
        });

        $(document).ready(async function() {
            send_timer = setInterval(async function() {
                const response = await call_local_api('{{ route("wallet-send.result") }}', { request_key: @json($prepare['request_key']) })

                const d = response.data
                // console.log(d)
                if (d['status'] === 'completed') {
                    completed_wallet_send(d)

                    $('#medium-modal.show').modal('hide')
                    iziToast.success({ title: 'Success', message: $('#action-completed').text() })
                    clearInterval(send_timer)
                }
            }, 1000);
        });
        var send_timer = null
    </script>
@endonce
