|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { useState } from "react"; |
| 4 | +import PageBreadcrumb from "@/components/Sandboxes/PageBreadcrumb"; |
| 5 | +import ApiDocsLink from "@/components/ApiDocs/ApiDocsLink"; |
| 6 | +import { useSlackTags } from "@/hooks/useSlackTags"; |
| 7 | +import SlackTagsTable from "./SlackTagsTable"; |
| 8 | +import AdminLineChart from "@/components/Admin/AdminLineChart"; |
| 9 | +import { getTagsByDate } from "@/lib/coding-agent/getTagsByDate"; |
| 10 | +import PeriodSelector from "@/components/Admin/PeriodSelector"; |
| 11 | +import TableSkeleton from "@/components/Sandboxes/TableSkeleton"; |
| 12 | +import ChartSkeleton from "@/components/PrivyLogins/ChartSkeleton"; |
| 13 | +import type { AdminPeriod } from "@/types/admin"; |
| 14 | + |
| 15 | +export default function CodingAgentSlackTagsPage() { |
| 16 | + const [period, setPeriod] = useState<AdminPeriod>("all"); |
| 17 | + const { data, isLoading, error } = useSlackTags(period); |
| 18 | + |
| 19 | + return ( |
| 20 | + <main className="mx-auto max-w-6xl px-4 py-10"> |
| 21 | + <div className="mb-6 flex items-start justify-between"> |
| 22 | + <div> |
| 23 | + <PageBreadcrumb current="Coding Agent Tags" /> |
| 24 | + <h1 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-gray-100"> |
| 25 | + Coding Agent Slack Tags |
| 26 | + </h1> |
| 27 | + <p className="mt-1 text-sm text-gray-500 dark:text-gray-400"> |
| 28 | + Slack mentions of the Recoup Coding Agent, pulled directly from the Slack API. |
| 29 | + </p> |
| 30 | + </div> |
| 31 | + <ApiDocsLink path="admins/coding-agent-slack-tags" /> |
| 32 | + </div> |
| 33 | + |
| 34 | + <div className="mb-6 flex items-center gap-4"> |
| 35 | + <PeriodSelector period={period} onPeriodChange={setPeriod} /> |
| 36 | + {data && ( |
| 37 | + <div className="text-sm text-gray-600 dark:text-gray-400"> |
| 38 | + <span className="font-semibold text-gray-900 dark:text-gray-100">{data.total}</span>{" "} |
| 39 | + {data.total === 1 ? "tag" : "tags"} found |
| 40 | + </div> |
| 41 | + )} |
| 42 | + </div> |
| 43 | + |
| 44 | + {isLoading && ( |
| 45 | + <> |
| 46 | + <ChartSkeleton /> |
| 47 | + <TableSkeleton columns={["Tagged By", "Prompt", "Channel", "Timestamp"]} /> |
| 48 | + </> |
| 49 | + )} |
| 50 | + |
| 51 | + {error && ( |
| 52 | + <div className="rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/20 dark:text-red-400"> |
| 53 | + {error instanceof Error ? error.message : "Failed to load Slack tags"} |
| 54 | + </div> |
| 55 | + )} |
| 56 | + |
| 57 | + {!isLoading && !error && data && data.tags.length === 0 && ( |
| 58 | + <div className="flex items-center justify-center py-12 text-sm text-gray-400"> |
| 59 | + No tags found for this period. |
| 60 | + </div> |
| 61 | + )} |
| 62 | + |
| 63 | + {!isLoading && !error && data && data.tags.length > 0 && ( |
| 64 | + <> |
| 65 | + <AdminLineChart title="Tags Over Time" data={getTagsByDate(data.tags)} label="Tags" /> |
| 66 | + <SlackTagsTable tags={data.tags} /> |
| 67 | + </> |
| 68 | + )} |
| 69 | + </main> |
| 70 | + ); |
| 71 | +} |
0 commit comments