@optifye/dashboard-core 4.2.9 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.js +521 -21
- package/dist/index.mjs +518 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2109,28 +2109,42 @@ var AuthProvider = ({ children }) => {
|
|
|
2109
2109
|
id: supabaseUser.id,
|
|
2110
2110
|
email: supabaseUser.email
|
|
2111
2111
|
};
|
|
2112
|
-
if (!
|
|
2112
|
+
if (!supabase) return basicUser;
|
|
2113
2113
|
try {
|
|
2114
2114
|
const timeoutPromise = new Promise(
|
|
2115
2115
|
(_, reject) => setTimeout(() => reject(new Error("Profile fetch timeout")), 5e3)
|
|
2116
2116
|
);
|
|
2117
|
-
const
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2117
|
+
const rolePromise = supabase.from("user_roles").select("role_level").eq("user_id", supabaseUser.id).single();
|
|
2118
|
+
let profilePromise = null;
|
|
2119
|
+
if (userProfileTable) {
|
|
2120
|
+
profilePromise = supabase.from(userProfileTable).select(roleColumn).eq("id", supabaseUser.id).single();
|
|
2121
|
+
}
|
|
2122
|
+
const [roleResult, profileResult] = await Promise.race([
|
|
2123
|
+
Promise.all([
|
|
2124
|
+
rolePromise,
|
|
2125
|
+
profilePromise || Promise.resolve(null)
|
|
2126
|
+
]),
|
|
2127
|
+
timeoutPromise.then(() => {
|
|
2128
|
+
throw new Error("Timeout");
|
|
2129
|
+
})
|
|
2121
2130
|
]);
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
console.error("Error fetching user profile:", profileError);
|
|
2128
|
-
return basicUser;
|
|
2131
|
+
let roleLevel = void 0;
|
|
2132
|
+
if (roleResult && !roleResult.error && roleResult.data) {
|
|
2133
|
+
roleLevel = roleResult.data.role_level;
|
|
2134
|
+
} else if (roleResult?.error) {
|
|
2135
|
+
console.log("Error fetching role_level:", roleResult.error.message);
|
|
2129
2136
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2137
|
+
let roleValue = void 0;
|
|
2138
|
+
if (profileResult && !profileResult.error && profileResult.data) {
|
|
2139
|
+
roleValue = profileResult.data[roleColumn];
|
|
2140
|
+
}
|
|
2141
|
+
return {
|
|
2142
|
+
...basicUser,
|
|
2143
|
+
role: roleValue,
|
|
2144
|
+
role_level: roleLevel
|
|
2145
|
+
};
|
|
2132
2146
|
} catch (err) {
|
|
2133
|
-
console.error("Error fetching user
|
|
2147
|
+
console.error("Error fetching user details:", err);
|
|
2134
2148
|
return basicUser;
|
|
2135
2149
|
}
|
|
2136
2150
|
}, [supabase, userProfileTable, roleColumn]);
|
|
@@ -2165,7 +2179,8 @@ var AuthProvider = ({ children }) => {
|
|
|
2165
2179
|
email: userDetails.email,
|
|
2166
2180
|
name: userDetails.email,
|
|
2167
2181
|
// using email as the display name for now
|
|
2168
|
-
role: userDetails.role
|
|
2182
|
+
role: userDetails.role,
|
|
2183
|
+
role_level: userDetails.role_level
|
|
2169
2184
|
});
|
|
2170
2185
|
}
|
|
2171
2186
|
}
|
|
@@ -2203,7 +2218,8 @@ var AuthProvider = ({ children }) => {
|
|
|
2203
2218
|
identifyCoreUser(userDetails.id, {
|
|
2204
2219
|
email: userDetails.email,
|
|
2205
2220
|
name: userDetails.email,
|
|
2206
|
-
role: userDetails.role
|
|
2221
|
+
role: userDetails.role,
|
|
2222
|
+
role_level: userDetails.role_level
|
|
2207
2223
|
});
|
|
2208
2224
|
}
|
|
2209
2225
|
}
|
|
@@ -17989,6 +18005,187 @@ var SOPComplianceChart = ({
|
|
|
17989
18005
|
renderLegend()
|
|
17990
18006
|
] });
|
|
17991
18007
|
};
|
|
18008
|
+
var GaugeChart = ({
|
|
18009
|
+
value,
|
|
18010
|
+
min,
|
|
18011
|
+
max,
|
|
18012
|
+
target,
|
|
18013
|
+
label,
|
|
18014
|
+
unit = "",
|
|
18015
|
+
thresholds,
|
|
18016
|
+
className = ""
|
|
18017
|
+
}) => {
|
|
18018
|
+
const normalizedValue = (value - min) / (max - min) * 100;
|
|
18019
|
+
const clampedValue = Math.max(0, Math.min(100, normalizedValue));
|
|
18020
|
+
const data = [
|
|
18021
|
+
{ name: "value", value: clampedValue },
|
|
18022
|
+
{ name: "empty", value: 100 - clampedValue }
|
|
18023
|
+
];
|
|
18024
|
+
const getColor = () => {
|
|
18025
|
+
if (thresholds && thresholds.length > 0) {
|
|
18026
|
+
const sortedThresholds = [...thresholds].sort((a, b) => a.value - b.value);
|
|
18027
|
+
for (let i = sortedThresholds.length - 1; i >= 0; i--) {
|
|
18028
|
+
if (value >= sortedThresholds[i].value) {
|
|
18029
|
+
return sortedThresholds[i].color;
|
|
18030
|
+
}
|
|
18031
|
+
}
|
|
18032
|
+
return sortedThresholds[0].color;
|
|
18033
|
+
}
|
|
18034
|
+
if (clampedValue < 33) return "#ef4444";
|
|
18035
|
+
if (clampedValue < 66) return "#f59e0b";
|
|
18036
|
+
return "#10b981";
|
|
18037
|
+
};
|
|
18038
|
+
const gaugeColor = getColor();
|
|
18039
|
+
const targetAngle = target !== void 0 ? 180 - (target - min) / (max - min) * 180 : null;
|
|
18040
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `relative w-full h-full flex flex-col items-center justify-center ${className}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full max-w-[280px] aspect-square", children: [
|
|
18041
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.PieChart, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18042
|
+
recharts.Pie,
|
|
18043
|
+
{
|
|
18044
|
+
data,
|
|
18045
|
+
cx: "50%",
|
|
18046
|
+
cy: "50%",
|
|
18047
|
+
startAngle: 180,
|
|
18048
|
+
endAngle: 0,
|
|
18049
|
+
innerRadius: "65%",
|
|
18050
|
+
outerRadius: "85%",
|
|
18051
|
+
paddingAngle: 0,
|
|
18052
|
+
dataKey: "value",
|
|
18053
|
+
animationBegin: 0,
|
|
18054
|
+
animationDuration: 1e3,
|
|
18055
|
+
animationEasing: "ease-out",
|
|
18056
|
+
children: [
|
|
18057
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Cell, { fill: gaugeColor }),
|
|
18058
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Cell, { fill: "#f3f4f6" })
|
|
18059
|
+
]
|
|
18060
|
+
}
|
|
18061
|
+
) }) }),
|
|
18062
|
+
targetAngle !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
18063
|
+
"div",
|
|
18064
|
+
{
|
|
18065
|
+
className: "absolute top-1/2 left-1/2 w-1 h-[42%] bg-gray-800 origin-bottom",
|
|
18066
|
+
style: {
|
|
18067
|
+
transform: `translate(-50%, -100%) rotate(${targetAngle}deg)`,
|
|
18068
|
+
transition: "transform 0.3s ease-out"
|
|
18069
|
+
},
|
|
18070
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -top-1 -left-1.5 w-3 h-3 bg-gray-800 rounded-full" })
|
|
18071
|
+
}
|
|
18072
|
+
),
|
|
18073
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
18074
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-3xl font-bold text-gray-800", children: [
|
|
18075
|
+
value.toFixed(unit === "%" ? 1 : 0),
|
|
18076
|
+
unit
|
|
18077
|
+
] }),
|
|
18078
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-600 mt-1 font-medium", children: label }),
|
|
18079
|
+
target !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-500 mt-1", children: [
|
|
18080
|
+
"Target: ",
|
|
18081
|
+
target,
|
|
18082
|
+
unit
|
|
18083
|
+
] })
|
|
18084
|
+
] }) }),
|
|
18085
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute bottom-[15%] left-[15%] text-xs text-gray-500", children: [
|
|
18086
|
+
min,
|
|
18087
|
+
unit
|
|
18088
|
+
] }),
|
|
18089
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute bottom-[15%] right-[15%] text-xs text-gray-500", children: [
|
|
18090
|
+
max,
|
|
18091
|
+
unit
|
|
18092
|
+
] })
|
|
18093
|
+
] }) });
|
|
18094
|
+
};
|
|
18095
|
+
var DEFAULT_COLORS = [
|
|
18096
|
+
"#3b82f6",
|
|
18097
|
+
// blue-500
|
|
18098
|
+
"#10b981",
|
|
18099
|
+
// green-500
|
|
18100
|
+
"#f59e0b",
|
|
18101
|
+
// amber-500
|
|
18102
|
+
"#ef4444",
|
|
18103
|
+
// red-500
|
|
18104
|
+
"#8b5cf6",
|
|
18105
|
+
// violet-500
|
|
18106
|
+
"#06b6d4",
|
|
18107
|
+
// cyan-500
|
|
18108
|
+
"#f97316",
|
|
18109
|
+
// orange-500
|
|
18110
|
+
"#6366f1"
|
|
18111
|
+
// indigo-500
|
|
18112
|
+
];
|
|
18113
|
+
var PieChart4 = ({
|
|
18114
|
+
data,
|
|
18115
|
+
className = "",
|
|
18116
|
+
showPercentages = false,
|
|
18117
|
+
colors = DEFAULT_COLORS
|
|
18118
|
+
}) => {
|
|
18119
|
+
const total = data.reduce((sum, entry) => sum + entry.value, 0);
|
|
18120
|
+
const dataWithPercentage = data.map((entry) => ({
|
|
18121
|
+
...entry,
|
|
18122
|
+
percentage: (entry.value / total * 100).toFixed(1)
|
|
18123
|
+
}));
|
|
18124
|
+
const renderCustomLabel = (props) => {
|
|
18125
|
+
if (!showPercentages) return null;
|
|
18126
|
+
const { cx: cx2, cy, midAngle, innerRadius, outerRadius, percentage } = props;
|
|
18127
|
+
const RADIAN = Math.PI / 180;
|
|
18128
|
+
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
18129
|
+
const x = cx2 + radius * Math.cos(-midAngle * RADIAN);
|
|
18130
|
+
const y = cy + radius * Math.sin(-midAngle * RADIAN);
|
|
18131
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18132
|
+
"text",
|
|
18133
|
+
{
|
|
18134
|
+
x,
|
|
18135
|
+
y,
|
|
18136
|
+
fill: "white",
|
|
18137
|
+
textAnchor: x > cx2 ? "start" : "end",
|
|
18138
|
+
dominantBaseline: "central",
|
|
18139
|
+
className: "text-xs font-medium",
|
|
18140
|
+
children: [
|
|
18141
|
+
percentage,
|
|
18142
|
+
"%"
|
|
18143
|
+
]
|
|
18144
|
+
}
|
|
18145
|
+
);
|
|
18146
|
+
};
|
|
18147
|
+
const CustomTooltip = ({ active, payload }) => {
|
|
18148
|
+
if (active && payload && payload.length) {
|
|
18149
|
+
const data2 = payload[0];
|
|
18150
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white px-3 py-2 shadow-lg rounded-lg border border-gray-200", children: [
|
|
18151
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-900", children: data2.name }),
|
|
18152
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-600", children: [
|
|
18153
|
+
"Value: ",
|
|
18154
|
+
data2.value,
|
|
18155
|
+
showPercentages && ` (${data2.payload.percentage}%)`
|
|
18156
|
+
] })
|
|
18157
|
+
] });
|
|
18158
|
+
}
|
|
18159
|
+
return null;
|
|
18160
|
+
};
|
|
18161
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full h-full ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.PieChart, { children: [
|
|
18162
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18163
|
+
recharts.Pie,
|
|
18164
|
+
{
|
|
18165
|
+
data: dataWithPercentage,
|
|
18166
|
+
cx: "50%",
|
|
18167
|
+
cy: "50%",
|
|
18168
|
+
labelLine: false,
|
|
18169
|
+
label: showPercentages ? renderCustomLabel : void 0,
|
|
18170
|
+
outerRadius: "80%",
|
|
18171
|
+
fill: "#8884d8",
|
|
18172
|
+
dataKey: "value",
|
|
18173
|
+
animationBegin: 0,
|
|
18174
|
+
animationDuration: 800,
|
|
18175
|
+
children: dataWithPercentage.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(recharts.Cell, { fill: colors[index % colors.length] }, `cell-${index}`))
|
|
18176
|
+
}
|
|
18177
|
+
),
|
|
18178
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, { content: /* @__PURE__ */ jsxRuntime.jsx(CustomTooltip, {}) }),
|
|
18179
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18180
|
+
recharts.Legend,
|
|
18181
|
+
{
|
|
18182
|
+
verticalAlign: "bottom",
|
|
18183
|
+
height: 36,
|
|
18184
|
+
formatter: (value) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: value })
|
|
18185
|
+
}
|
|
18186
|
+
)
|
|
18187
|
+
] }) }) });
|
|
18188
|
+
};
|
|
17992
18189
|
var TrendIcon = ({ trend }) => {
|
|
17993
18190
|
if (trend === "up") {
|
|
17994
18191
|
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "h-4 w-4 text-green-500" });
|
|
@@ -22587,7 +22784,7 @@ var getWorkspaceStyles = (position, isPlaceholder = false) => {
|
|
|
22587
22784
|
${additionalStyles}
|
|
22588
22785
|
${isPlaceholder ? "cursor-default" : ""}`;
|
|
22589
22786
|
};
|
|
22590
|
-
var
|
|
22787
|
+
var Legend6 = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 bg-white/95 rounded-lg shadow-sm px-2 sm:px-4 py-1 sm:py-1.5 border border-gray-200/60 backdrop-blur-sm text-xs sm:text-sm", children: [
|
|
22591
22788
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-gray-700 hidden sm:block", children: "Efficiency:" }),
|
|
22592
22789
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 sm:gap-4", children: [
|
|
22593
22790
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 sm:gap-2", children: [
|
|
@@ -22725,8 +22922,8 @@ var WorkspaceGrid = React14__namespace.default.memo(({
|
|
|
22725
22922
|
const { VideoGridView: VideoGridViewComponent } = useRegistry();
|
|
22726
22923
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `relative w-full h-full overflow-hidden ${className}`, children: [
|
|
22727
22924
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute top-0 left-2 sm:left-4 right-2 sm:right-8 z-20", children: [
|
|
22728
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row items-center justify-between py-1 sm:py-1.5 gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22729
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22925
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row items-center justify-between py-1 sm:py-1.5 gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsx(Legend6, {}) }) }),
|
|
22926
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(Legend6, {}) })
|
|
22730
22927
|
] }),
|
|
22731
22928
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-10 sm:top-16 left-0 right-0 bottom-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22732
22929
|
VideoGridViewComponent,
|
|
@@ -23329,6 +23526,78 @@ var WorkspaceMonthlyDataFetcher = ({
|
|
|
23329
23526
|
}, [workspaceId, selectedMonth, selectedYear, supabase, onDataLoaded, onLoadingChange]);
|
|
23330
23527
|
return null;
|
|
23331
23528
|
};
|
|
23529
|
+
var WorkspaceDisplayNameExample = () => {
|
|
23530
|
+
const { displayNames, loading, error } = useWorkspaceDisplayNames();
|
|
23531
|
+
const { displayName: singleWorkspaceName, loading: singleLoading } = useWorkspaceDisplayName("WS01");
|
|
23532
|
+
const { displayNames: displayNamesMap, loading: mapLoading } = useWorkspaceDisplayNamesMap(["WS01", "WS02", "WS03"]);
|
|
23533
|
+
if (loading) {
|
|
23534
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: "Loading workspace display names..." });
|
|
23535
|
+
}
|
|
23536
|
+
if (error) {
|
|
23537
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 text-red-600", children: [
|
|
23538
|
+
"Error loading workspace display names: ",
|
|
23539
|
+
error.message
|
|
23540
|
+
] });
|
|
23541
|
+
}
|
|
23542
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 max-w-4xl mx-auto", children: [
|
|
23543
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-bold mb-6", children: "Workspace Display Names Examples" }),
|
|
23544
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-8", children: [
|
|
23545
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-4", children: "1. All Workspace Display Names" }),
|
|
23546
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4", children: Object.entries(displayNames).map(([workspaceId, displayName]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-3 border rounded-lg", children: [
|
|
23547
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: workspaceId }),
|
|
23548
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-600", children: displayName })
|
|
23549
|
+
] }, workspaceId)) }),
|
|
23550
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 p-3 bg-gray-50 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm", children: [
|
|
23551
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Using utility function:" }),
|
|
23552
|
+
` getWorkspaceDisplayName('WS01') = "`,
|
|
23553
|
+
getWorkspaceDisplayName("WS01"),
|
|
23554
|
+
'"'
|
|
23555
|
+
] }) })
|
|
23556
|
+
] }),
|
|
23557
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-8", children: [
|
|
23558
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-4", children: "2. Single Workspace Display Name" }),
|
|
23559
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 border rounded-lg", children: singleLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading WS01..." }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
23560
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "WS01:" }),
|
|
23561
|
+
" ",
|
|
23562
|
+
singleWorkspaceName
|
|
23563
|
+
] }) })
|
|
23564
|
+
] }),
|
|
23565
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-8", children: [
|
|
23566
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-4", children: "3. Specific Workspaces Map" }),
|
|
23567
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: mapLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading specific workspaces..." }) : Object.entries(displayNamesMap).map(([workspaceId, displayName]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-3 border rounded-lg", children: [
|
|
23568
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: workspaceId }),
|
|
23569
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-600", children: displayName })
|
|
23570
|
+
] }, workspaceId)) })
|
|
23571
|
+
] }),
|
|
23572
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-8 p-4 bg-blue-50 rounded-lg", children: [
|
|
23573
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-2", children: "Migration Guide" }),
|
|
23574
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm space-y-2", children: [
|
|
23575
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Before (hardcoded):" }) }),
|
|
23576
|
+
/* @__PURE__ */ jsxRuntime.jsxs("code", { className: "block p-2 bg-gray-100 rounded", children: [
|
|
23577
|
+
"import ",
|
|
23578
|
+
`{getWorkspaceDisplayName}`,
|
|
23579
|
+
" from '@optifye/dashboard-core';",
|
|
23580
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
23581
|
+
"const name = getWorkspaceDisplayName('WS01'); // Synchronous, hardcoded"
|
|
23582
|
+
] }),
|
|
23583
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "After (from Supabase):" }) }),
|
|
23584
|
+
/* @__PURE__ */ jsxRuntime.jsxs("code", { className: "block p-2 bg-gray-100 rounded", children: [
|
|
23585
|
+
"import ",
|
|
23586
|
+
`{useWorkspaceDisplayName}`,
|
|
23587
|
+
" from '@optifye/dashboard-core';",
|
|
23588
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
23589
|
+
"const ",
|
|
23590
|
+
`{displayName, loading}`,
|
|
23591
|
+
" = useWorkspaceDisplayName('WS01'); // Async, from database"
|
|
23592
|
+
] }),
|
|
23593
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-blue-700", children: [
|
|
23594
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Note:" }),
|
|
23595
|
+
" The old synchronous functions are still available as fallbacks and for backward compatibility."
|
|
23596
|
+
] })
|
|
23597
|
+
] })
|
|
23598
|
+
] })
|
|
23599
|
+
] });
|
|
23600
|
+
};
|
|
23332
23601
|
var Breadcrumbs = ({ items }) => {
|
|
23333
23602
|
const navigation = useNavigation();
|
|
23334
23603
|
if (!items || items.length === 0) return null;
|
|
@@ -24774,6 +25043,234 @@ var AIAgentView = () => {
|
|
|
24774
25043
|
});
|
|
24775
25044
|
}
|
|
24776
25045
|
const renderAssistantContent = (content) => {
|
|
25046
|
+
const parseChartPatterns = (text) => {
|
|
25047
|
+
const chartElements = [];
|
|
25048
|
+
let lastIndex = 0;
|
|
25049
|
+
const chartRegex = /\[\s*(?:Calling\s+|CALL\s+)?(create_[a-z_]+)\s*\(([\s\S]*?)\)\s*\]/g;
|
|
25050
|
+
let match;
|
|
25051
|
+
const processedIndices = /* @__PURE__ */ new Set();
|
|
25052
|
+
while ((match = chartRegex.exec(text)) !== null) {
|
|
25053
|
+
const startIndex = match.index;
|
|
25054
|
+
const endIndex = startIndex + match[0].length;
|
|
25055
|
+
if (!processedIndices.has(startIndex)) {
|
|
25056
|
+
processedIndices.add(startIndex);
|
|
25057
|
+
if (startIndex > lastIndex) {
|
|
25058
|
+
const beforeText = text.substring(lastIndex, startIndex);
|
|
25059
|
+
chartElements.push(
|
|
25060
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
25061
|
+
"div",
|
|
25062
|
+
{
|
|
25063
|
+
dangerouslySetInnerHTML: { __html: formatMessage(beforeText) }
|
|
25064
|
+
},
|
|
25065
|
+
`text-${lastIndex}`
|
|
25066
|
+
)
|
|
25067
|
+
);
|
|
25068
|
+
}
|
|
25069
|
+
const chartType = match[1];
|
|
25070
|
+
const argsString = match[2];
|
|
25071
|
+
try {
|
|
25072
|
+
const args = parseChartArguments(argsString);
|
|
25073
|
+
const chartElement = renderChart(chartType, args, startIndex);
|
|
25074
|
+
if (chartElement) {
|
|
25075
|
+
chartElements.push(chartElement);
|
|
25076
|
+
}
|
|
25077
|
+
} catch (error) {
|
|
25078
|
+
console.error(`Failed to parse chart ${chartType}:`, error);
|
|
25079
|
+
chartElements.push(
|
|
25080
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
25081
|
+
"div",
|
|
25082
|
+
{
|
|
25083
|
+
className: "text-red-500 text-sm",
|
|
25084
|
+
children: [
|
|
25085
|
+
"Error rendering chart: ",
|
|
25086
|
+
match[0]
|
|
25087
|
+
]
|
|
25088
|
+
},
|
|
25089
|
+
`error-${startIndex}`
|
|
25090
|
+
)
|
|
25091
|
+
);
|
|
25092
|
+
}
|
|
25093
|
+
lastIndex = endIndex;
|
|
25094
|
+
}
|
|
25095
|
+
}
|
|
25096
|
+
if (lastIndex < text.length) {
|
|
25097
|
+
const remainingText = text.substring(lastIndex);
|
|
25098
|
+
chartElements.push(
|
|
25099
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
25100
|
+
"div",
|
|
25101
|
+
{
|
|
25102
|
+
dangerouslySetInnerHTML: { __html: formatMessage(remainingText) }
|
|
25103
|
+
},
|
|
25104
|
+
`text-${lastIndex}`
|
|
25105
|
+
)
|
|
25106
|
+
);
|
|
25107
|
+
}
|
|
25108
|
+
if (chartElements.length === 1 && lastIndex === 0) {
|
|
25109
|
+
return null;
|
|
25110
|
+
}
|
|
25111
|
+
return chartElements;
|
|
25112
|
+
};
|
|
25113
|
+
const parseChartArguments = (argsString) => {
|
|
25114
|
+
const args = {};
|
|
25115
|
+
const jsonParamRegex = /(\w+)\s*=\s*(\[[\s\S]*?\](?=\s*(?:,|\s*\)|\s*$))|\{[\s\S]*?\}(?=\s*(?:,|\s*\)|\s*$)))/g;
|
|
25116
|
+
let jsonMatch;
|
|
25117
|
+
while ((jsonMatch = jsonParamRegex.exec(argsString)) !== null) {
|
|
25118
|
+
const paramName = jsonMatch[1];
|
|
25119
|
+
const jsonValue = jsonMatch[2];
|
|
25120
|
+
try {
|
|
25121
|
+
args[paramName] = JSON.parse(jsonValue);
|
|
25122
|
+
argsString = argsString.replace(jsonMatch[0], "");
|
|
25123
|
+
} catch (e) {
|
|
25124
|
+
console.error(`Failed to parse ${paramName} JSON:`, e);
|
|
25125
|
+
}
|
|
25126
|
+
}
|
|
25127
|
+
const argRegex = /(\w+)\s*=\s*("([^"]*)"|'([^']*)'|([^,\s\)]+))/g;
|
|
25128
|
+
let argMatch;
|
|
25129
|
+
while ((argMatch = argRegex.exec(argsString)) !== null) {
|
|
25130
|
+
const key = argMatch[1];
|
|
25131
|
+
const value = argMatch[3] || argMatch[4] || argMatch[5];
|
|
25132
|
+
if (key === "data") continue;
|
|
25133
|
+
if (value === "true" || value === "True") {
|
|
25134
|
+
args[key] = true;
|
|
25135
|
+
} else if (value === "false" || value === "False") {
|
|
25136
|
+
args[key] = false;
|
|
25137
|
+
} else if (value === "null" || value === "None") {
|
|
25138
|
+
args[key] = null;
|
|
25139
|
+
} else if (!isNaN(Number(value)) && value !== "") {
|
|
25140
|
+
args[key] = Number(value);
|
|
25141
|
+
} else {
|
|
25142
|
+
args[key] = value;
|
|
25143
|
+
}
|
|
25144
|
+
}
|
|
25145
|
+
return args;
|
|
25146
|
+
};
|
|
25147
|
+
const renderChart = (chartType, args, key) => {
|
|
25148
|
+
switch (chartType) {
|
|
25149
|
+
case "create_gauge_chart":
|
|
25150
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-6 h-64 w-full flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25151
|
+
GaugeChart,
|
|
25152
|
+
{
|
|
25153
|
+
value: args.value || 0,
|
|
25154
|
+
min: args.min_value || 0,
|
|
25155
|
+
max: args.max_value || 100,
|
|
25156
|
+
target: args.target,
|
|
25157
|
+
label: args.title || "",
|
|
25158
|
+
unit: args.unit || "",
|
|
25159
|
+
thresholds: args.thresholds,
|
|
25160
|
+
className: "w-full max-w-sm"
|
|
25161
|
+
}
|
|
25162
|
+
) }, `gauge-${key}`);
|
|
25163
|
+
case "create_bar_chart":
|
|
25164
|
+
if (!args.data || !args.x_field || !args.y_field) {
|
|
25165
|
+
console.error("Bar chart missing required parameters");
|
|
25166
|
+
return null;
|
|
25167
|
+
}
|
|
25168
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", style: { maxWidth: args.max_width || "100%" }, children: [
|
|
25169
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
25170
|
+
BarChart,
|
|
25171
|
+
{
|
|
25172
|
+
data: args.data,
|
|
25173
|
+
bars: [{
|
|
25174
|
+
dataKey: args.y_field,
|
|
25175
|
+
fill: args.color || "#3b82f6",
|
|
25176
|
+
labelList: args.show_values
|
|
25177
|
+
}],
|
|
25178
|
+
xAxisDataKey: args.x_field,
|
|
25179
|
+
className: "h-64",
|
|
25180
|
+
showLegend: false
|
|
25181
|
+
}
|
|
25182
|
+
),
|
|
25183
|
+
args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
|
|
25184
|
+
] }, `bar-${key}`);
|
|
25185
|
+
case "create_line_chart":
|
|
25186
|
+
if (!args.data || !args.x_field || !args.y_field) {
|
|
25187
|
+
console.error("Line chart missing required parameters");
|
|
25188
|
+
return null;
|
|
25189
|
+
}
|
|
25190
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", style: {
|
|
25191
|
+
height: args.height || 256,
|
|
25192
|
+
width: args.width || "100%"
|
|
25193
|
+
}, children: [
|
|
25194
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
25195
|
+
LineChart,
|
|
25196
|
+
{
|
|
25197
|
+
data: args.data,
|
|
25198
|
+
lines: [{
|
|
25199
|
+
dataKey: args.y_field,
|
|
25200
|
+
stroke: "#3b82f6",
|
|
25201
|
+
strokeWidth: 2
|
|
25202
|
+
}],
|
|
25203
|
+
xAxisDataKey: args.x_field,
|
|
25204
|
+
className: "h-full",
|
|
25205
|
+
showLegend: false
|
|
25206
|
+
}
|
|
25207
|
+
),
|
|
25208
|
+
args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
|
|
25209
|
+
] }, `line-${key}`);
|
|
25210
|
+
case "create_pie_chart":
|
|
25211
|
+
if (!args.data || !args.label_field || !args.value_field) {
|
|
25212
|
+
console.error("Pie chart missing required parameters");
|
|
25213
|
+
return null;
|
|
25214
|
+
}
|
|
25215
|
+
const pieData = args.data.map((item) => ({
|
|
25216
|
+
name: item[args.label_field],
|
|
25217
|
+
value: item[args.value_field]
|
|
25218
|
+
}));
|
|
25219
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full flex flex-col items-center", children: [
|
|
25220
|
+
args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
|
|
25221
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-64 w-full max-w-md", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25222
|
+
PieChart4,
|
|
25223
|
+
{
|
|
25224
|
+
data: pieData,
|
|
25225
|
+
showPercentages: args.show_percentages || false
|
|
25226
|
+
}
|
|
25227
|
+
) })
|
|
25228
|
+
] }, `pie-${key}`);
|
|
25229
|
+
case "create_comparison_table":
|
|
25230
|
+
if (!args.data) {
|
|
25231
|
+
console.error("Comparison table missing required data");
|
|
25232
|
+
return null;
|
|
25233
|
+
}
|
|
25234
|
+
const columns = args.columns || Object.keys(args.data[0] || {});
|
|
25235
|
+
let sortedData = [...args.data];
|
|
25236
|
+
if (args.sort_by && columns.includes(args.sort_by)) {
|
|
25237
|
+
sortedData.sort((a, b) => {
|
|
25238
|
+
const aVal = a[args.sort_by];
|
|
25239
|
+
const bVal = b[args.sort_by];
|
|
25240
|
+
const comparison = aVal > bVal ? 1 : aVal < bVal ? -1 : 0;
|
|
25241
|
+
return args.sort_descending === false ? comparison : -comparison;
|
|
25242
|
+
});
|
|
25243
|
+
}
|
|
25244
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full overflow-x-auto", children: [
|
|
25245
|
+
args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
|
|
25246
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-gray-200", children: [
|
|
25247
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-gray-50", children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
25248
|
+
"th",
|
|
25249
|
+
{
|
|
25250
|
+
className: `px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider ${col === args.highlight_column ? "bg-blue-50" : ""}`,
|
|
25251
|
+
children: col
|
|
25252
|
+
},
|
|
25253
|
+
col
|
|
25254
|
+
)) }) }),
|
|
25255
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "bg-white divide-y divide-gray-200", children: sortedData.map((row, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx("tr", { className: rowIdx % 2 === 0 ? "bg-white" : "bg-gray-50", children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
25256
|
+
"td",
|
|
25257
|
+
{
|
|
25258
|
+
className: `px-4 py-2 whitespace-nowrap text-sm ${col === args.highlight_column ? "font-medium text-blue-600 bg-blue-50" : "text-gray-900"}`,
|
|
25259
|
+
children: row[col]
|
|
25260
|
+
},
|
|
25261
|
+
col
|
|
25262
|
+
)) }, rowIdx)) })
|
|
25263
|
+
] })
|
|
25264
|
+
] }, `table-${key}`);
|
|
25265
|
+
default:
|
|
25266
|
+
console.warn(`Unknown chart type: ${chartType}`);
|
|
25267
|
+
return null;
|
|
25268
|
+
}
|
|
25269
|
+
};
|
|
25270
|
+
const chartContent = parseChartPatterns(content);
|
|
25271
|
+
if (chartContent) {
|
|
25272
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "formatted-content", children: chartContent });
|
|
25273
|
+
}
|
|
24777
25274
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
24778
25275
|
"div",
|
|
24779
25276
|
{
|
|
@@ -31029,6 +31526,7 @@ exports.DebugAuth = DebugAuth;
|
|
|
31029
31526
|
exports.DebugAuthView = DebugAuthView_default;
|
|
31030
31527
|
exports.EmptyStateMessage = EmptyStateMessage;
|
|
31031
31528
|
exports.FactoryView = FactoryView_default;
|
|
31529
|
+
exports.GaugeChart = GaugeChart;
|
|
31032
31530
|
exports.GridComponentsPlaceholder = GridComponentsPlaceholder;
|
|
31033
31531
|
exports.Header = Header;
|
|
31034
31532
|
exports.HelpView = HelpView_default;
|
|
@@ -31044,7 +31542,7 @@ exports.KPIsOverviewView = KPIsOverviewView_default;
|
|
|
31044
31542
|
exports.LINE_1_UUID = LINE_1_UUID;
|
|
31045
31543
|
exports.LargeOutputProgressChart = LargeOutputProgressChart;
|
|
31046
31544
|
exports.LeaderboardDetailView = LeaderboardDetailView_default;
|
|
31047
|
-
exports.Legend =
|
|
31545
|
+
exports.Legend = Legend6;
|
|
31048
31546
|
exports.LineChart = LineChart;
|
|
31049
31547
|
exports.LineHistoryCalendar = LineHistoryCalendar;
|
|
31050
31548
|
exports.LineMonthlyHistory = LineMonthlyHistory;
|
|
@@ -31064,6 +31562,7 @@ exports.NoWorkspaceData = NoWorkspaceData;
|
|
|
31064
31562
|
exports.OptifyeAgentClient = OptifyeAgentClient;
|
|
31065
31563
|
exports.OutputProgressChart = OutputProgressChart;
|
|
31066
31564
|
exports.PageHeader = PageHeader;
|
|
31565
|
+
exports.PieChart = PieChart4;
|
|
31067
31566
|
exports.ProfileView = ProfileView_default;
|
|
31068
31567
|
exports.RegistryProvider = RegistryProvider;
|
|
31069
31568
|
exports.S3Service = S3Service;
|
|
@@ -31098,6 +31597,7 @@ exports.WORKSPACE_POSITIONS = WORKSPACE_POSITIONS;
|
|
|
31098
31597
|
exports.WhatsAppShareButton = WhatsAppShareButton;
|
|
31099
31598
|
exports.WorkspaceCard = WorkspaceCard;
|
|
31100
31599
|
exports.WorkspaceDetailView = WorkspaceDetailView_default;
|
|
31600
|
+
exports.WorkspaceDisplayNameExample = WorkspaceDisplayNameExample;
|
|
31101
31601
|
exports.WorkspaceGrid = WorkspaceGrid;
|
|
31102
31602
|
exports.WorkspaceGridItem = WorkspaceGridItem;
|
|
31103
31603
|
exports.WorkspaceHistoryCalendar = WorkspaceHistoryCalendar;
|