<form class="modal-form form-prevent-multiple-submits" action="{{ route('address.store') }}" method="POST">
    @csrf
    <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>
</form>

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

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

                const d = response.data
                if (d['status'] === 'completed') {
                    update_balance_ui(d)

                    $('#medium-modal.show').modal('hide')
                    iziToast.success({ title: 'Success', message: $('#action-completed').text() })
                    clearInterval(balance_timer)

                }
            }, 1000);
        });
        var balance_timer = null
    </script>
@endonce
