Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const YTAuthButton = () => {
<span className="flex gap-2 items-center">
<p>{session.data.user.name}</p>
<BroadcastStatus />
<HealthStatus />
</span>
<Button variant="ghost" type="button" onClick={handleSignOut}>
Sign out
Expand Down Expand Up @@ -165,6 +166,58 @@ const BroadcastStatus = () => {
);
};

const HealthStatus = () => {
const { data, isLoading } = useQuery({
queryKey: ["livestream", "health"],
queryFn: () => fetch("/livestream/health").then((res) => res.json()),
});

if (isLoading || !data) return null;

const getHealthIcon = (status: string) => {
switch (status) {
case "good":
return "🟒";
case "ok":
return "🟑";
case "bad":
return "πŸ”΄";
case "noData":
return "βšͺ";
case "revoked":
return "❌";
default:
return "βšͺ";
}
};

const getHealthColor = (status: string) => {
switch (status) {
case "good":
return "text-green-600";
case "ok":
return "text-yellow-600";
case "bad":
return "text-red-600";
case "noData":
return "text-gray-500";
case "revoked":
return "text-red-800";
default:
return "text-gray-500";
}
};

return (
<span className="flex items-center gap-1">
<p>{getHealthIcon(data.healthStatus)}</p>
<p className={`text-sm ${getHealthColor(data.healthStatus)} uppercase`}>
health: {data.healthStatus}
</p>
</span>
);
};

const StreamKey = () => {
const [show, setShow] = useState(false);
const [copied, setCopied] = useState(false);
Expand Down
20 changes: 10 additions & 10 deletions src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
Expand Down Expand Up @@ -32,8 +32,8 @@ const buttonVariants = cva(
variant: "default",
size: "default",
},
}
)
},
);

function Button({
className,
Expand All @@ -43,17 +43,17 @@ function Button({
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
asChild?: boolean;
}) {
const Comp = asChild ? Slot : "button"
const Comp = asChild ? Slot : "button";

return (
<Comp
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
);
}

export { Button, buttonVariants }
export { Button, buttonVariants };
26 changes: 13 additions & 13 deletions src/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as React from "react"
import * as React from "react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
className
className,
)}
{...props}
/>
)
);
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -21,11 +21,11 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className
className,
)}
{...props}
/>
)
);
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -35,7 +35,7 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
className={cn("leading-none font-semibold", className)}
{...props}
/>
)
);
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -45,7 +45,7 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
);
}

function CardAction({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -54,11 +54,11 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
className,
)}
{...props}
/>
)
);
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -68,7 +68,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
className={cn("px-6", className)}
{...props}
/>
)
);
}

function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -78,7 +78,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
)
);
}

export {
Expand All @@ -89,4 +89,4 @@ export {
CardAction,
CardDescription,
CardContent,
}
};
10 changes: 5 additions & 5 deletions src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react"
import * as React from "react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
Expand All @@ -11,11 +11,11 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
className
className,
)}
{...props}
/>
)
);
}

export { Input }
export { Input };
10 changes: 5 additions & 5 deletions src/components/ui/textarea.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as React from "react"
import * as React from "react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
return (
<textarea
data-slot="textarea"
className={cn(
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
className,
)}
{...props}
/>
)
);
}

export { Textarea }
export { Textarea };
Loading