<template>
    <div
        v-if="progress > 0"
        class="progress-bar-container">
        <div class="progress-bar-header">
            <span aria-hidden="true">{{ progress }}%</span>
        </div>
        <div class="progress">
            <div
                class="progress-bar progress-bar-success"
                role="progressbar"
                :aria-valuetext="`Scheduling progress ${progress}%`"
                aria-valuemin="0"
                aria-valuemax="100"
                :style="{ width: progress + '%' }">
                    <div class="progress-bar-middle"></div>
            </div>
        </div>
    </div>
</template>

<script>
import { getProgressBarPercentage } from '@/constants/progress-bar-mapper';
import { useMainStore } from '@/store';

export default {
    name: 'progress-bar',
    data() {
        return {
            progress: this.getProgress()
        };
    },
    methods: {
        getProgress() {
            const pageName = useMainStore().applicationUser.lastPageVisited;
            return getProgressBarPercentage(pageName);
        }
    }
};
</script>
<style lang="scss">
    .progress-bar-container {
        display: flex;

        .progress-bar-header {
            padding-right: 0.3125rem;
            color: $progress-bar-success-color;
            font-weight: 600;
            font-size: 0.875rem;
            line-height: 0.9375rem;
            text-align: right;
        }

        .progress {
            @include media-breakpoint-up(xs) {
                min-width: 5.9375rem;
            }

            @include media-breakpoint-up(md) {
                min-width: 17.1875rem;
            }

            margin-left: 0;
            border-radius: $border-radius-pill;
            overflow: visible;
            background-color: $progress-bar-background-color;

            .progress-bar {
                background-color: $progress-bar-success-color;
                border-radius: $border-radius-pill 0 0 $border-radius-pill;
                overflow: visible;

                .progress-bar-middle {
                    width: 1.0625rem;
                    height: 1.0625rem;
                    position: relative;
                    margin-right: -8.5px;
                    margin-left: auto;
                    margin-top: -1px;
                    border: 0.125rem solid #ffffff;
                    border-radius: 50%;
                    background-color: $progress-bar-success-color;
                    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
                }
            }
        }
    }
</style>
