# All files / js/components PermissionErrorModal.vue

0% Statements 0/11
0% Branches 0/23
0% Functions 0/6
0% Lines 0/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71

     <script setup lang="ts">
    import { computed } from 'vue';
    import { ShieldX, X } from 'lucide-vue-next';
    import { usePermissionError } from '@/composables/usePermissionError';

    const { permissionError, showPermissionModal, hideError, getModuleDisplayName, getAbilityDisplayName } = usePermissionError();

    const moduleDisplayName = computed(() =>
        permissionError.value ? getModuleDisplayName(permissionError.value.module) : ''
    );

    const abilityDisplayName = computed(() =>
        permissionError.value ? getAbilityDisplayName(permissionError.value.ability) : ''
    );
    </script>

    <template>
        <!-- Modal Backdrop -->
        <div
            v-if="showPermissionModal"
            class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50"
            @click="hideError"
        >
            <!-- Modal Content -->
            <div
                class="relative mx-4 w-full max-w-md rounded-lg bg-white p-6 shadow-xl"
                @click.stop
            >
                <!-- Close Button -->
                <button
                    @click="hideError"
                    class="absolute right-4 top-4 text-gray-400 hover:text-gray-600"
                >
                    <X class="h-5 w-5" />
                </button>

                <!-- Icon -->
                <div class="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-100">
                    <ShieldX class="h-8 w-8 text-red-600" />
                </div>

                <!-- Title -->
                <h2 class="mb-3 text-center text-xl font-semibold text-gray-900">
                    Access Denied
                </h2>

                <!-- Message -->
                <p class="mb-4 text-center text-gray-600">
                    You don't have permission to {{ abilityDisplayName }} {{ moduleDisplayName }}.
                </p>

                <!-- Additional Info -->
                <div class="mb-6 rounded-lg bg-yellow-50 border border-yellow-200 p-3">
                    <p class="text-sm text-yellow-800">
                        <strong>Need access?</strong> Contact your administrator to request permission for this feature.
                    </p>
                </div>

                <!-- Actions -->
                <div class="flex gap-3">
                    <button
                        @click="hideError"
                        class="flex-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
                    >
                        OK
                    </button>
                </div>
            </div>
        </div>
    </template>