fix:优化数据
This commit is contained in:
@@ -2,27 +2,63 @@
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import {
|
||||
FileText,
|
||||
FolderArchive,
|
||||
Settings,
|
||||
Building2,
|
||||
Globe,
|
||||
PiggyBank,
|
||||
FileStack,
|
||||
Settings2,
|
||||
} from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { HistoricalReferences } from "@/components/historical-references";
|
||||
|
||||
const QUICK_LINKS = [
|
||||
{ label: "国家税务总局门户", href: "https://www.chinatax.gov.cn", icon: Building2 },
|
||||
{ label: "电子税务局", href: "https://etax.chinatax.gov.cn", icon: Globe },
|
||||
{ label: "公积金管理中心", href: "https://www.12329.com.cn", icon: PiggyBank },
|
||||
];
|
||||
import { cloudDocsApi, portalLinksApi, type CloudDocLinkRead, type PortalLinkRead } from "@/lib/api/client";
|
||||
|
||||
export function AppSidebar() {
|
||||
const pathname = usePathname();
|
||||
const [cloudDocs, setCloudDocs] = useState<CloudDocLinkRead[]>([]);
|
||||
const [portalLinks, setPortalLinks] = useState<PortalLinkRead[]>([]);
|
||||
|
||||
const loadCloudDocs = useCallback(async () => {
|
||||
try {
|
||||
const list = await cloudDocsApi.list();
|
||||
setCloudDocs(list);
|
||||
} catch {
|
||||
setCloudDocs([]);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadCloudDocs();
|
||||
}, [loadCloudDocs]);
|
||||
|
||||
useEffect(() => {
|
||||
const onCloudDocsChanged = () => loadCloudDocs();
|
||||
window.addEventListener("cloud-docs-changed", onCloudDocsChanged);
|
||||
return () => window.removeEventListener("cloud-docs-changed", onCloudDocsChanged);
|
||||
}, [loadCloudDocs]);
|
||||
|
||||
const loadPortalLinks = useCallback(async () => {
|
||||
try {
|
||||
const list = await portalLinksApi.list();
|
||||
setPortalLinks(list);
|
||||
} catch {
|
||||
setPortalLinks([]);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadPortalLinks();
|
||||
}, [loadPortalLinks]);
|
||||
|
||||
useEffect(() => {
|
||||
const onPortalLinksChanged = () => loadPortalLinks();
|
||||
window.addEventListener("portal-links-changed", onPortalLinksChanged);
|
||||
return () => window.removeEventListener("portal-links-changed", onPortalLinksChanged);
|
||||
}, [loadPortalLinks]);
|
||||
|
||||
const nav = [
|
||||
{ href: "/workspace", label: "需求与方案", icon: FileText },
|
||||
@@ -54,25 +90,70 @@ export function AppSidebar() {
|
||||
))}
|
||||
</nav>
|
||||
<Separator />
|
||||
<div className="p-2">
|
||||
<p className="text-xs font-medium text-muted-foreground px-2 mb-2">
|
||||
快捷门户
|
||||
</p>
|
||||
<div className="flex flex-col gap-1">
|
||||
{QUICK_LINKS.map((link) => (
|
||||
<a
|
||||
key={link.href}
|
||||
href={link.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
"flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
||||
)}
|
||||
<div className="flex-1 min-h-0 overflow-y-auto flex flex-col">
|
||||
<div className="p-2 shrink-0">
|
||||
<div className="flex items-center justify-between px-2 mb-2">
|
||||
<p className="text-xs font-medium text-muted-foreground">云文档</p>
|
||||
<Link
|
||||
href="/settings/cloud-docs"
|
||||
className="text-xs text-muted-foreground hover:text-foreground"
|
||||
title="管理云文档入口"
|
||||
>
|
||||
<link.icon className="h-4 w-4 shrink-0" />
|
||||
{link.label}
|
||||
</a>
|
||||
))}
|
||||
<Settings2 className="h-3.5 w-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
{cloudDocs.length === 0 ? (
|
||||
<p className="text-xs text-muted-foreground px-2">暂无入口,去设置添加</p>
|
||||
) : (
|
||||
cloudDocs.map((doc) => (
|
||||
<a
|
||||
key={doc.id}
|
||||
href={doc.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
"flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
||||
)}
|
||||
>
|
||||
<FileStack className="h-4 w-4 shrink-0" />
|
||||
<span className="truncate">{doc.name}</span>
|
||||
</a>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-2 shrink-0">
|
||||
<div className="flex items-center justify-between px-2 mb-2">
|
||||
<p className="text-xs font-medium text-muted-foreground">快捷门户</p>
|
||||
<Link
|
||||
href="/settings/portal-links"
|
||||
className="text-xs text-muted-foreground hover:text-foreground"
|
||||
title="管理快捷门户"
|
||||
>
|
||||
<Settings2 className="h-3.5 w-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
{portalLinks.length === 0 ? (
|
||||
<p className="text-xs text-muted-foreground px-2">暂无入口,去设置添加</p>
|
||||
) : (
|
||||
portalLinks.map((link) => (
|
||||
<a
|
||||
key={link.id}
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
"flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
||||
)}
|
||||
>
|
||||
<Globe className="h-4 w-4 shrink-0" />
|
||||
<span className="truncate">{link.name}</span>
|
||||
</a>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{pathname === "/workspace" && <HistoricalReferences />}
|
||||
|
||||
@@ -1,22 +1,59 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useState, useEffect, useCallback, useMemo } from "react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { listProjects, type ProjectRead } from "@/lib/api/client";
|
||||
import { Copy, Search, FileText } from "lucide-react";
|
||||
import {
|
||||
listProjects,
|
||||
projectsApi,
|
||||
type ProjectRead,
|
||||
} from "@/lib/api/client";
|
||||
import { Copy, Search, FileText, Eye, Pencil, Loader2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
|
||||
function parseTags(tagsStr: string | null | undefined): string[] {
|
||||
if (!tagsStr?.trim()) return [];
|
||||
return tagsStr
|
||||
.split(",")
|
||||
.map((t) => t.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
export function HistoricalReferences() {
|
||||
const [projects, setProjects] = useState<ProjectRead[]>([]);
|
||||
const [search, setSearch] = useState("");
|
||||
const [selectedTag, setSelectedTag] = useState<string>("");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [previewProject, setPreviewProject] = useState<ProjectRead | null>(null);
|
||||
const [editProject, setEditProject] = useState<ProjectRead | null>(null);
|
||||
const [editRaw, setEditRaw] = useState("");
|
||||
const [editMd, setEditMd] = useState("");
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await listProjects();
|
||||
const data = await listProjects(
|
||||
selectedTag ? { customer_tag: selectedTag } : undefined
|
||||
);
|
||||
setProjects(data);
|
||||
} catch (e) {
|
||||
toast.error("加载历史项目失败");
|
||||
@@ -24,19 +61,32 @@ export function HistoricalReferences() {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
}, [selectedTag]);
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, [load]);
|
||||
|
||||
const filtered = search.trim()
|
||||
? projects.filter(
|
||||
const allTags = useMemo(() => {
|
||||
const set = new Set<string>();
|
||||
projects.forEach((p) =>
|
||||
parseTags(p.customer?.tags ?? null).forEach((t) => set.add(t))
|
||||
);
|
||||
return Array.from(set).sort();
|
||||
}, [projects]);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
let list = projects;
|
||||
if (search.trim()) {
|
||||
const q = search.toLowerCase();
|
||||
list = list.filter(
|
||||
(p) =>
|
||||
p.raw_requirement.toLowerCase().includes(search.toLowerCase()) ||
|
||||
(p.ai_solution_md || "").toLowerCase().includes(search.toLowerCase())
|
||||
)
|
||||
: projects.slice(0, 10);
|
||||
p.raw_requirement.toLowerCase().includes(q) ||
|
||||
(p.ai_solution_md || "").toLowerCase().includes(q)
|
||||
);
|
||||
}
|
||||
return list.slice(0, 20);
|
||||
}, [projects, search]);
|
||||
|
||||
const copySnippet = (text: string, label: string) => {
|
||||
if (!text) return;
|
||||
@@ -44,20 +94,67 @@ export function HistoricalReferences() {
|
||||
toast.success(`已复制 ${label}`);
|
||||
};
|
||||
|
||||
const openPreview = (p: ProjectRead) => setPreviewProject(p);
|
||||
const openEdit = (p: ProjectRead) => {
|
||||
setEditProject(p);
|
||||
setEditRaw(p.raw_requirement);
|
||||
setEditMd(p.ai_solution_md || "");
|
||||
};
|
||||
|
||||
const handleSaveEdit = async () => {
|
||||
if (!editProject) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
await projectsApi.update(editProject.id, {
|
||||
raw_requirement: editRaw,
|
||||
ai_solution_md: editMd || null,
|
||||
});
|
||||
toast.success("已保存");
|
||||
setEditProject(null);
|
||||
load();
|
||||
} catch (e) {
|
||||
toast.error("保存失败");
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="border-t p-2">
|
||||
<p className="text-xs font-medium text-muted-foreground px-2 mb-2 flex items-center gap-1">
|
||||
<FileText className="h-3.5 w-3.5" />
|
||||
历史参考
|
||||
</p>
|
||||
<div className="relative mb-2">
|
||||
<Search className="absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="搜索项目..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="h-8 pl-7 text-xs"
|
||||
/>
|
||||
<div className="space-y-2 mb-2">
|
||||
<div className="flex gap-1 items-center">
|
||||
<Select
|
||||
value={selectedTag || "__all__"}
|
||||
onValueChange={(v) => setSelectedTag(v === "__all__" ? "" : v)}
|
||||
>
|
||||
<SelectTrigger className="h-8 text-xs flex-1">
|
||||
<SelectValue placeholder="按标签收纳" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="__all__" className="text-xs">
|
||||
全部
|
||||
</SelectItem>
|
||||
{allTags.map((t) => (
|
||||
<SelectItem key={t} value={t} className="text-xs">
|
||||
{t}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<Search className="absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="搜索项目..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="h-8 pl-7 text-xs"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-h-48 overflow-y-auto space-y-1">
|
||||
{loading ? (
|
||||
@@ -72,20 +169,43 @@ export function HistoricalReferences() {
|
||||
"rounded border bg-background/50 p-2 text-xs space-y-1"
|
||||
)}
|
||||
>
|
||||
<p className="font-medium text-foreground line-clamp-1">
|
||||
项目 #{p.id}
|
||||
<p className="font-medium text-foreground line-clamp-1 flex items-center justify-between gap-1">
|
||||
<span>项目 #{p.id}</span>
|
||||
{p.customer?.tags && (
|
||||
<span className="text-muted-foreground font-normal truncate max-w-[60%]">
|
||||
{parseTags(p.customer.tags).slice(0, 2).join(", ")}
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
<p className="text-muted-foreground line-clamp-2">
|
||||
{p.raw_requirement.slice(0, 80)}…
|
||||
</p>
|
||||
<div className="flex gap-1 pt-1">
|
||||
<div className="flex flex-wrap gap-1 pt-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-1.5 text-xs"
|
||||
onClick={() =>
|
||||
copySnippet(p.raw_requirement, "原始需求")
|
||||
}
|
||||
onClick={() => openPreview(p)}
|
||||
title="预览"
|
||||
>
|
||||
<Eye className="h-3 w-3 mr-0.5" />
|
||||
预览
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-1.5 text-xs"
|
||||
onClick={() => openEdit(p)}
|
||||
title="编辑"
|
||||
>
|
||||
<Pencil className="h-3 w-3 mr-0.5" />
|
||||
编辑
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-1.5 text-xs"
|
||||
onClick={() => copySnippet(p.raw_requirement, "原始需求")}
|
||||
>
|
||||
<Copy className="h-3 w-3 mr-0.5" />
|
||||
需求
|
||||
@@ -94,9 +214,7 @@ export function HistoricalReferences() {
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-1.5 text-xs"
|
||||
onClick={() =>
|
||||
copySnippet(p.ai_solution_md || "", "方案")
|
||||
}
|
||||
onClick={() => copySnippet(p.ai_solution_md || "", "方案")}
|
||||
>
|
||||
<Copy className="h-3 w-3 mr-0.5" />
|
||||
方案
|
||||
@@ -106,6 +224,80 @@ export function HistoricalReferences() {
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 预览弹窗 */}
|
||||
<Dialog open={!!previewProject} onOpenChange={() => setPreviewProject(null)}>
|
||||
<DialogContent className="max-w-2xl max-h-[85vh] overflow-hidden flex flex-col">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
项目 #{previewProject?.id}
|
||||
{previewProject?.customer?.name && (
|
||||
<span className="text-sm font-normal text-muted-foreground ml-2">
|
||||
{previewProject.customer.name}
|
||||
</span>
|
||||
)}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Tabs defaultValue="requirement" className="flex-1 min-h-0 flex flex-col overflow-hidden">
|
||||
<TabsList>
|
||||
<TabsTrigger value="requirement">原始需求</TabsTrigger>
|
||||
<TabsTrigger value="solution">方案</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="requirement" className="mt-2 overflow-auto flex-1 min-h-0">
|
||||
<pre className="text-xs whitespace-pre-wrap bg-muted/50 p-3 rounded-md">
|
||||
{previewProject?.raw_requirement ?? ""}
|
||||
</pre>
|
||||
</TabsContent>
|
||||
<TabsContent value="solution" className="mt-2 overflow-auto flex-1 min-h-0">
|
||||
<div className="prose prose-sm dark:prose-invert max-w-none p-2">
|
||||
{previewProject?.ai_solution_md ? (
|
||||
<ReactMarkdown>{previewProject.ai_solution_md}</ReactMarkdown>
|
||||
) : (
|
||||
<p className="text-muted-foreground">暂无方案</p>
|
||||
)}
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* 二次编辑弹窗 */}
|
||||
<Dialog open={!!editProject} onOpenChange={() => !saving && setEditProject(null)}>
|
||||
<DialogContent className="max-w-2xl max-h-[85vh] overflow-hidden flex flex-col">
|
||||
<DialogHeader>
|
||||
<DialogTitle>编辑 项目 #{editProject?.id}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-2 flex-1 min-h-0 overflow-auto">
|
||||
<div className="grid gap-2">
|
||||
<Label>原始需求</Label>
|
||||
<textarea
|
||||
className="min-h-[120px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm font-mono resize-none"
|
||||
value={editRaw}
|
||||
onChange={(e) => setEditRaw(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>方案 (Markdown)</Label>
|
||||
<textarea
|
||||
className="min-h-[180px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm font-mono resize-none"
|
||||
value={editMd}
|
||||
onChange={(e) => setEditMd(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setEditProject(null)} disabled={saving}>
|
||||
取消
|
||||
</Button>
|
||||
<Button onClick={handleSaveEdit} disabled={saving}>
|
||||
{saving ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin mr-2" />
|
||||
) : null}
|
||||
保存
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
119
frontend/components/ui/dialog.tsx
Normal file
119
frontend/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,119 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||
import { X } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Dialog = DialogPrimitive.Root;
|
||||
const DialogTrigger = DialogPrimitive.Trigger;
|
||||
const DialogPortal = DialogPrimitive.Portal;
|
||||
const DialogClose = DialogPrimitive.Close;
|
||||
|
||||
const DialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
||||
showCloseButton?: boolean;
|
||||
}
|
||||
>(({ className, children, showCloseButton = true, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{showCloseButton && (
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
));
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
||||
|
||||
const DialogHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
DialogHeader.displayName = "DialogHeader";
|
||||
|
||||
const DialogFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
DialogFooter.displayName = "DialogFooter";
|
||||
|
||||
const DialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
||||
|
||||
const DialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogClose,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogFooter,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
};
|
||||
80
frontend/components/ui/table.tsx
Normal file
80
frontend/components/ui/table.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Table = React.forwardRef<
|
||||
HTMLTableElement,
|
||||
React.HTMLAttributes<HTMLTableElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div className="relative w-full overflow-auto">
|
||||
<table
|
||||
ref={ref}
|
||||
className={cn("w-full caption-bottom text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
));
|
||||
Table.displayName = "Table";
|
||||
|
||||
const TableHeader = React.forwardRef<
|
||||
HTMLTableSectionElement,
|
||||
React.HTMLAttributes<HTMLTableSectionElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
||||
));
|
||||
TableHeader.displayName = "TableHeader";
|
||||
|
||||
const TableBody = React.forwardRef<
|
||||
HTMLTableSectionElement,
|
||||
React.HTMLAttributes<HTMLTableSectionElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<tbody
|
||||
ref={ref}
|
||||
className={cn("[&_tr:last-child]:border-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TableBody.displayName = "TableBody";
|
||||
|
||||
const TableRow = React.forwardRef<
|
||||
HTMLTableRowElement,
|
||||
React.HTMLAttributes<HTMLTableRowElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<tr
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TableRow.displayName = "TableRow";
|
||||
|
||||
const TableHead = React.forwardRef<
|
||||
HTMLTableCellElement,
|
||||
React.ThHTMLAttributes<HTMLTableCellElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<th
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TableHead.displayName = "TableHead";
|
||||
|
||||
const TableCell = React.forwardRef<
|
||||
HTMLTableCellElement,
|
||||
React.TdHTMLAttributes<HTMLTableCellElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<td
|
||||
ref={ref}
|
||||
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
TableCell.displayName = "TableCell";
|
||||
|
||||
export { Table, TableHeader, TableBody, TableRow, TableHead, TableCell };
|
||||
Reference in New Issue
Block a user