34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { useTranslation } from "@/components/i18n/locale-provider";
|
|
import { UsersIcon } from "lucide-react";
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { useVisitorPresence } from "@/hooks/use-presence";
|
|
|
|
export function VisitorPresence({ guideId }: { guideId?: string }) {
|
|
const { t } = useTranslation();
|
|
const counts = useVisitorPresence(guideId ?? null);
|
|
return (
|
|
<div className="flex items-center gap-1" aria-live="polite">
|
|
<Badge
|
|
variant="secondary"
|
|
className=" tabular-nums"
|
|
title={t("ผู้เข้าชมทั้งหมดที่กำลังออนไลน์")}
|
|
>
|
|
<UsersIcon data-icon="inline-start" />
|
|
{t("ทั้งหมด")}{" "}{counts?.global ?? "-"}
|
|
</Badge>
|
|
{guideId ? (
|
|
<Badge
|
|
variant="outline"
|
|
className=" tabular-nums"
|
|
title={t("ผู้เข้าชม Guide นี้ที่กำลังออนไลน์")}
|
|
>
|
|
{t("Guide นี้")}{" "}{counts?.guide ?? "-"}
|
|
</Badge>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|