@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-12 text-center mt-5 fs-1">
                Формирование документа: <span id="percent">{{ $percent }}</span>%
            </div>
        </div>

        <div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0"
             aria-valuemax="100">
            <div class="progress-bar" style="width: {{ $percent }}%"></div>
        </div>
        @if($percent == 100)
            <div class="col-12 my-5 fs-1 text-center">
                Скачать <a id="link" download href="/exported/docx/{{ $filename }}">{{ $filename }}</a>
            </div>
        @endif

    </div>

    @if($percent < 100)
        <script>
            setTimeout(function () {
                window.location.reload();
            }, 1000);
        </script>
    @else
        <script>
            document.getElementById('link').click();
            setTimeout(function () {
                window.location = '/';
            }, 1000);
        </script>
    @endif

@endsection

