All files / apps/huella-legal/app error.vue

100% Statements 19/19
71.42% Branches 5/7
100% Functions 8/8
100% Lines 19/19

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 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  10x       5x   31x       31x                             5x                             10x       5x   31x     31x     31x         1x                         10x 10x                           10x 10x 10x   10x   10x   1x            
<template>
    <UApp :locale="es">
        <NuxtLayout>
            <UContainer class="py-12 md:py-20">
                <section v-if="error.status === 404" data-error="not-found" class="lg:w-7/12">
                    <BaseKicker>{{ $t("error.kicker", { status: error.status }) }}</BaseKicker>
                    <h1
                        class="mt-2 font-serif text-h1 text-balance text-highlighted md:text-display"
                    >
                        {{ $t("error.notFound.title") }}
                    </h1>
                    <p class="mt-4 max-w-measure font-serif text-reading text-toned">
                        {{ $t("error.notFound.lead") }}
                    </p>
                    <form
                        :action="searchAction"
                        method="get"
                        role="search"
                        class="mt-8 flex max-w-lg flex-col gap-3 sm:flex-row sm:items-end"
                    >
                        <UFormField :label="$t('error.search.label')" name="query" class="flex-1">
                            <UInput
                                name="query"
                                icon="i-lucide-search"
                                :placeholder="$t('error.search.placeholder')"
                                class="w-full"
                            />
                        </UFormField>
                        <UButton
                            type="submit"
                            :label="$t('error.search.submit')"
                            class="justify-center"
                        />
                    </form>
                    <UButton
                        :to="{ name: 'index' }"
                        variant="link"
                        trailing-icon="i-lucide-arrow-right"
                        :label="$t('error.notFound.home')"
                        class="mt-4 -ml-3"
                    />
                </section>
 
                <section v-else data-error="server" class="flex flex-col items-start gap-4">
                    <BaseKicker muted>
                        {{ $t("error.kicker", { status: error.status }) }}
                    </BaseKicker>
                    <h1 class="font-serif text-h3 text-balance text-highlighted">
                        {{ $t("error.server.title") }}
                    </h1>
                    <p class="max-w-md font-serif text-base/relaxed text-toned">
                        {{ $t("error.server.lead") }}
                    </p>
                    <div class="flex flex-col gap-3 self-stretch sm:flex-row sm:self-start">
                        <UButton
                            icon="i-lucide-rotate-cw"
                            :label="$t('error.server.retry')"
                            class="justify-center"
                            @click="reloadNuxtApp({ force: true })"
                        />
                        <UButton
                            :to="nav.contact"
                            variant="outline"
                            color="neutral"
                            :label="$t('error.server.contact')"
                            class="justify-center"
                        />
                    </div>
                </section>
 
                <ErrorDebug v-if="isDev" :error />
            </UContainer>
        </NuxtLayout>
    </UApp>
</template>
 
<script lang="ts" setup>
import type { NuxtError } from "#app";
import { es } from "@nuxt/ui/locale";
 
interface Props {
    error: NuxtError<{ message?: string }>;
}
 
const { error } = defineProps<Props>();
 
const { t } = useI18n();
const searchAction = useRouter().resolve({ name: "search" }).href;
const { nav } = useAppConfig();
 
const isDev = import.meta.dev;
 
useHead(
    {
        title: () => t("error.head", { status: error.status }),
        meta: [{ name: "robots", content: "noindex" }],
    },
    { tagPriority: "high" },
);
</script>