| 1 | "use client"; |
| 2 | |
| 3 | import { use } from |
| 4 | import { useQuery } |
| 5 | import { ShieldOff } |
| 6 | import { useTranslations } |
| 7 | import { orpc } |
| 8 | |
| 9 | function BlockedPage({ |
| 10 | name, |
| 11 | state, |
| 12 | }: { |
| 13 | name: string |
| 14 | state: "installing |
| 15 | }) { |
| 16 | const t = |
| 17 | const suspended = |
| 18 | |
| 19 | return ( |
| 20 | <div className="flex flex-1 flex-col bg-background |
| 21 | <div className="flex shrink-0 items-center gap-2 border-b border-border bg-card px-4 py-2.5 |
| 22 | <span className="text-sm font-medium text-foreground |
| 23 | <span className={` |
| 24 | suspended ? "bg-red-500/10 text-red-400" |
| 25 | }`}> |
| 26 | {suspended ? t |
| 27 | </span> |
| 28 | </div> |
| 29 | |
| 30 | <div className="flex flex-1 items-center justify-center p-6 |
| 31 | <div className="flex w-full max-w-sm flex-col items-center gap-4 rounded-xl border border-border bg-card p-8 text-center |
| 32 | {suspended ? ( |
| 33 | <> |
| 34 | <div className="flex h-11 w-11 items-center justify-center rounded-full bg-muted |
| 35 | <ShieldOff className=" |
| 36 | </div> |
| 37 | <div className="flex flex-col gap-1.5 |
| 38 | <p className="text-sm font-semibold text-foreground |
| 39 | <p className="text-xs leading-relaxed text-muted-foreground |
| 40 | {t("suspendedDescription") |
| 41 | </p> |
| 42 | </div> |
| 43 | </> |
| 44 | ) : ( |
| 45 | <div className="flex flex-col gap-1.5 |
| 46 | <p className="text-sm font-semibold text-foreground |
| 47 | <p className="text-xs leading-relaxed text-muted-foreground |
| 48 | {t("installingDescription") |
| 49 | </p> |
| 50 | </div> |
| 51 | )} |
| 52 | </div> |
| 53 | </div> |
| 54 | </div> |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | export default function ServerLayout |
| 59 | children, |
| 60 | params, |
| 61 | }: { |
| 62 | children: React |
| 63 | params: Promise |
| 64 | }) { |
| 65 | const { id |
| 66 | |
| 67 | const { data: |
| 68 | ...orpc.servers. |
| 69 | refetchInterval: (query) |
| 70 | select: (s) |
| 71 | }); |
| 72 | |
| 73 | if (isLoading || |
| 74 | |
| 75 | if (server.status |
| 76 | return <BlockedPage name |
| 77 | } |
| 78 | |
| 79 | if (server.suspended |
| 80 | return <BlockedPage name |
| 81 | } |
| 82 | |
| 83 | return <>{children} |
| 84 | } |