-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherror.vue
More file actions
118 lines (102 loc) · 2.31 KB
/
error.vue
File metadata and controls
118 lines (102 loc) · 2.31 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<script setup>
import { computed } from 'vue';
import { useCookie, useHead, clearError } from 'nuxt/app';
import { AlertTriangle } from 'lucide-vue-next';
import { HomeIcon } from '@heroicons/vue/24/outline';
const props = defineProps({
error: {
type: Object,
default: () => ({ statusCode: 500, message: '' })
}
});
const { t } = useI18n();
const token = useCookie('token');
const layout = computed(() => {
return token.value ? 'dashboard' : 'auth';
});
useHead({
title: `Error ${props.error.statusCode}`
});
const handleError = () => {
if (token.value) {
clearError({ redirect: '/dashboard' });
} else {
clearError({ redirect: '/login' });
}
};
</script>
<template>
<div>
<NuxtLayout :name="layout">
<div class="error-container">
<TCard class="error-card">
<div class="error-content">
<AlertTriangle class="error-icon" />
<h1 class="error-title">Error {{ error.statusCode }}</h1>
<p class="error-message">{{ error.message || t('Something went wrong') }}</p>
<TButton class="error-button" @click="handleError">
<template #left-icon>
<HomeIcon />
</template>
{{ t('Go to Homepage') }}
</TButton>
</div>
</TCard>
</div>
</NuxtLayout>
</div>
</template>
<style lang="scss" scoped>
@use '@/assets/scss/_variables.scss' as *;
.error-container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
padding: $spacing-8;
}
.error-card {
width: 100%;
max-width: 400px;
}
.error-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: $spacing-8;
text-align: center;
}
.error-icon {
width: 8rem; // 128px
height: 8rem; // 128px
color: $error-color;
animation: pulse-red 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.error-title {
margin-top: $spacing-4;
font-size: 2.25rem; // 36px
font-weight: $font-bold;
color: $text-secondary;
}
.error-message {
margin-top: $spacing-2;
font-size: $font-size-xl;
color: $text-muted;
}
.error-button {
margin-top: $spacing-6;
}
@keyframes pulse-red {
0%,
100% {
transform: scale(1);
opacity: 0.8;
}
50% {
transform: scale(1.1);
opacity: 1;
}
}
</style>