@optifye/dashboard-core 6.9.1 → 6.9.4

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.css CHANGED
@@ -2454,10 +2454,6 @@ body {
2454
2454
  --tw-bg-opacity: 1;
2455
2455
  background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1));
2456
2456
  }
2457
- .bg-red-400 {
2458
- --tw-bg-opacity: 1;
2459
- background-color: rgb(248 113 113 / var(--tw-bg-opacity, 1));
2460
- }
2461
2457
  .bg-red-400\/50 {
2462
2458
  background-color: rgb(248 113 113 / 0.5);
2463
2459
  }
@@ -3384,10 +3380,6 @@ body {
3384
3380
  --tw-text-opacity: 1;
3385
3381
  color: rgb(146 64 14 / var(--tw-text-opacity, 1));
3386
3382
  }
3387
- .text-amber-900 {
3388
- --tw-text-opacity: 1;
3389
- color: rgb(120 53 15 / var(--tw-text-opacity, 1));
3390
- }
3391
3383
  .text-blue-500 {
3392
3384
  --tw-text-opacity: 1;
3393
3385
  color: rgb(59 130 246 / var(--tw-text-opacity, 1));
@@ -5631,6 +5623,10 @@ input[type=range]:active::-moz-range-thumb {
5631
5623
  padding-top: 0.75rem;
5632
5624
  padding-bottom: 0.75rem;
5633
5625
  }
5626
+ .lg\:py-3\.5 {
5627
+ padding-top: 0.875rem;
5628
+ padding-bottom: 0.875rem;
5629
+ }
5634
5630
  .lg\:text-2xl {
5635
5631
  font-size: 1.5rem;
5636
5632
  line-height: 2rem;
package/dist/index.d.mts CHANGED
@@ -933,6 +933,11 @@ interface LeaderboardDetailViewProps {
933
933
  * Optional className for custom styling
934
934
  */
935
935
  className?: string;
936
+ /**
937
+ * Optional array of line IDs that the user has access to
938
+ * Used to filter leaderboard for supervisors
939
+ */
940
+ userAccessibleLineIds?: string[];
936
941
  }
937
942
 
938
943
  /**
@@ -2422,6 +2427,12 @@ interface UseDashboardMetricsProps {
2422
2427
  * suggesting that related components (like a Line KPI display) might need to refresh.
2423
2428
  */
2424
2429
  onLineMetricsUpdate?: () => void;
2430
+ /**
2431
+ * Optional array of line IDs that the user has access to.
2432
+ * Used to filter factory view to only show accessible lines for supervisors.
2433
+ * If not provided, defaults to all configured lines.
2434
+ */
2435
+ userAccessibleLineIds?: string[];
2425
2436
  }
2426
2437
  /**
2427
2438
  * Custom hook to fetch and subscribe to real-time dashboard metrics.
@@ -2463,7 +2474,7 @@ interface UseDashboardMetricsProps {
2463
2474
  * }
2464
2475
  * ```
2465
2476
  */
2466
- declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId }: UseDashboardMetricsProps) => {
2477
+ declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId, userAccessibleLineIds }: UseDashboardMetricsProps) => {
2467
2478
  workspaceMetrics: WorkspaceMetrics[];
2468
2479
  lineMetrics: OverviewLineMetric[];
2469
2480
  isLoading: boolean;
@@ -3007,6 +3018,8 @@ interface UseAllWorkspaceMetricsOptions {
3007
3018
  initialDate?: string;
3008
3019
  /** Specific shift ID to fetch metrics for, overriding the current shift. */
3009
3020
  initialShiftId?: number;
3021
+ /** Optional array of line IDs that the user has access to. If not provided, uses all configured lines. */
3022
+ allowedLineIds?: string[];
3010
3023
  }
3011
3024
  /**
3012
3025
  * @hook useAllWorkspaceMetrics
@@ -3607,13 +3620,13 @@ interface UseWorkspaceHealthStatusReturn {
3607
3620
  *
3608
3621
  * @description This hook subscribes to the workspace_health_status table and monitors
3609
3622
  * the last_heartbeat column for real-time updates. It automatically formats the time
3610
- * as "Xs ago", "Xm Ys ago", etc. and updates the display every second for accuracy.
3623
+ * with whole numbers (e.g., "Less than a minute ago", "4 minutes ago") and updates periodically.
3611
3624
  *
3612
3625
  * @param {string} workspaceId - The workspace UUID to monitor
3613
3626
  *
3614
3627
  * @returns {UseWorkspaceHealthStatusReturn} Object containing:
3615
3628
  * - lastHeartbeat: ISO timestamp string or null
3616
- * - timeSinceUpdate: Formatted relative time string (e.g., "30s ago")
3629
+ * - timeSinceUpdate: Formatted relative time string (e.g., "Less than a minute ago", "4 minutes ago")
3617
3630
  * - isHealthy: Boolean health status flag
3618
3631
  * - healthData: Full health status record from database
3619
3632
  * - loading: Loading state
@@ -3622,7 +3635,7 @@ interface UseWorkspaceHealthStatusReturn {
3622
3635
  *
3623
3636
  * @example
3624
3637
  * const { lastHeartbeat, timeSinceUpdate, isHealthy } = useWorkspaceHealthStatus('workspace-123');
3625
- * // timeSinceUpdate: "45s ago" or "5m 30s ago"
3638
+ * // timeSinceUpdate: "Less than a minute ago" or "4 minutes ago"
3626
3639
  */
3627
3640
  declare const useWorkspaceHealthStatus: (workspaceId: string) => UseWorkspaceHealthStatusReturn;
3628
3641
 
@@ -3708,17 +3721,18 @@ interface UseSessionKeepAliveOptions {
3708
3721
  */
3709
3722
  declare const useSessionKeepAlive: (options?: UseSessionKeepAliveOptions) => void;
3710
3723
 
3711
- type UserRole = 'owner' | 'plant_head' | 'supervisor';
3724
+ type UserRole = 'owner' | 'plant_head' | 'supervisor' | 'optifye';
3712
3725
  interface AccessControlReturn {
3713
3726
  userRole: UserRole | null;
3714
3727
  hasAccess: (path: string) => boolean;
3715
3728
  accessiblePages: string[];
3716
3729
  isPageVisible: (path: string) => boolean;
3717
3730
  canAccessPage: (path: string) => boolean;
3731
+ assignedLineIds: string[];
3732
+ assignedFactoryIds: string[];
3718
3733
  }
3719
3734
  /**
3720
3735
  * Hook to manage role-based access control
3721
- * TEMPORARILY DISABLED: All users have access to all pages
3722
3736
  *
3723
3737
  * @returns {AccessControlReturn} Access control utilities and state
3724
3738
  */
@@ -3842,21 +3856,17 @@ declare class UserManagementService {
3842
3856
  optifye: number;
3843
3857
  }>;
3844
3858
  /**
3845
- * Deactivate a user
3846
- * @param input - Deactivation input
3847
- */
3848
- deactivateUser(input: {
3849
- user_id: string;
3850
- deactivated_by: string;
3851
- }): Promise<void>;
3852
- /**
3853
- * Reactivate a user
3854
- * @param input - Reactivation input
3859
+ * Permanently delete a user
3860
+ * @param userId - The ID of the user to delete
3861
+ * @returns Promise with deletion response
3855
3862
  */
3856
- reactivateUser(input: {
3857
- user_id: string;
3858
- reactivated_by: string;
3859
- }): Promise<void>;
3863
+ deleteUser(userId: string): Promise<{
3864
+ success: boolean;
3865
+ message: string;
3866
+ deleted_user_id: string;
3867
+ deleted_user_email: string;
3868
+ deleted_by: string;
3869
+ }>;
3860
3870
  }
3861
3871
  /**
3862
3872
  * Factory function to create UserManagementService
@@ -3914,6 +3924,7 @@ interface LineSupervisor {
3914
3924
  interface UseLineSupervisorReturn {
3915
3925
  supervisorName: string | null;
3916
3926
  supervisor: LineSupervisor | null;
3927
+ supervisors: LineSupervisor[];
3917
3928
  isLoading: boolean;
3918
3929
  error: Error | null;
3919
3930
  }
@@ -4013,6 +4024,21 @@ declare const workspaceService: {
4013
4024
  updateLineThresholds(lineId: string, productId: string, workspaces: Workspace[], shiftId: number): Promise<void>;
4014
4025
  getShiftConfigurations(lineId: string): Promise<ShiftConfiguration[]>;
4015
4026
  updateShiftConfigurations(shiftConfig: ShiftConfiguration): Promise<void>;
4027
+ /**
4028
+ * Fetch bulk targets data for multiple lines and shifts in a single API call
4029
+ * This replaces 120+ individual API calls with 1 optimized call
4030
+ *
4031
+ * @param params - Parameters for the bulk fetch
4032
+ * @returns Promise with complete targets data for all lines and shifts
4033
+ */
4034
+ fetchBulkTargets(params: {
4035
+ companyId: string;
4036
+ lineIds: string[];
4037
+ date: string;
4038
+ shifts?: number[];
4039
+ includeSkus?: boolean;
4040
+ includeActions?: boolean;
4041
+ }): Promise<any>;
4016
4042
  };
4017
4043
 
4018
4044
  declare class WorkspaceHealthService {
@@ -4919,15 +4945,15 @@ declare const getCompanyMetricsTableName: (companyId: string | undefined, prefix
4919
4945
  declare const getMetricsTablePrefix: (companyId?: string) => string;
4920
4946
 
4921
4947
  /**
4922
- * Format a timestamp as relative time with detailed precision
4923
- * Shows seconds, minutes, hours, or days ago
4948
+ * Format a timestamp as relative time with whole number precision
4949
+ * Shows minutes, hours, or days ago without real-time seconds
4924
4950
  *
4925
4951
  * @param timestamp - Date object or ISO string timestamp
4926
- * @returns Formatted relative time string (e.g., "30s ago", "5m 30s ago", "2h ago", "3d ago")
4952
+ * @returns Formatted relative time string (e.g., "Less than a minute ago", "4 minutes ago", "2 hours ago", "3 days ago")
4927
4953
  *
4928
4954
  * @example
4929
- * formatRelativeTime(new Date()) // "0s ago"
4930
- * formatRelativeTime("2024-01-01T12:00:00Z") // "5m 30s ago"
4955
+ * formatRelativeTime(new Date()) // "Less than a minute ago"
4956
+ * formatRelativeTime("2024-01-01T12:00:00Z") // "4 minutes ago"
4931
4957
  */
4932
4958
  declare function formatRelativeTime(timestamp: string | Date | null | undefined): string;
4933
4959
  /**
package/dist/index.d.ts CHANGED
@@ -933,6 +933,11 @@ interface LeaderboardDetailViewProps {
933
933
  * Optional className for custom styling
934
934
  */
935
935
  className?: string;
936
+ /**
937
+ * Optional array of line IDs that the user has access to
938
+ * Used to filter leaderboard for supervisors
939
+ */
940
+ userAccessibleLineIds?: string[];
936
941
  }
937
942
 
938
943
  /**
@@ -2422,6 +2427,12 @@ interface UseDashboardMetricsProps {
2422
2427
  * suggesting that related components (like a Line KPI display) might need to refresh.
2423
2428
  */
2424
2429
  onLineMetricsUpdate?: () => void;
2430
+ /**
2431
+ * Optional array of line IDs that the user has access to.
2432
+ * Used to filter factory view to only show accessible lines for supervisors.
2433
+ * If not provided, defaults to all configured lines.
2434
+ */
2435
+ userAccessibleLineIds?: string[];
2425
2436
  }
2426
2437
  /**
2427
2438
  * Custom hook to fetch and subscribe to real-time dashboard metrics.
@@ -2463,7 +2474,7 @@ interface UseDashboardMetricsProps {
2463
2474
  * }
2464
2475
  * ```
2465
2476
  */
2466
- declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId }: UseDashboardMetricsProps) => {
2477
+ declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId, userAccessibleLineIds }: UseDashboardMetricsProps) => {
2467
2478
  workspaceMetrics: WorkspaceMetrics[];
2468
2479
  lineMetrics: OverviewLineMetric[];
2469
2480
  isLoading: boolean;
@@ -3007,6 +3018,8 @@ interface UseAllWorkspaceMetricsOptions {
3007
3018
  initialDate?: string;
3008
3019
  /** Specific shift ID to fetch metrics for, overriding the current shift. */
3009
3020
  initialShiftId?: number;
3021
+ /** Optional array of line IDs that the user has access to. If not provided, uses all configured lines. */
3022
+ allowedLineIds?: string[];
3010
3023
  }
3011
3024
  /**
3012
3025
  * @hook useAllWorkspaceMetrics
@@ -3607,13 +3620,13 @@ interface UseWorkspaceHealthStatusReturn {
3607
3620
  *
3608
3621
  * @description This hook subscribes to the workspace_health_status table and monitors
3609
3622
  * the last_heartbeat column for real-time updates. It automatically formats the time
3610
- * as "Xs ago", "Xm Ys ago", etc. and updates the display every second for accuracy.
3623
+ * with whole numbers (e.g., "Less than a minute ago", "4 minutes ago") and updates periodically.
3611
3624
  *
3612
3625
  * @param {string} workspaceId - The workspace UUID to monitor
3613
3626
  *
3614
3627
  * @returns {UseWorkspaceHealthStatusReturn} Object containing:
3615
3628
  * - lastHeartbeat: ISO timestamp string or null
3616
- * - timeSinceUpdate: Formatted relative time string (e.g., "30s ago")
3629
+ * - timeSinceUpdate: Formatted relative time string (e.g., "Less than a minute ago", "4 minutes ago")
3617
3630
  * - isHealthy: Boolean health status flag
3618
3631
  * - healthData: Full health status record from database
3619
3632
  * - loading: Loading state
@@ -3622,7 +3635,7 @@ interface UseWorkspaceHealthStatusReturn {
3622
3635
  *
3623
3636
  * @example
3624
3637
  * const { lastHeartbeat, timeSinceUpdate, isHealthy } = useWorkspaceHealthStatus('workspace-123');
3625
- * // timeSinceUpdate: "45s ago" or "5m 30s ago"
3638
+ * // timeSinceUpdate: "Less than a minute ago" or "4 minutes ago"
3626
3639
  */
3627
3640
  declare const useWorkspaceHealthStatus: (workspaceId: string) => UseWorkspaceHealthStatusReturn;
3628
3641
 
@@ -3708,17 +3721,18 @@ interface UseSessionKeepAliveOptions {
3708
3721
  */
3709
3722
  declare const useSessionKeepAlive: (options?: UseSessionKeepAliveOptions) => void;
3710
3723
 
3711
- type UserRole = 'owner' | 'plant_head' | 'supervisor';
3724
+ type UserRole = 'owner' | 'plant_head' | 'supervisor' | 'optifye';
3712
3725
  interface AccessControlReturn {
3713
3726
  userRole: UserRole | null;
3714
3727
  hasAccess: (path: string) => boolean;
3715
3728
  accessiblePages: string[];
3716
3729
  isPageVisible: (path: string) => boolean;
3717
3730
  canAccessPage: (path: string) => boolean;
3731
+ assignedLineIds: string[];
3732
+ assignedFactoryIds: string[];
3718
3733
  }
3719
3734
  /**
3720
3735
  * Hook to manage role-based access control
3721
- * TEMPORARILY DISABLED: All users have access to all pages
3722
3736
  *
3723
3737
  * @returns {AccessControlReturn} Access control utilities and state
3724
3738
  */
@@ -3842,21 +3856,17 @@ declare class UserManagementService {
3842
3856
  optifye: number;
3843
3857
  }>;
3844
3858
  /**
3845
- * Deactivate a user
3846
- * @param input - Deactivation input
3847
- */
3848
- deactivateUser(input: {
3849
- user_id: string;
3850
- deactivated_by: string;
3851
- }): Promise<void>;
3852
- /**
3853
- * Reactivate a user
3854
- * @param input - Reactivation input
3859
+ * Permanently delete a user
3860
+ * @param userId - The ID of the user to delete
3861
+ * @returns Promise with deletion response
3855
3862
  */
3856
- reactivateUser(input: {
3857
- user_id: string;
3858
- reactivated_by: string;
3859
- }): Promise<void>;
3863
+ deleteUser(userId: string): Promise<{
3864
+ success: boolean;
3865
+ message: string;
3866
+ deleted_user_id: string;
3867
+ deleted_user_email: string;
3868
+ deleted_by: string;
3869
+ }>;
3860
3870
  }
3861
3871
  /**
3862
3872
  * Factory function to create UserManagementService
@@ -3914,6 +3924,7 @@ interface LineSupervisor {
3914
3924
  interface UseLineSupervisorReturn {
3915
3925
  supervisorName: string | null;
3916
3926
  supervisor: LineSupervisor | null;
3927
+ supervisors: LineSupervisor[];
3917
3928
  isLoading: boolean;
3918
3929
  error: Error | null;
3919
3930
  }
@@ -4013,6 +4024,21 @@ declare const workspaceService: {
4013
4024
  updateLineThresholds(lineId: string, productId: string, workspaces: Workspace[], shiftId: number): Promise<void>;
4014
4025
  getShiftConfigurations(lineId: string): Promise<ShiftConfiguration[]>;
4015
4026
  updateShiftConfigurations(shiftConfig: ShiftConfiguration): Promise<void>;
4027
+ /**
4028
+ * Fetch bulk targets data for multiple lines and shifts in a single API call
4029
+ * This replaces 120+ individual API calls with 1 optimized call
4030
+ *
4031
+ * @param params - Parameters for the bulk fetch
4032
+ * @returns Promise with complete targets data for all lines and shifts
4033
+ */
4034
+ fetchBulkTargets(params: {
4035
+ companyId: string;
4036
+ lineIds: string[];
4037
+ date: string;
4038
+ shifts?: number[];
4039
+ includeSkus?: boolean;
4040
+ includeActions?: boolean;
4041
+ }): Promise<any>;
4016
4042
  };
4017
4043
 
4018
4044
  declare class WorkspaceHealthService {
@@ -4919,15 +4945,15 @@ declare const getCompanyMetricsTableName: (companyId: string | undefined, prefix
4919
4945
  declare const getMetricsTablePrefix: (companyId?: string) => string;
4920
4946
 
4921
4947
  /**
4922
- * Format a timestamp as relative time with detailed precision
4923
- * Shows seconds, minutes, hours, or days ago
4948
+ * Format a timestamp as relative time with whole number precision
4949
+ * Shows minutes, hours, or days ago without real-time seconds
4924
4950
  *
4925
4951
  * @param timestamp - Date object or ISO string timestamp
4926
- * @returns Formatted relative time string (e.g., "30s ago", "5m 30s ago", "2h ago", "3d ago")
4952
+ * @returns Formatted relative time string (e.g., "Less than a minute ago", "4 minutes ago", "2 hours ago", "3 days ago")
4927
4953
  *
4928
4954
  * @example
4929
- * formatRelativeTime(new Date()) // "0s ago"
4930
- * formatRelativeTime("2024-01-01T12:00:00Z") // "5m 30s ago"
4955
+ * formatRelativeTime(new Date()) // "Less than a minute ago"
4956
+ * formatRelativeTime("2024-01-01T12:00:00Z") // "4 minutes ago"
4931
4957
  */
4932
4958
  declare function formatRelativeTime(timestamp: string | Date | null | undefined): string;
4933
4959
  /**