@optifye/dashboard-core 6.10.41 → 6.10.43
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.js +21 -8
- package/dist/index.mjs +21 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42894,7 +42894,15 @@ var LineMonthlyHistory = ({
|
|
|
42894
42894
|
]
|
|
42895
42895
|
},
|
|
42896
42896
|
chartKey
|
|
42897
|
-
) }) })
|
|
42897
|
+
) }) }),
|
|
42898
|
+
!isUptimeMode && chartData.lastSetTarget > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center text-sm text-gray-600 bg-white py-1 pt-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 border border-gray-100 rounded-full px-3 py-1", children: [
|
|
42899
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full border-t-2 border-[#E34329] border-dashed" }) }),
|
|
42900
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
42901
|
+
"Target: ",
|
|
42902
|
+
Math.round(chartData.lastSetTarget),
|
|
42903
|
+
" units/day"
|
|
42904
|
+
] })
|
|
42905
|
+
] }) })
|
|
42898
42906
|
] })
|
|
42899
42907
|
] })
|
|
42900
42908
|
] })
|
|
@@ -56998,7 +57006,11 @@ var KPIDetailView = ({
|
|
|
56998
57006
|
underperforming_workspaces: metric.underperforming_workspaces || 0,
|
|
56999
57007
|
total_workspaces: metric.total_workspaces || 0,
|
|
57000
57008
|
output: metric.current_output || 0,
|
|
57001
|
-
|
|
57009
|
+
// LineMonthlyHistory expects `idealOutput` for the red dotted target ReferenceLine.
|
|
57010
|
+
// `line_threshold` comes from `line_metrics` (numeric -> string via PostgREST), so coerce.
|
|
57011
|
+
idealOutput: Number(metric.line_threshold ?? metric.ideal_output ?? 0),
|
|
57012
|
+
// Keep legacy field in case any downstream code still reads it.
|
|
57013
|
+
targetOutput: Number(metric.line_threshold ?? metric.ideal_output ?? 0),
|
|
57002
57014
|
compliance_percentage: 95 + Math.random() * 5,
|
|
57003
57015
|
// Mock data: random value between 95-100%
|
|
57004
57016
|
hasData: isUptimeMode ? availableTimeSeconds > 0 : true,
|
|
@@ -65936,8 +65948,8 @@ var TeamManagementView = ({
|
|
|
65936
65948
|
}, {});
|
|
65937
65949
|
}, [usageData, usageDateRange.daysElapsed]);
|
|
65938
65950
|
const pageTitle = user?.role_level === "optifye" ? "Platform Users" : "Team Management";
|
|
65939
|
-
const pageDescription = user?.role_level === "optifye" ? "Manage users across all companies" : user?.role_level === "owner" ? "Manage team members and view their daily usage" : "Manage supervisors in your factory";
|
|
65940
|
-
const hasAccess = user ? user.role_level === void 0 || ["optifye", "owner", "plant_head"].includes(user.role_level) : false;
|
|
65951
|
+
const pageDescription = user?.role_level === "optifye" ? "Manage users across all companies" : user?.role_level === "owner" || user?.role_level === "it" ? "Manage team members and view their daily usage" : "Manage supervisors in your factory";
|
|
65952
|
+
const hasAccess = user ? user.role_level === void 0 || ["optifye", "owner", "it", "plant_head"].includes(user.role_level) : false;
|
|
65941
65953
|
const loadData = React26.useCallback(async () => {
|
|
65942
65954
|
if (!supabase) {
|
|
65943
65955
|
setError("Supabase client not available. Please refresh the page.");
|
|
@@ -65988,7 +66000,7 @@ var TeamManagementView = ({
|
|
|
65988
66000
|
setAvailableFactories(factories || []);
|
|
65989
66001
|
setAvailableLines(lines);
|
|
65990
66002
|
console.log("[TeamManagementView] Optifye - Loaded factories:", factories?.length, "lines:", lines?.length, "Sample lines:", lines?.slice(0, 3));
|
|
65991
|
-
} else if (user?.role_level === "owner" && companyId) {
|
|
66003
|
+
} else if ((user?.role_level === "owner" || user?.role_level === "it") && companyId) {
|
|
65992
66004
|
const { data: factories } = await supabase.from("factories").select("id, factory_name, company_id").eq("company_id", companyId).order("factory_name");
|
|
65993
66005
|
const linesResponse = await fetch(`${backendUrl}/api/lines?company_id=${companyId}`, {
|
|
65994
66006
|
headers: {
|
|
@@ -66003,7 +66015,7 @@ var TeamManagementView = ({
|
|
|
66003
66015
|
const lines = linesData.lines || [];
|
|
66004
66016
|
setAvailableFactories(factories || []);
|
|
66005
66017
|
setAvailableLines(lines);
|
|
66006
|
-
console.log("[TeamManagementView] Owner - Company:", companyId, "Loaded factories:", factories?.length, "lines:", lines?.length);
|
|
66018
|
+
console.log("[TeamManagementView] Owner/IT - Company:", companyId, "Loaded factories:", factories?.length, "lines:", lines?.length);
|
|
66007
66019
|
} else if (user?.role_level === "plant_head") {
|
|
66008
66020
|
const plantHeadFactoryIds = user?.properties?.factory_ids || [];
|
|
66009
66021
|
if (plantHeadFactoryIds.length > 0) {
|
|
@@ -66096,7 +66108,8 @@ var TeamManagementView = ({
|
|
|
66096
66108
|
}
|
|
66097
66109
|
}, [supabase, user, entityConfig]);
|
|
66098
66110
|
React26.useEffect(() => {
|
|
66099
|
-
const
|
|
66111
|
+
const companyId = entityConfig?.companyId || user?.properties?.company_id;
|
|
66112
|
+
const canLoad = hasAccess && user && (user.role_level === "optifye" || !!companyId);
|
|
66100
66113
|
if (canLoad) {
|
|
66101
66114
|
loadData();
|
|
66102
66115
|
} else if (!user) {
|
|
@@ -66196,7 +66209,7 @@ var TeamManagementView = ({
|
|
|
66196
66209
|
{
|
|
66197
66210
|
iconType: lucideReact.AlertCircle,
|
|
66198
66211
|
title: "Access Denied",
|
|
66199
|
-
message: "You don't have permission to view this page. Only owners
|
|
66212
|
+
message: "You don't have permission to view this page. Only owners, IT, plant heads, and Optifye users can access team management."
|
|
66200
66213
|
}
|
|
66201
66214
|
) });
|
|
66202
66215
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -42865,7 +42865,15 @@ var LineMonthlyHistory = ({
|
|
|
42865
42865
|
]
|
|
42866
42866
|
},
|
|
42867
42867
|
chartKey
|
|
42868
|
-
) }) })
|
|
42868
|
+
) }) }),
|
|
42869
|
+
!isUptimeMode && chartData.lastSetTarget > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center text-sm text-gray-600 bg-white py-1 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border border-gray-100 rounded-full px-3 py-1", children: [
|
|
42870
|
+
/* @__PURE__ */ jsx("div", { className: "w-8 flex items-center", children: /* @__PURE__ */ jsx("div", { className: "w-full border-t-2 border-[#E34329] border-dashed" }) }),
|
|
42871
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
42872
|
+
"Target: ",
|
|
42873
|
+
Math.round(chartData.lastSetTarget),
|
|
42874
|
+
" units/day"
|
|
42875
|
+
] })
|
|
42876
|
+
] }) })
|
|
42869
42877
|
] })
|
|
42870
42878
|
] })
|
|
42871
42879
|
] })
|
|
@@ -56969,7 +56977,11 @@ var KPIDetailView = ({
|
|
|
56969
56977
|
underperforming_workspaces: metric.underperforming_workspaces || 0,
|
|
56970
56978
|
total_workspaces: metric.total_workspaces || 0,
|
|
56971
56979
|
output: metric.current_output || 0,
|
|
56972
|
-
|
|
56980
|
+
// LineMonthlyHistory expects `idealOutput` for the red dotted target ReferenceLine.
|
|
56981
|
+
// `line_threshold` comes from `line_metrics` (numeric -> string via PostgREST), so coerce.
|
|
56982
|
+
idealOutput: Number(metric.line_threshold ?? metric.ideal_output ?? 0),
|
|
56983
|
+
// Keep legacy field in case any downstream code still reads it.
|
|
56984
|
+
targetOutput: Number(metric.line_threshold ?? metric.ideal_output ?? 0),
|
|
56973
56985
|
compliance_percentage: 95 + Math.random() * 5,
|
|
56974
56986
|
// Mock data: random value between 95-100%
|
|
56975
56987
|
hasData: isUptimeMode ? availableTimeSeconds > 0 : true,
|
|
@@ -65907,8 +65919,8 @@ var TeamManagementView = ({
|
|
|
65907
65919
|
}, {});
|
|
65908
65920
|
}, [usageData, usageDateRange.daysElapsed]);
|
|
65909
65921
|
const pageTitle = user?.role_level === "optifye" ? "Platform Users" : "Team Management";
|
|
65910
|
-
const pageDescription = user?.role_level === "optifye" ? "Manage users across all companies" : user?.role_level === "owner" ? "Manage team members and view their daily usage" : "Manage supervisors in your factory";
|
|
65911
|
-
const hasAccess = user ? user.role_level === void 0 || ["optifye", "owner", "plant_head"].includes(user.role_level) : false;
|
|
65922
|
+
const pageDescription = user?.role_level === "optifye" ? "Manage users across all companies" : user?.role_level === "owner" || user?.role_level === "it" ? "Manage team members and view their daily usage" : "Manage supervisors in your factory";
|
|
65923
|
+
const hasAccess = user ? user.role_level === void 0 || ["optifye", "owner", "it", "plant_head"].includes(user.role_level) : false;
|
|
65912
65924
|
const loadData = useCallback(async () => {
|
|
65913
65925
|
if (!supabase) {
|
|
65914
65926
|
setError("Supabase client not available. Please refresh the page.");
|
|
@@ -65959,7 +65971,7 @@ var TeamManagementView = ({
|
|
|
65959
65971
|
setAvailableFactories(factories || []);
|
|
65960
65972
|
setAvailableLines(lines);
|
|
65961
65973
|
console.log("[TeamManagementView] Optifye - Loaded factories:", factories?.length, "lines:", lines?.length, "Sample lines:", lines?.slice(0, 3));
|
|
65962
|
-
} else if (user?.role_level === "owner" && companyId) {
|
|
65974
|
+
} else if ((user?.role_level === "owner" || user?.role_level === "it") && companyId) {
|
|
65963
65975
|
const { data: factories } = await supabase.from("factories").select("id, factory_name, company_id").eq("company_id", companyId).order("factory_name");
|
|
65964
65976
|
const linesResponse = await fetch(`${backendUrl}/api/lines?company_id=${companyId}`, {
|
|
65965
65977
|
headers: {
|
|
@@ -65974,7 +65986,7 @@ var TeamManagementView = ({
|
|
|
65974
65986
|
const lines = linesData.lines || [];
|
|
65975
65987
|
setAvailableFactories(factories || []);
|
|
65976
65988
|
setAvailableLines(lines);
|
|
65977
|
-
console.log("[TeamManagementView] Owner - Company:", companyId, "Loaded factories:", factories?.length, "lines:", lines?.length);
|
|
65989
|
+
console.log("[TeamManagementView] Owner/IT - Company:", companyId, "Loaded factories:", factories?.length, "lines:", lines?.length);
|
|
65978
65990
|
} else if (user?.role_level === "plant_head") {
|
|
65979
65991
|
const plantHeadFactoryIds = user?.properties?.factory_ids || [];
|
|
65980
65992
|
if (plantHeadFactoryIds.length > 0) {
|
|
@@ -66067,7 +66079,8 @@ var TeamManagementView = ({
|
|
|
66067
66079
|
}
|
|
66068
66080
|
}, [supabase, user, entityConfig]);
|
|
66069
66081
|
useEffect(() => {
|
|
66070
|
-
const
|
|
66082
|
+
const companyId = entityConfig?.companyId || user?.properties?.company_id;
|
|
66083
|
+
const canLoad = hasAccess && user && (user.role_level === "optifye" || !!companyId);
|
|
66071
66084
|
if (canLoad) {
|
|
66072
66085
|
loadData();
|
|
66073
66086
|
} else if (!user) {
|
|
@@ -66167,7 +66180,7 @@ var TeamManagementView = ({
|
|
|
66167
66180
|
{
|
|
66168
66181
|
iconType: AlertCircle,
|
|
66169
66182
|
title: "Access Denied",
|
|
66170
|
-
message: "You don't have permission to view this page. Only owners
|
|
66183
|
+
message: "You don't have permission to view this page. Only owners, IT, plant heads, and Optifye users can access team management."
|
|
66171
66184
|
}
|
|
66172
66185
|
) });
|
|
66173
66186
|
}
|