hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import type { ErrorComponentProps } from "@tanstack/solid-router"; |
| 2 | import { currentLocale, formatApiError } from "@/api/client"; |
| 3 | import { Button } from "@/components/ui/button"; |
| 4 | import { IconAlert } from "@/components/ui/icons"; |
| 5 | |
| 6 | /** |
| 7 | * The router's default error component: a page that throws while rendering |
| 8 | * (typically a failed list read through `resource.latest`) shows this in |
| 9 | * place of its own content, inside the shell, so navigation keeps working. |
| 10 | * Without it the throw reached the app-wide boundary and replaced everything |
| 11 | * with a full-screen 500. |
| 12 | * |
| 13 | * It can also render for the root route, above the i18n provider, so it uses |
| 14 | * the client's bilingual-fallback idiom instead of `t(...)`. |
| 15 | */ |
| 16 | export function RouteErrorFallback(props: ErrorComponentProps) { |
| 17 | const tr = () => currentLocale() === "tr"; |
| 18 | console.error("Route render error:", props.error); |
| 19 | return ( |
| 20 | <div role="alert" class="mx-auto flex w-full max-w-[520px] flex-col items-center gap-4 rounded-xl border border-border-line bg-surface-base px-6 py-10 text-center"> |
| 21 | <span class="flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10 text-destructive-text"> |
| 22 | <IconAlert class="h-5 w-5" /> |
| 23 | </span> |
| 24 | <div class="space-y-1.5"> |
| 25 | <p class="text-base font-semibold text-text-strong">{tr() ? "Bu sayfa yüklenemedi" : "This page could not load"}</p> |
| 26 | <p class="text-sm text-text-subtle">{formatApiError(props.error)}</p> |
| 27 | </div> |
| 28 | <Button type="button" size="sm" class="h-9 px-4" onClick={() => props.reset()}> |
| 29 | {tr() ? "Tekrar dene" : "Try again"} |
| 30 | </Button> |
| 31 | </div> |
| 32 | ); |
| 33 | } |