import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"
import { Skeleton } from "@/shared/components/ui/skeleton"

/**
 * 公告列表骨架屏（P2-5 抽取）。
 *
 * 此前用户端 `/announcements/loading.tsx` 与管理端 `/admin/announcements/loading.tsx`
 * 几乎逐行重复，违反"重复超过 90% 必须抽取共享组件"规则。
 */
export function AnnouncementListSkeleton({
  showCreateButton = false,
}: {
  showCreateButton?: boolean
}) {
  return (
    <div className="flex h-full flex-col space-y-8 p-8">
      <div className="flex items-center justify-between space-y-2">
        <div className="space-y-2">
          <Skeleton className="h-8 w-48" />
          <Skeleton className="h-4 w-64" />
        </div>
        {showCreateButton ? <Skeleton className="h-9 w-40" /> : null}
      </div>

      <div className="flex items-center gap-3">
        <Skeleton className="h-9 w-[180px]" />
      </div>

      <div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
        {Array.from({ length: 6 }).map((_, i) => (
          <Card key={i}>
            <CardHeader className="flex flex-row items-start justify-between gap-2 space-y-0">
              <Skeleton className="h-5 w-3/4" />
              <Skeleton className="h-5 w-16" />
            </CardHeader>
            <CardContent className="space-y-2">
              <Skeleton className="h-4 w-full" />
              <Skeleton className="h-4 w-full" />
              <Skeleton className="h-4 w-2/3" />
              <div className="flex items-center gap-2 pt-2">
                <Skeleton className="h-5 w-16" />
                <Skeleton className="h-3 w-32" />
              </div>
            </CardContent>
          </Card>
        ))}
      </div>
    </div>
  )
}
