Skip to content

Commit a34f891

Browse files
committed
feat(error): merge components
1 parent ce23c59 commit a34f891

19 files changed

+43
-96
lines changed

β€Žsrc/app/components/_/Error.vue β€Žsrc/app/components/_/AppError.vue

+33-30
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
<span class="flex items-center gap-1 text-xl font-black">
55
{{ t('maevNo') }}
66
</span>
7-
<span>
8-
{{ statusCode ? `${statusCode} - ` : '' }}{{ statusReason }}
9-
</span>
7+
<h1>{{ `${statusCode} - ${statusReason}` }}</h1>
108
</CardStateAlert>
11-
<p v-if="statusCode === 403" class="text-center">
12-
{{ t('error403Description') }}
13-
<br />
14-
{{ t('error403Hint') }}
15-
</p>
9+
<div>
10+
<p v-if="statusCode === 403" class="text-center">
11+
{{ t('error403Description') }}
12+
<br />
13+
{{ t('error403Hint') }}
14+
</p>
15+
</div>
16+
<div>
17+
<span v-if="description">
18+
{{ description }}
19+
</span>
20+
<!-- eslint-disable vue/no-v-html -->
21+
<div v-if="isInDevelopment && stack" v-html="stack" />
22+
<!-- eslint-enable vue/no-v-html -->
23+
</div>
1624
<ButtonList class="justify-center">
1725
<ButtonSignIn v-if="statusCode === 403" />
1826
<ButtonHome />
@@ -21,38 +29,33 @@
2129
</template>
2230

2331
<script setup lang="ts">
24-
import { status } from '@http-util/status-i18n'
25-
2632
export interface Props {
27-
statusCode?: number
33+
statusCode: number
34+
statusMessage?: string
35+
description?: string
36+
stack?: string
2837
}
2938
const props = withDefaults(defineProps<Props>(), {
30-
statusCode: undefined,
39+
description: undefined,
40+
statusMessage: undefined,
41+
stack: undefined,
3142
})
3243
3344
const { locale, t } = useI18n()
34-
const { ssrContext } = useNuxtApp()
3545
36-
// computations
37-
const statusReason = computed(() => {
38-
return status(props.statusCode, locale.value) || (t('error') as string)
39-
})
46+
const isInDevelopment = import.meta.dev
4047
41-
// methods
42-
const init = () => {
43-
if (ssrContext && props.statusCode) {
44-
ssrContext.event.node.res.statusCode = props.statusCode
45-
}
48+
// page
49+
const { ssrContext } = useNuxtApp()
50+
if (ssrContext && props.statusCode) {
51+
ssrContext.event.node.res.statusCode = props.statusCode
4652
}
4753
48-
// initialization
49-
init()
50-
</script>
51-
52-
<script lang="ts">
53-
export default {
54-
name: 'AppError',
55-
}
54+
// status code
55+
const { status } = await import('@http-util/status-i18n')
56+
const statusReason = computed(() => {
57+
return status(props.statusCode, locale.value) || t('error')
58+
})
5659
</script>
5760

5861
<i18n lang="yaml">

β€Žsrc/app/components/_/VioError.vue

-44
This file was deleted.

β€Žsrc/app/error.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<NuxtLayout>
3-
<VioError
3+
<AppError
44
:status-code="error.statusCode"
55
:status-message="error.statusMessage"
66
:description="error.message"

β€Žsrc/app/pages/account/password/reset/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<h1>{{ title }}</h1>
44
<FormAccountPasswordReset v-if="isCodeValid" />
5-
<Error v-else :status-code="422" />
5+
<AppError v-else :status-code="422" />
66
</div>
77
</template>
88

β€Žsrc/app/pages/account/verify.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
postgresP0002: t('postgresP0002'),
1010
}"
1111
/>
12-
<Error v-else :status-code="422" />
12+
<AppError v-else :status-code="422" />
1313
</div>
1414
</template>
1515

β€Žsrc/app/pages/event/edit/[username]/[event_name].vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/>
2929
</section>
3030
</div>
31-
<Error v-else :status-code="403" />
31+
<AppError v-else :status-code="403" />
3232
</Loader>
3333
</template>
3434

β€Žsrc/app/pages/event/view/[username]/[event_name]/attendance.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</template>
5656
</Modal>
5757
</div>
58-
<Error v-else :status-code="403" />
58+
<AppError v-else :status-code="403" />
5959
</Loader>
6060
</template>
6161

β€Žsrc/app/pages/event/view/[username]/[event_name]/guest.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<LayoutPageTitle :title="t('title')" />
88
<GuestList :event="event" />
99
</div>
10-
<Error v-else :status-code="403" />
10+
<AppError v-else :status-code="403" />
1111
</Loader>
1212
</template>
1313

β€Žsrc/app/pages/event/view/[username]/[event_name]/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
</template>
352352
</Modal>
353353
</div>
354-
<Error v-else :status-code="403" />
354+
<AppError v-else :status-code="403" />
355355
</Loader>
356356
</template>
357357

β€Žsrc/app/pages/πŸ«–/index.vue

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
<template>
22
<div>
3-
<Error :status-code="418" />
3+
<AppError :status-code="418" />
44
</div>
55
</template>
66

77
<script setup lang="ts">
88
const { t } = useI18n()
9-
const { ssrContext } = useNuxtApp() // cannot use `useRequestEvent` instead
109
11-
// data
12-
const title = t('title')
13-
14-
// methods
15-
const init = () => {
16-
if (ssrContext) {
17-
ssrContext.event.node.res.statusCode = 418
18-
}
19-
}
20-
21-
// initialization
22-
useHeadDefault({ title })
23-
init()
10+
// page
11+
useHeadDefault({ title: t('title') })
2412
</script>
2513

2614
<i18n lang="yaml">

0 commit comments

Comments
Β (0)