@lincros-ui/components 0.2.20 → 0.2.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React37 from 'react';
2
2
  import React37__default, { memo, useMemo, useCallback, useState, useRef, useEffect } from 'react';
3
3
  import * as AccordionPrimitive from '@radix-ui/react-accordion';
4
- import { ChevronDown, ArrowLeft, ArrowRight, Check, X, Search, ChevronRight, Circle, Minimize2, Maximize2, Dot, ChevronUp, PanelLeft, Clock, AlertCircle, CheckCircle, Shield, AlertTriangle, Users, RefreshCw, Home, ExternalLink, LogIn, Server, Key, MoreHorizontal, ChevronLeft, Phone, Video, Info, MoreVertical, Paperclip, Smile, Mic, Send, GripVertical, Lock, Monitor, Navigation, Bell, BarChart3, Settings, UserCheck, UserCog, Car, Workflow, MessageCircle, Building2, Database, Bot, Settings2, LogOut, Loader2, User, ClipboardList, Filter, ChevronsLeft, ChevronsRight, Bold, Italic, List, ListOrdered, Quote, Code, Link2, Image, Plus, LayoutGrid, MessageSquare, FileJson, Activity, Hash, Copy, Zap, Network, Timer, Eye, GitBranch, Terminal, Pause, Play, Trash2, Download, FileText, History, QrCode, TrendingUp, TrendingDown, XCircle, CheckCircle2, Wifi, WifiOff, TestTube, Save, Bug, MapPin, CheckCheck } from 'lucide-react';
4
+ import { ChevronDown, ArrowLeft, ArrowRight, Check, X, Search, ChevronRight, Circle, Minimize2, Maximize2, Dot, ChevronUp, PanelLeft, Clock, AlertCircle, CheckCircle, Shield, AlertTriangle, Users, RefreshCw, Home, ExternalLink, LogIn, Server, Key, MoreHorizontal, ChevronLeft, Phone, Video, Info, MoreVertical, Paperclip, Smile, Mic, Send, GripVertical, Lock, Settings2, LogOut, Loader2, Bot, User, Building2, UserCheck, ClipboardList, Filter, ChevronsLeft, ChevronsRight, Bold, Italic, List, ListOrdered, Quote, Code, Link2, Image, Plus, LayoutGrid, MessageSquare, FileJson, Activity, Database, Hash, Copy, Zap, Network, Timer, Eye, Workflow, GitBranch, Terminal, Pause, Play, Trash2, Download, FileText, History, MessageCircle, QrCode, TrendingUp, TrendingDown, BarChart3, XCircle, CheckCircle2, Wifi, WifiOff, TestTube, Save, Bug, MapPin, CheckCheck } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -42,7 +42,6 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
42
42
  import * as TogglePrimitive from '@radix-ui/react-toggle';
43
43
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
44
44
  import { Link, useLocation, Navigate, useNavigate } from 'react-router-dom';
45
- import { canAccessMenu } from '@/lib/menu-permissions';
46
45
  import { useEditor, EditorContent } from '@tiptap/react';
47
46
  import StarterKit from '@tiptap/starter-kit';
48
47
  import Image2 from '@tiptap/extension-image';
@@ -4770,8 +4769,30 @@ var MenuPermissionLevel = /* @__PURE__ */ ((MenuPermissionLevel2) => {
4770
4769
  MenuPermissionLevel2["ADMIN_ONLY"] = "ADMIN_ONLY";
4771
4770
  MenuPermissionLevel2["MANAGER_OR_ADMIN"] = "MANAGER_OR_ADMIN";
4772
4771
  MenuPermissionLevel2["MASTER_TENANT_ONLY"] = "MASTER_TENANT_ONLY";
4772
+ MenuPermissionLevel2["NON_MASTER_TENANT_ONLY"] = "NON_MASTER_TENANT_ONLY";
4773
4773
  return MenuPermissionLevel2;
4774
4774
  })(MenuPermissionLevel || {});
4775
+
4776
+ // src/lib/menu-permissions.ts
4777
+ var MANAGER_PROFILE_ID = 6;
4778
+ function canAccessMenu(user, permission, isMasterTenant) {
4779
+ if (!permission || permission === "ALL" /* ALL */) return true;
4780
+ if (!user) return false;
4781
+ const isAdmin = user.is_admin === true;
4782
+ const isManager = user.perfil_usuario_id === MANAGER_PROFILE_ID;
4783
+ switch (permission) {
4784
+ case "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */:
4785
+ return isAdmin || isManager;
4786
+ case "ADMIN_ONLY" /* ADMIN_ONLY */:
4787
+ return isAdmin;
4788
+ case "MASTER_TENANT_ONLY" /* MASTER_TENANT_ONLY */:
4789
+ return isMasterTenant === true;
4790
+ case "NON_MASTER_TENANT_ONLY" /* NON_MASTER_TENANT_ONLY */:
4791
+ return isMasterTenant !== true;
4792
+ default:
4793
+ return false;
4794
+ }
4795
+ }
4775
4796
  var STORAGE_KEY = "sidebar-expanded-menus";
4776
4797
  function useSidebarState(routePaths) {
4777
4798
  const location = useLocation();
@@ -5010,12 +5031,13 @@ function PasswordResetModal({
5010
5031
  ] })
5011
5032
  ] }) });
5012
5033
  }
5013
- function filterMenuItems(items, user) {
5014
- return items.filter((item) => canAccessMenu(user, item.permission)).map((item) => {
5034
+ function filterMenuItems(items, user, isMasterTenant) {
5035
+ return items.filter((item) => canAccessMenu(user, item.permission, isMasterTenant)).map((item) => {
5015
5036
  if (item.subItems) {
5016
5037
  const filteredSubItems = filterMenuItems(
5017
5038
  item.subItems,
5018
- user
5039
+ user,
5040
+ isMasterTenant
5019
5041
  );
5020
5042
  if (filteredSubItems.length === 0) {
5021
5043
  return null;
@@ -5128,136 +5150,6 @@ function ControlSidebar({
5128
5150
  }
5129
5151
  }
5130
5152
  };
5131
- const defaultMenuItems = [
5132
- {
5133
- title: "Dashboard",
5134
- url: routePaths.DASHBOARD,
5135
- icon: Monitor,
5136
- permission: "ALL" /* ALL */
5137
- },
5138
- {
5139
- title: "Monitoramento de Rotas",
5140
- url: routePaths.ROUTE_MONITORING,
5141
- icon: Navigation,
5142
- permission: "ADMIN_ONLY" /* ADMIN_ONLY */
5143
- },
5144
- {
5145
- title: "Alertas",
5146
- url: routePaths.ALERTS,
5147
- icon: Bell,
5148
- permission: "ALL" /* ALL */
5149
- },
5150
- {
5151
- title: "Relat\xF3rios",
5152
- url: routePaths.REPORTS,
5153
- icon: BarChart3,
5154
- permission: "ALL" /* ALL */
5155
- },
5156
- {
5157
- title: "Configura\xE7\xF5es",
5158
- icon: Settings,
5159
- permission: "ADMIN_ONLY" /* ADMIN_ONLY */,
5160
- subItems: [
5161
- {
5162
- title: "Configura\xE7\xF5es Gerais",
5163
- url: routePaths.SETTINGS,
5164
- icon: Settings,
5165
- permission: "ALL" /* ALL */
5166
- },
5167
- {
5168
- title: "Usu\xE1rios",
5169
- icon: Users,
5170
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
5171
- subItems: [
5172
- {
5173
- title: "Gest\xE3o de Usu\xE1rios",
5174
- url: routePaths.USER_MANAGEMENT,
5175
- icon: UserCheck,
5176
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5177
- },
5178
- {
5179
- title: "Perfis de Usu\xE1rio",
5180
- url: routePaths.USER_PROFILES,
5181
- icon: UserCog,
5182
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5183
- },
5184
- {
5185
- title: "Permiss\xF5es",
5186
- url: routePaths.PERMISSIONS_MANAGEMENT,
5187
- icon: Shield,
5188
- permission: "ADMIN_ONLY" /* ADMIN_ONLY */
5189
- }
5190
- ]
5191
- },
5192
- {
5193
- title: "Motoristas",
5194
- url: routePaths.MOTORISTAS,
5195
- icon: Car,
5196
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5197
- },
5198
- {
5199
- title: "WhatsApp",
5200
- icon: MessageCircle,
5201
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
5202
- subItems: [
5203
- {
5204
- title: "Configura\xE7\xF5es",
5205
- url: routePaths.WHATSAPP_CONFIG,
5206
- icon: Settings,
5207
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5208
- },
5209
- {
5210
- title: "Triggers de Fluxo",
5211
- url: routePaths.WHATSAPP_TRIGGERS,
5212
- icon: Workflow,
5213
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5214
- },
5215
- {
5216
- title: "Monitoramento",
5217
- url: routePaths.WHATSAPP_MONITORING,
5218
- icon: Monitor,
5219
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5220
- }
5221
- ]
5222
- },
5223
- ...isMasterTenant ? [] : [
5224
- {
5225
- title: "Unidades de Neg\xF3cio",
5226
- url: routePaths.UNIDADES_NEGOCIO,
5227
- icon: Building2,
5228
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5229
- }
5230
- ],
5231
- ...isMasterTenant ? [
5232
- {
5233
- title: "Tenants",
5234
- url: routePaths.TENANT_MANAGEMENT,
5235
- icon: Database,
5236
- permission: "ADMIN_ONLY" /* ADMIN_ONLY */
5237
- }
5238
- ] : []
5239
- ]
5240
- },
5241
- {
5242
- title: "Automa\xE7\xE3o",
5243
- icon: Bot,
5244
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
5245
- subItems: [
5246
- {
5247
- title: "Fluxos de Automa\xE7\xE3o",
5248
- url: routePaths.FLOWS,
5249
- icon: Workflow,
5250
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5251
- },
5252
- {
5253
- title: "Credenciais",
5254
- url: routePaths.CREDENTIALS,
5255
- icon: Key,
5256
- permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
5257
- }
5258
- ]
5259
- }
5260
- ];
5261
5153
  React37__default.useEffect(() => {
5262
5154
  if (!currentTime) {
5263
5155
  const timer = setInterval(() => {
@@ -5266,9 +5158,9 @@ function ControlSidebar({
5266
5158
  return () => clearInterval(timer);
5267
5159
  }
5268
5160
  }, [currentTime]);
5269
- const resolvedMenuItems = menuItemsProp ?? defaultMenuItems;
5161
+ const resolvedMenuItems = menuItemsProp ?? [];
5270
5162
  const displayTime = currentTime || internalTime;
5271
- const filteredMenuItems = filterMenuItems(resolvedMenuItems, user);
5163
+ const filteredMenuItems = filterMenuItems(resolvedMenuItems, user, isMasterTenant);
5272
5164
  return /* @__PURE__ */ jsxs(Sidebar, { className: "border-r border-gray-200", collapsible: "icon", children: [
5273
5165
  /* @__PURE__ */ jsxs(SidebarHeader, { className: "border-b border-gray-200", children: [
5274
5166
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-2 py-2", children: /* @__PURE__ */ jsx(SidebarTrigger, { className: "ml-auto" }) }),