|
| 1 | +import type { ReactNode } from "react"; |
1 | 2 | import { IllustrationEmptyInbox } from "@/components/illustrations/illustration-empty-inbox"; |
2 | 3 | import { IllustrationNoSearchResults } from "@/components/illustrations/illustration-no-search-results"; |
3 | | -import { Button } from "@/components/ui/button"; |
4 | 4 |
|
5 | | -interface NoServersEmptyStateProps { |
6 | | - variant: "no-servers"; |
| 5 | +interface EmptyStateProps { |
| 6 | + variant: "no-servers" | "no-results"; |
| 7 | + title: string; |
| 8 | + description: string; |
| 9 | + actions?: ReactNode; |
7 | 10 | } |
8 | 11 |
|
9 | | -interface NoResultsEmptyStateProps { |
10 | | - variant: "no-results"; |
11 | | - searchQuery: string; |
12 | | - onClearSearch: () => void; |
13 | | -} |
14 | | - |
15 | | -type EmptyStateProps = NoServersEmptyStateProps | NoResultsEmptyStateProps; |
16 | | - |
17 | | -export function EmptyState(props: EmptyStateProps) { |
18 | | - const isNoResults = props.variant === "no-results"; |
19 | | - |
| 12 | +export function EmptyState({ |
| 13 | + variant, |
| 14 | + title, |
| 15 | + description, |
| 16 | + actions, |
| 17 | +}: EmptyStateProps) { |
20 | 18 | return ( |
21 | 19 | <div className="flex items-center justify-center py-20"> |
22 | 20 | <div className="flex flex-col items-center text-center gap-4 max-w-md"> |
23 | | - {isNoResults ? ( |
| 21 | + {variant === "no-results" ? ( |
24 | 22 | <IllustrationNoSearchResults className="size-32" /> |
25 | 23 | ) : ( |
26 | 24 | <IllustrationEmptyInbox className="size-32" /> |
27 | 25 | )} |
28 | 26 |
|
29 | 27 | <div className="space-y-2"> |
30 | | - <h2 className="text-xl font-semibold tracking-tight"> |
31 | | - {isNoResults ? "No results found" : "No servers available"} |
32 | | - </h2> |
33 | | - <p className="text-muted-foreground"> |
34 | | - {isNoResults |
35 | | - ? `We couldn't find any servers matching "${props.searchQuery}". Try adjusting your search.` |
36 | | - : "There are no MCP servers in the catalog yet. Check back later."} |
37 | | - </p> |
| 28 | + <h2 className="text-xl font-semibold tracking-tight">{title}</h2> |
| 29 | + <p className="text-muted-foreground">{description}</p> |
38 | 30 | </div> |
39 | 31 |
|
40 | | - {isNoResults && ( |
41 | | - <div className="flex gap-2 mt-2"> |
42 | | - <Button variant="outline" onClick={props.onClearSearch}> |
43 | | - Clear search |
44 | | - </Button> |
45 | | - </div> |
46 | | - )} |
| 32 | + {actions} |
47 | 33 | </div> |
48 | 34 | </div> |
49 | 35 | ); |
|
0 commit comments