-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstored-recommendations-dialog.tsx
More file actions
99 lines (92 loc) · 2.72 KB
/
Copy pathstored-recommendations-dialog.tsx
File metadata and controls
99 lines (92 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"use client";
import * as React from "react";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog";
import { DataTable } from "../data-table";
import { columns } from "./columns";
import { InfoItem } from "../core/InfoItem";
interface RecommendationsDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
suggestions: RecommendationItem[];
onApplySuggestion: (data: {
concept: number;
object_id: number;
content_type: string;
creation_type: string;
table_id: string;
}) => void;
searchedValue: string;
tableId: string;
rowId: number;
domainId: string;
contentType: string;
source: "unison" | "v3";
}
// Shared dialog component for both Unison and V3 recommendations
export default function RecommendationsDialog({
open,
onOpenChange,
suggestions,
onApplySuggestion,
searchedValue,
tableId,
rowId,
domainId,
contentType,
source,
}: RecommendationsDialogProps) {
const getSourceLabel = () => {
return source === "v3"
? "Stored Mapping Recommendations"
: "Live Mapping Recommendations";
};
const getSourceDescription = () => {
return source === "v3"
? "Pre-computed mapping recommendations from the database"
: "Mapping recommendations";
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-screen-xl overflow-auto max-h-[80vh]">
<DialogHeader>
<DialogTitle className="text-xl text-center">
{getSourceLabel()}
</DialogTitle>
<div className="flex flex-col md:flex-row md:items-center h-7 justify-center space-y-2 md:space-y-0 divide-y md:divide-y-0 md:divide-x divide-gray-300">
<InfoItem
label="Value queried"
value={searchedValue}
className="py-1 md:py-0 md:pr-3"
/>
{source === "unison" && (
<InfoItem
label="Domain Chosen"
value={domainId}
className="py-1 md:py-0 md:px-3"
/>
)}
<InfoItem
label="Source"
value={getSourceDescription()}
className="py-1 md:py-0 md:px-3"
/>
</div>
</DialogHeader>
{suggestions.length > 0 ? (
<DataTable
columns={columns(tableId, rowId, onApplySuggestion, contentType)}
data={suggestions}
count={suggestions.length}
paginated={false}
viewColumns={false}
overflow={false}
/>
) : (
<div className="text-center py-8 text-gray-500">
No recommendations found
</div>
)}
</DialogContent>
</Dialog>
);
}