@natoora-libs/drawer-menu 0.0.1

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 ADDED
@@ -0,0 +1,931 @@
1
+ // src/components/LeftDrawer/LeftDrawer.tsx
2
+ import { Fragment, useState } from "react";
3
+ import { useNavigate } from "react-router";
4
+ import {
5
+ PushPinOutlined,
6
+ FiberManualRecord,
7
+ ExpandLess
8
+ } from "@mui/icons-material";
9
+ import {
10
+ AppBar,
11
+ Collapse,
12
+ List,
13
+ ListItem,
14
+ ListItemIcon,
15
+ ListItemText,
16
+ ListSubheader,
17
+ SwipeableDrawer,
18
+ Toolbar,
19
+ ListItemButton,
20
+ Box
21
+ } from "@mui/material";
22
+ import Icon from "@mui/material/Icon";
23
+ import { RoundButton, UserBust } from "@natoora-libs/core/components";
24
+ import { makeStyles } from "tss-react/mui";
25
+
26
+ // src/resources/styles/colors/darkPalette.ts
27
+ var darkPalette = {
28
+ // General colors
29
+ white: "#FFFFFF",
30
+ black: "#000000",
31
+ // Neutral
32
+ neutral50: "#1C1B1A",
33
+ neutral100: "#1F1F1F",
34
+ neutral150: "#262626",
35
+ neutral200: "#2E2E2E",
36
+ neutral250: "#383838",
37
+ neutral300: "#424242",
38
+ neutral400: "#4C4C4C",
39
+ neutral500: "#666666",
40
+ neutral600: "#808080",
41
+ neutral700: "#A3A3A3",
42
+ neutral750: "#B3B3B3",
43
+ neutral800: "#CCCCCC",
44
+ neutral900: "#F5F5F5",
45
+ // Input and contrast
46
+ contrast: "#FFFFFF",
47
+ constrastOpacity50: "rgba(255,255,255,0.5)",
48
+ // Icon and Material UI colors
49
+ iconSearch: "#B0B0B0",
50
+ default: "#444444",
51
+ muiPrimary: "#E9FB62",
52
+ muiPrimaryBlack: "#FFFFFF",
53
+ lightMuiPrimaryColorBackground: "#e9fb6214",
54
+ lightBlueBackground: "#e9fb6214",
55
+ muiPrimaryAlternate: "#07BAF1",
56
+ muiPrimaryHover: "#1890d5",
57
+ muiSecondary: "#DE5B99",
58
+ muiSecondaryAlternate: "#EC613C",
59
+ muiSuccess: "#66BB6A",
60
+ muiSuccessAlternate: "#81C784",
61
+ // Transparency variants
62
+ blackOpacity10: "inherit",
63
+ blackOpacity20: "inherit",
64
+ blackOpacity30: "inherit",
65
+ blackOpacity50: "inherit",
66
+ blackOpacity80: "inherit",
67
+ primaryOpacity10: "rgba(233, 251, 98, 0.10)",
68
+ primaryOpacity20: "rgba(233, 251, 98, 0.20)",
69
+ primaryOpacity30: "rgba(233, 251, 98, 0.30)",
70
+ secondaryAlternateOpacity30: "rgba(236, 97, 60, .3)",
71
+ blueOpacity08: "rgba(25, 118, 210, 0.08)",
72
+ whiteOpacity10: "rgba(255,255,255,0.1)",
73
+ whiteOpacity20: "rgba(255,255,255,0.2)",
74
+ whiteOpacity40: "rgba(255,255,255,0.4)",
75
+ // Table rows and top bar
76
+ topBar: "#2e3133",
77
+ // Button colors
78
+ // Round Button (default)
79
+ buttonHoverBackground: "rgba(255, 255, 255, 0.08)",
80
+ // Active Button
81
+ buttonActiveText: "#E9FB62",
82
+ // Contrast Button
83
+ buttonContrastBorder: "#CECECE",
84
+ buttonContrastText: "#CECECE",
85
+ // Error Button
86
+ error: "#EF5350"
87
+ };
88
+ var darkPalette_default = darkPalette;
89
+
90
+ // src/resources/styles/colors/lightPalette.ts
91
+ var lightPalette = {
92
+ // General colors
93
+ white: "#FFFFFF",
94
+ black: "#000000",
95
+ // Neutral
96
+ neutral50: "#F0EBE6",
97
+ neutral100: "#FAFAFA",
98
+ neutral150: "#F4F4F4",
99
+ neutral200: "#F1F1F1",
100
+ neutral250: "#ECECEC",
101
+ neutral300: "#E0E0E0",
102
+ neutral400: "#C8C8C8",
103
+ neutral500: "#BDBDBD",
104
+ neutral600: "#999999",
105
+ neutral700: "#878787",
106
+ neutral750: "#6c6c6c",
107
+ neutral800: "#555555",
108
+ neutral900: "#4D4D4D",
109
+ // Input and contrast
110
+ contrast: "#000000",
111
+ constrastOpacity50: "rgba(0,0,0,0.5)",
112
+ // Icon and Material UI colors
113
+ iconSearch: "#606060",
114
+ default: "#E0E0E0",
115
+ muiPrimary: "#0781CE",
116
+ muiPrimaryBlack: "#000000",
117
+ lightMuiPrimaryColorBackground: "#eff4fb",
118
+ lightBlueBackground: "#eff4fb",
119
+ muiPrimaryAlternate: "#07BAF1",
120
+ muiPrimaryHover: "#1565c0",
121
+ muiSecondary: "#A42966",
122
+ muiSecondaryAlternate: "#EC613C",
123
+ muiSuccess: "#4caf50",
124
+ muiSuccessAlternate: "#357a38",
125
+ // Transparency variants
126
+ blackOpacity10: "rgba(0,0,0,0.1)",
127
+ blackOpacity20: "rgba(0,0,0,0.2)",
128
+ blackOpacity30: "rgba(0,0,0,0.3)",
129
+ blackOpacity50: "rgba(0,0,0,0.5)",
130
+ blackOpacity80: "rgba(0,0,0,0.8)",
131
+ primaryOpacity10: "rgba(7, 129, 206, 0.10)",
132
+ primaryOpacity20: "rgba(7, 129, 206, 0.20)",
133
+ primaryOpacity30: "rgba(7, 129, 206, 0.30)",
134
+ secondaryAlternateOpacity30: "rgba(236, 97, 60, 0.3)",
135
+ blueOpacity08: "rgba(25, 118, 210, 0.08)",
136
+ whiteOpacity10: "rgba(255,255,255,0.1)",
137
+ whiteOpacity20: "rgba(255,255,255,0.2)",
138
+ whiteOpacity40: "rgba(255,255,255,0.4)",
139
+ // Table rows and top bar
140
+ topBar: "#2e3133",
141
+ // Button colors
142
+ // Round Button (default)
143
+ buttonHoverBackground: "rgba(0, 0, 0, 0.04)",
144
+ // Active Button
145
+ buttonActiveText: "#0781CE",
146
+ // Contrast Button
147
+ buttonContrastBorder: "#CECECE",
148
+ buttonContrastText: "#CECECE",
149
+ // Error Button
150
+ error: "#D32F2F"
151
+ };
152
+ var lightPalette_default = lightPalette;
153
+
154
+ // src/resources/styles/colors.ts
155
+ var stylesheet = localStorage.getItem("@stylesheet");
156
+ var isDarkModeEnabled = stylesheet === "styles/style-dark.css";
157
+ var palette = isDarkModeEnabled ? darkPalette_default : lightPalette_default;
158
+ var colors = {
159
+ white: palette.white,
160
+ black: palette.black,
161
+ neutral50: palette.neutral50,
162
+ neutral100: palette.neutral100,
163
+ neutral150: palette.neutral150,
164
+ neutral200: palette.neutral200,
165
+ neutral250: palette.neutral250,
166
+ neutral300: palette.neutral300,
167
+ neutral400: palette.neutral400,
168
+ neutral500: palette.neutral500,
169
+ neutral600: palette.neutral600,
170
+ neutral700: palette.neutral700,
171
+ neutral750: palette.neutral750,
172
+ neutral800: palette.neutral800,
173
+ neutral900: palette.neutral900,
174
+ // Input and contrast
175
+ contrast: palette.contrast,
176
+ constrastOpacity50: palette.constrastOpacity50,
177
+ iconSearch: palette.iconSearch,
178
+ default: palette.default,
179
+ muiPrimary: palette.muiPrimary,
180
+ muiPrimaryBlack: palette.muiPrimaryBlack,
181
+ lightMuiPrimaryColorBackground: palette.lightMuiPrimaryColorBackground,
182
+ lightBlueBackground: palette.lightBlueBackground,
183
+ muiPrimaryAlternate: palette.muiPrimaryAlternate,
184
+ muiPrimaryHover: palette.muiPrimaryHover,
185
+ muiSecondary: palette.muiSecondary,
186
+ muiSecondaryAlternate: palette.muiSecondaryAlternate,
187
+ muiSuccess: palette.muiSuccess,
188
+ muiSuccessAlternate: palette.muiSuccessAlternate,
189
+ // Transparency
190
+ blackOpacity10: palette.blackOpacity10,
191
+ blackOpacity20: palette.blackOpacity20,
192
+ blackOpacity30: palette.blackOpacity30,
193
+ blackOpacity50: palette.blackOpacity50,
194
+ blackOpacity80: palette.blackOpacity80,
195
+ primaryOpacity10: palette.primaryOpacity10,
196
+ primaryOpacity20: palette.primaryOpacity20,
197
+ primaryOpacity30: palette.primaryOpacity30,
198
+ secondaryAlternateOpacity30: palette.secondaryAlternateOpacity30,
199
+ blueOpacity08: palette.blueOpacity08,
200
+ whiteOpacity10: palette.whiteOpacity10,
201
+ whiteOpacity20: palette.whiteOpacity20,
202
+ whiteOpacity40: palette.whiteOpacity40,
203
+ topBar: palette.topBar,
204
+ error: palette.error,
205
+ roundButton: {
206
+ default: {
207
+ border: palette.neutral600,
208
+ color: palette.contrast,
209
+ disabled: {
210
+ color: palette.blackOpacity20
211
+ },
212
+ hover: {
213
+ background: palette.buttonHoverBackground
214
+ }
215
+ },
216
+ filled: {
217
+ background: palette.neutral100,
218
+ color: palette.blackOpacity80,
219
+ hover: {
220
+ background: palette.neutral250
221
+ }
222
+ },
223
+ active: {
224
+ color: palette.buttonActiveText,
225
+ hover: {
226
+ background: palette.primaryOpacity20
227
+ }
228
+ },
229
+ contrast: {
230
+ border: palette.buttonContrastBorder,
231
+ color: palette.buttonContrastText,
232
+ hover: {
233
+ background: palette.whiteOpacity10
234
+ }
235
+ },
236
+ tableButton: {
237
+ color: palette.neutral800
238
+ },
239
+ focused: {
240
+ background: palette.primaryOpacity20,
241
+ color: palette.buttonActiveText,
242
+ hover: {
243
+ background: palette.primaryOpacity30
244
+ }
245
+ },
246
+ error: palette.error
247
+ },
248
+ movementCard: {
249
+ default: {
250
+ background: palette.neutral100
251
+ },
252
+ disabled: {
253
+ background: palette.neutral250
254
+ },
255
+ pill: {
256
+ color: palette.neutral200,
257
+ background: palette.neutral600
258
+ }
259
+ },
260
+ rowProductCard: {
261
+ locationSubtitle: palette.neutral800
262
+ }
263
+ };
264
+
265
+ // src/config/drawerAppList.tsx
266
+ import { useMemo } from "react";
267
+ import { icons } from "@natoora-libs/core/components";
268
+
269
+ // src/config/features.ts
270
+ var featureNames = {
271
+ ACCOUNTS: "accounts",
272
+ ADMIN: "admin",
273
+ AIRCALL: "aircall",
274
+ BULK_UPDATE: "product_bulk_update",
275
+ CONTENT_MANAGEMENT: "content_management",
276
+ CUSTOMERS: "customers",
277
+ GOODS_IN: "goods_in",
278
+ KANBAN: "kanban_cards",
279
+ LOCATIONS: "locations",
280
+ NOTIFICATIONS: "notifications",
281
+ OPS_METRICS: "ops_metrics",
282
+ ORDERS: "orders",
283
+ PICKING_STATIONS: "picking_stations",
284
+ PRICE_LIST: "price_list",
285
+ PRODUCTS: "products",
286
+ PROMO_CODES: "promo_codes",
287
+ PURCHASE_ORDERS: "purchase_orders",
288
+ QUALITY_CONTROL: "quality_control",
289
+ REPORTS: "reports",
290
+ RETAIL: "retail",
291
+ RETURNS: "returns",
292
+ SEARCH_CATEGORIES: "search_categories",
293
+ SERVICE_DELIVERY: "service_delivery",
294
+ SPECIAL_PRICES: "special_prices",
295
+ STOCK: "stock",
296
+ STOCK_MOVEMENTS: "stock_movements",
297
+ SUPPLIERS: "suppliers",
298
+ SUPPLIER_PRICES: "supplier_prices",
299
+ USER_MANAGEMENT: "users"
300
+ };
301
+ function featuresAreEnabled({
302
+ enabledFeatures,
303
+ featureNames: featureNames2,
304
+ requireAll = true
305
+ }) {
306
+ const storedPermissions = localStorage.getItem("permissions") || "";
307
+ let enabled = false;
308
+ if (requireAll) {
309
+ enabled = featureNames2.every(
310
+ (feature) => enabledFeatures.includes(feature) && storedPermissions.includes(`${feature}_read`)
311
+ );
312
+ } else {
313
+ enabled = featureNames2.some(
314
+ (feature) => enabledFeatures.includes(feature) && storedPermissions.includes(`${feature}_read`)
315
+ );
316
+ }
317
+ return enabled;
318
+ }
319
+
320
+ // src/config/drawerAppList.tsx
321
+ import { jsx } from "react/jsx-runtime";
322
+ var drawerAppList = [
323
+ {
324
+ groupName: "Home",
325
+ apps: [
326
+ {
327
+ name: "Home",
328
+ routeName: "home",
329
+ alwaysDisplay: true,
330
+ featureNames: [],
331
+ pinned: null,
332
+ icon: /* @__PURE__ */ jsx(icons.SvgIconHome, {}),
333
+ url: "/#/",
334
+ shouldReload: true
335
+ }
336
+ ]
337
+ },
338
+ {
339
+ groupName: "App",
340
+ apps: [
341
+ {
342
+ name: "Notifications",
343
+ routeName: "appNotifications",
344
+ alwaysDisplay: false,
345
+ featureNames: [featureNames.NOTIFICATIONS],
346
+ pinned: "notifications",
347
+ icon: /* @__PURE__ */ jsx(icons.SvgIconNotification, {}),
348
+ url: "/#/notifications",
349
+ shouldReload: true
350
+ },
351
+ {
352
+ name: "Promo Codes",
353
+ routeName: "promo_codes",
354
+ alwaysDisplay: false,
355
+ featureNames: [featureNames.PROMO_CODES],
356
+ pinned: "promo_codes",
357
+ icon: /* @__PURE__ */ jsx(icons.SvgIconPromoCode, {}),
358
+ url: "/promo_codes"
359
+ },
360
+ {
361
+ name: "Search Categories",
362
+ routeName: "search-categories",
363
+ alwaysDisplay: false,
364
+ featureNames: [featureNames.SEARCH_CATEGORIES],
365
+ pinned: "search_categories",
366
+ icon: /* @__PURE__ */ jsx(icons.SvgIconSearchCategories, {}),
367
+ url: "/search-categories"
368
+ },
369
+ {
370
+ name: "Content Management",
371
+ routeName: "content-management",
372
+ alwaysDisplay: false,
373
+ featureNames: [featureNames.CONTENT_MANAGEMENT],
374
+ pinned: "content_management",
375
+ icon: /* @__PURE__ */ jsx(icons.SvgIconContentManagement, {}),
376
+ url: "/content-management"
377
+ }
378
+ ]
379
+ },
380
+ {
381
+ groupName: "Customer Service",
382
+ apps: [
383
+ {
384
+ name: "Aircall",
385
+ routeName: "recordedcalls",
386
+ alwaysDisplay: false,
387
+ featureNames: [featureNames.AIRCALL],
388
+ pinned: "aircall",
389
+ icon: /* @__PURE__ */ jsx(icons.SvgIconPhone, {}),
390
+ url: "/air-call"
391
+ },
392
+ {
393
+ name: "Customers",
394
+ routeName: "customers",
395
+ alwaysDisplay: false,
396
+ featureNames: [featureNames.CUSTOMERS],
397
+ pinned: "customers",
398
+ icon: /* @__PURE__ */ jsx(icons.SvgIconAccount, {}),
399
+ url: "/customers",
400
+ children: [
401
+ {
402
+ name: "Sites",
403
+ routeName: "customer-sites",
404
+ pinned: "customer-sites",
405
+ url: "/customers/sites"
406
+ },
407
+ {
408
+ name: "Groups",
409
+ routeName: "customer-groups",
410
+ pinned: "customer-groups",
411
+ url: "/customers/groups"
412
+ }
413
+ ]
414
+ },
415
+ {
416
+ name: "Orders",
417
+ routeName: "orders",
418
+ alwaysDisplay: false,
419
+ featureNames: [featureNames.ORDERS],
420
+ pinned: "orders",
421
+ icon: /* @__PURE__ */ jsx(icons.SvgIconOrders, {}),
422
+ url: "/#/orders",
423
+ shouldReload: true
424
+ },
425
+ {
426
+ name: "Price Lists",
427
+ routeName: "price_list",
428
+ alwaysDisplay: false,
429
+ featureNames: [featureNames.PRICE_LIST],
430
+ pinned: "price_list",
431
+ icon: /* @__PURE__ */ jsx(icons.SvgIconPriceList, {}),
432
+ url: "/#/price-list",
433
+ shouldReload: true
434
+ },
435
+ {
436
+ name: "Special Prices",
437
+ routeName: "special_prices",
438
+ alwaysDisplay: false,
439
+ featureNames: [featureNames.SPECIAL_PRICES],
440
+ pinned: "special_prices",
441
+ icon: /* @__PURE__ */ jsx(icons.SvgIconSpecialPrice, {}),
442
+ url: "/#/pricing/special-prices",
443
+ shouldReload: true
444
+ }
445
+ ]
446
+ },
447
+ {
448
+ groupName: "Buying",
449
+ apps: [
450
+ {
451
+ name: "Purchase Orders",
452
+ routeName: "purchaseOrders",
453
+ alwaysDisplay: false,
454
+ featureNames: [featureNames.PURCHASE_ORDERS],
455
+ pinned: "purchase_orders",
456
+ icon: /* @__PURE__ */ jsx(icons.SvgIconBuying, {}),
457
+ url: "/react/purchase-orders",
458
+ shouldReload: true
459
+ },
460
+ {
461
+ name: "Products",
462
+ routeName: "products",
463
+ alwaysDisplay: false,
464
+ featureNames: [featureNames.PRODUCTS],
465
+ pinned: "products",
466
+ icon: /* @__PURE__ */ jsx(icons.SvgIconProducts, {}),
467
+ url: "/#/product-base-list",
468
+ shouldReload: true
469
+ },
470
+ {
471
+ name: "Suppliers",
472
+ routeName: "suppliers",
473
+ alwaysDisplay: false,
474
+ featureNames: [featureNames.SUPPLIERS],
475
+ pinned: "suppliers",
476
+ icon: /* @__PURE__ */ jsx(icons.SvgIconSupplier, {}),
477
+ url: "/suppliers"
478
+ },
479
+ {
480
+ name: "Supplier Prices",
481
+ routeName: "supplier_prices",
482
+ alwaysDisplay: false,
483
+ featureNames: [featureNames.SUPPLIER_PRICES],
484
+ pinned: "supplier_prices",
485
+ icon: /* @__PURE__ */ jsx(icons.SvgIconSupplierPrices, {}),
486
+ url: "/#/supplier-prices",
487
+ shouldReload: true
488
+ },
489
+ {
490
+ name: "Product Bulk Update",
491
+ routeName: "bulk-update",
492
+ alwaysDisplay: false,
493
+ featureNames: [featureNames.BULK_UPDATE],
494
+ pinned: "product_bulk_update",
495
+ icon: /* @__PURE__ */ jsx(icons.SvgIconImport, {}),
496
+ url: "/bulk_update"
497
+ }
498
+ ]
499
+ },
500
+ {
501
+ groupName: "Operations",
502
+ apps: [
503
+ {
504
+ name: "Retail",
505
+ routeName: "retail",
506
+ alwaysDisplay: false,
507
+ featureNames: [featureNames.RETAIL],
508
+ pinned: "retail",
509
+ icon: /* @__PURE__ */ jsx(icons.SvgIconRetail, {}),
510
+ url: "/#/retail/product-availability",
511
+ shouldReload: true
512
+ },
513
+ {
514
+ name: "Goods In",
515
+ routeName: "goodsin-list",
516
+ alwaysDisplay: false,
517
+ featureNames: [featureNames.GOODS_IN],
518
+ pinned: "goods_in",
519
+ icon: /* @__PURE__ */ jsx(icons.SvgIconGoodsin, {}),
520
+ url: "/goodsin-list"
521
+ },
522
+ {
523
+ name: "Returns",
524
+ routeName: "goods-in-list",
525
+ alwaysDisplay: false,
526
+ featureNames: [featureNames.RETURNS],
527
+ pinned: "returns",
528
+ icon: /* @__PURE__ */ jsx(icons.SvgIconGoodsin, {}),
529
+ url: "/returns"
530
+ },
531
+ {
532
+ icon: /* @__PURE__ */ jsx(icons.SvgIconLocation, {}),
533
+ name: "Stock and Locations",
534
+ pinned: "stock",
535
+ routeName: "locations",
536
+ featureNames: [featureNames.STOCK, featureNames.LOCATIONS],
537
+ alwaysDisplay: false,
538
+ url: "/locations",
539
+ children: [
540
+ {
541
+ name: "Movements",
542
+ routeName: "movements",
543
+ url: "/movements",
544
+ featureName: featureNames.STOCK_MOVEMENTS
545
+ }
546
+ ]
547
+ },
548
+ {
549
+ name: "Kanban Cards",
550
+ routeName: "kanban",
551
+ alwaysDisplay: false,
552
+ featureNames: [featureNames.KANBAN],
553
+ pinned: "kanban_cards",
554
+ icon: /* @__PURE__ */ jsx(icons.SvgIconVkc, {}),
555
+ url: "/#/kanban",
556
+ shouldReload: true
557
+ },
558
+ {
559
+ name: "Picking Stations",
560
+ routeName: "picking",
561
+ alwaysDisplay: false,
562
+ featureNames: [featureNames.PICKING_STATIONS],
563
+ pinned: "picking_stations",
564
+ icon: /* @__PURE__ */ jsx(icons.SvgIconScales, {}),
565
+ url: "/#/pickingstation",
566
+ shouldReload: true
567
+ },
568
+ {
569
+ name: "Quality Control",
570
+ routeName: "qualityControl",
571
+ alwaysDisplay: false,
572
+ featureNames: [featureNames.QUALITY_CONTROL],
573
+ pinned: "quality_control",
574
+ icon: /* @__PURE__ */ jsx(icons.SvgIconQc, {}),
575
+ url: "/#/quality-control",
576
+ shouldReload: true
577
+ },
578
+ {
579
+ name: "Service Delivery",
580
+ routeName: "runs",
581
+ alwaysDisplay: false,
582
+ featureNames: [featureNames.SERVICE_DELIVERY],
583
+ pinned: "service_delivery",
584
+ icon: /* @__PURE__ */ jsx(icons.SvgIconRuns, {}),
585
+ url: "/#/runs",
586
+ shouldReload: true
587
+ },
588
+ {
589
+ name: "Ops Metrics",
590
+ routeName: "ops-metrics",
591
+ alwaysDisplay: false,
592
+ featureNames: [featureNames.OPS_METRICS],
593
+ pinned: "ops_metrics",
594
+ icon: /* @__PURE__ */ jsx(icons.SvgIconOpsMetrics, {}),
595
+ url: "/ops-metrics"
596
+ }
597
+ ]
598
+ },
599
+ {
600
+ groupName: "Tools",
601
+ apps: [
602
+ {
603
+ name: "Accounts",
604
+ routeName: "accounts",
605
+ alwaysDisplay: false,
606
+ featureNames: [featureNames.ACCOUNTS],
607
+ pinned: "accounts",
608
+ icon: /* @__PURE__ */ jsx(icons.SvgIconAccounts, {}),
609
+ url: "/#/accounts",
610
+ shouldReload: true
611
+ },
612
+ {
613
+ name: "Reports",
614
+ routeName: "reports",
615
+ alwaysDisplay: false,
616
+ featureNames: [featureNames.REPORTS],
617
+ pinned: "reports",
618
+ icon: /* @__PURE__ */ jsx(icons.SvgIconReports, {}),
619
+ url: "/#/reports",
620
+ shouldReload: true
621
+ }
622
+ ]
623
+ },
624
+ {
625
+ groupName: "Settings",
626
+ apps: [
627
+ {
628
+ name: "Admin",
629
+ routeName: "admin",
630
+ alwaysDisplay: false,
631
+ featureNames: [featureNames.ADMIN],
632
+ pinned: "admin",
633
+ icon: /* @__PURE__ */ jsx(icons.SvgIconSetting, {}),
634
+ url: "/#/admin",
635
+ shouldReload: true
636
+ },
637
+ {
638
+ name: "User Management",
639
+ routeName: "user-management",
640
+ alwaysDisplay: false,
641
+ featureNames: [featureNames.USER_MANAGEMENT],
642
+ pinned: "users",
643
+ icon: /* @__PURE__ */ jsx(icons.SvgIconUserManagement, {}),
644
+ url: "/user-management"
645
+ },
646
+ {
647
+ name: "Logout",
648
+ routeName: "logout",
649
+ alwaysDisplay: true,
650
+ featureNames: [],
651
+ pinned: null,
652
+ icon: /* @__PURE__ */ jsx(icons.SvgIconLogin, {}),
653
+ url: "/logout"
654
+ }
655
+ ]
656
+ },
657
+ {
658
+ groupName: "Release Notes",
659
+ apps: [
660
+ {
661
+ name: "Release Notes",
662
+ routeName: "release-notes",
663
+ alwaysDisplay: true,
664
+ featureNames: [],
665
+ pinned: null,
666
+ // icon: <icons.SvgIconReleaseNote />,
667
+ icon: /* @__PURE__ */ jsx(icons.SvgIconLogin, {}),
668
+ url: "/release-notes"
669
+ }
670
+ ]
671
+ }
672
+ ];
673
+ var useGetDrawerAppList = (enabledFeatures) => {
674
+ return useMemo(() => {
675
+ if (!enabledFeatures?.length) {
676
+ return [];
677
+ }
678
+ return drawerAppList.map((group) => {
679
+ const enabledApps = group.apps.filter(
680
+ (app) => app.alwaysDisplay || featuresAreEnabled({
681
+ enabledFeatures,
682
+ featureNames: app.featureNames,
683
+ requireAll: false
684
+ })
685
+ ).map((app) => {
686
+ if (app.children) {
687
+ const filteredChildren = app.children.filter(
688
+ (child) => {
689
+ if (child.featureName) {
690
+ return enabledFeatures.includes(child.featureName);
691
+ }
692
+ return true;
693
+ }
694
+ );
695
+ return { ...app, children: filteredChildren };
696
+ }
697
+ return app;
698
+ });
699
+ return { ...group, apps: enabledApps };
700
+ }).filter((group) => group.apps.length > 0);
701
+ }, [enabledFeatures]);
702
+ };
703
+
704
+ // src/components/LeftDrawer/LeftDrawer.tsx
705
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
706
+ var useStyles = makeStyles()((theme) => ({
707
+ subheader: {
708
+ textTransform: "uppercase",
709
+ fontSize: theme.spacing(1.5)
710
+ },
711
+ menuButton: {
712
+ marginRight: theme.spacing(2)
713
+ },
714
+ inputRoot: {
715
+ color: "inherit"
716
+ },
717
+ inputInput: {
718
+ transition: theme.transitions.create("width"),
719
+ width: "100%"
720
+ },
721
+ topBar: {
722
+ backgroundColor: theme.palette.secondary.dark,
723
+ width: theme.spacing(40),
724
+ padding: theme.spacing(2),
725
+ display: "flex",
726
+ alignItems: "end",
727
+ justifyContent: "space-between"
728
+ },
729
+ drawer: {
730
+ alignContent: "space-between",
731
+ flexDirection: "column",
732
+ minWidth: theme.spacing(80)
733
+ },
734
+ drawerBody: {
735
+ minWidth: "300px",
736
+ flexGrow: 1,
737
+ padding: theme.spacing(3)
738
+ },
739
+ drawerItem: {
740
+ width: "300px",
741
+ marginBottom: theme.spacing(1)
742
+ },
743
+ button: {
744
+ color: theme.palette.primary.contrastText
745
+ },
746
+ iconMenu: {
747
+ height: "40px",
748
+ width: "40px",
749
+ opacity: 1,
750
+ fill: colors.neutral700
751
+ },
752
+ pinIcon: {
753
+ height: "16px",
754
+ width: "16px",
755
+ fill: colors.neutral700,
756
+ opacity: 0.5,
757
+ "&:hover": {
758
+ opacity: 1,
759
+ cursor: "pointer"
760
+ }
761
+ },
762
+ expandIcon: {
763
+ height: "22px",
764
+ width: "22px",
765
+ fill: colors.neutral700
766
+ },
767
+ nested: {
768
+ paddingLeft: theme.spacing(6),
769
+ border: colors.neutral200
770
+ },
771
+ appName: {
772
+ "& .MuiTypography-body2": {
773
+ fontWeight: 700
774
+ }
775
+ }
776
+ }));
777
+ var LeftDrawer = ({
778
+ enabledFeatures,
779
+ pinnedApps,
780
+ open,
781
+ user,
782
+ handleClose,
783
+ handleOpen,
784
+ onLogout,
785
+ onTogglePinnedApp
786
+ }) => {
787
+ const navigate = useNavigate();
788
+ const [openCollapse, setOpenCollapse] = useState({});
789
+ const drawerAppList2 = useGetDrawerAppList(enabledFeatures);
790
+ const { classes } = useStyles();
791
+ const navigateTo = (url, shouldReload) => {
792
+ if (shouldReload) {
793
+ const fullUrl = `${window.location.origin}${url}`;
794
+ window.location.href = fullUrl;
795
+ return;
796
+ }
797
+ return navigate(url);
798
+ };
799
+ console.log({ drawerAppList: drawerAppList2 });
800
+ return /* @__PURE__ */ jsxs(
801
+ SwipeableDrawer,
802
+ {
803
+ className: classes.drawer,
804
+ id: "primary-menu",
805
+ onClose: handleClose,
806
+ onOpen: handleOpen,
807
+ open,
808
+ children: [
809
+ /* @__PURE__ */ jsx2(AppBar, { position: "static", children: /* @__PURE__ */ jsxs(Toolbar, { className: classes.topBar, children: [
810
+ /* @__PURE__ */ jsx2(
811
+ UserBust,
812
+ {
813
+ user,
814
+ avatarProps: { height: 50, width: 50 },
815
+ typographyProps: {
816
+ name: { variant: "subtitle1", component: "div" },
817
+ username: { variant: "caption", component: "div" }
818
+ }
819
+ }
820
+ ),
821
+ /* @__PURE__ */ jsx2(
822
+ RoundButton,
823
+ {
824
+ icon: "edit",
825
+ isContrast: true,
826
+ onClick: () => navigateTo(`/#/user-settings`, true),
827
+ size: "small",
828
+ tooltip: "User Settings"
829
+ }
830
+ )
831
+ ] }) }),
832
+ /* @__PURE__ */ jsx2(List, { children: drawerAppList2.map((group) => /* @__PURE__ */ jsxs(Fragment, { children: [
833
+ /* @__PURE__ */ jsx2(ListSubheader, { disableSticky: true, className: classes.subheader, children: group.groupName }),
834
+ group.apps.map((app) => /* @__PURE__ */ jsxs(Fragment, { children: [
835
+ /* @__PURE__ */ jsxs(
836
+ ListItem,
837
+ {
838
+ title: app.url,
839
+ onClick: () => {
840
+ if (app.routeName === "logout") {
841
+ return onLogout();
842
+ }
843
+ return navigateTo(app.url, app.shouldReload);
844
+ },
845
+ children: [
846
+ /* @__PURE__ */ jsx2(ListItemIcon, { children: /* @__PURE__ */ jsx2(Icon, { className: classes.iconMenu, children: app.icon }) }),
847
+ /* @__PURE__ */ jsx2(
848
+ ListItemText,
849
+ {
850
+ className: classes.appName,
851
+ primary: app.name,
852
+ slotProps: { primary: { variant: "body2" } }
853
+ }
854
+ ),
855
+ /* @__PURE__ */ jsxs(
856
+ Box,
857
+ {
858
+ display: "flex",
859
+ gap: 2,
860
+ alignItems: "center",
861
+ justifyContent: "center",
862
+ children: [
863
+ app.children?.length > 0 && /* @__PURE__ */ jsx2(
864
+ ExpandLess,
865
+ {
866
+ className: classes.expandIcon,
867
+ style: {
868
+ rotate: openCollapse[app.routeName] ? "0deg" : "180deg"
869
+ },
870
+ "data-testid": "svg-close-collapse",
871
+ onClick: (event) => {
872
+ event.stopPropagation();
873
+ setOpenCollapse({
874
+ ...openCollapse,
875
+ [app.routeName]: !openCollapse[app.routeName]
876
+ });
877
+ }
878
+ }
879
+ ),
880
+ app.pinned && /* @__PURE__ */ jsx2(
881
+ PushPinOutlined,
882
+ {
883
+ className: classes.pinIcon,
884
+ style: { opacity: pinnedApps[app.pinned] ? 1 : 0.3 },
885
+ onClick: (event) => {
886
+ event.stopPropagation();
887
+ onTogglePinnedApp(
888
+ app.pinned,
889
+ !pinnedApps[app.pinned]
890
+ );
891
+ }
892
+ }
893
+ )
894
+ ]
895
+ }
896
+ )
897
+ ]
898
+ },
899
+ app.name
900
+ ),
901
+ app.children?.length > 0 && /* @__PURE__ */ jsx2(Collapse, { in: openCollapse[app.routeName], children: /* @__PURE__ */ jsx2(List, { children: app.children.map((child) => /* @__PURE__ */ jsxs(
902
+ ListItemButton,
903
+ {
904
+ className: classes.nested,
905
+ disabled: child.disabled,
906
+ onClick: () => navigateTo(child.url, child.shouldReload),
907
+ title: child.url,
908
+ children: [
909
+ /* @__PURE__ */ jsx2(ListItemIcon, { children: /* @__PURE__ */ jsx2(FiberManualRecord, { style: { height: 12 } }) }),
910
+ /* @__PURE__ */ jsx2(
911
+ ListItemText,
912
+ {
913
+ primary: child.name,
914
+ slotProps: { primary: { variant: "body2" } }
915
+ }
916
+ )
917
+ ]
918
+ },
919
+ child.name
920
+ )) }) })
921
+ ] }, `${group.groupName}_${app.name}`))
922
+ ] }, group.groupName)) })
923
+ ]
924
+ }
925
+ );
926
+ };
927
+ var LeftDrawer_default = LeftDrawer;
928
+ export {
929
+ LeftDrawer_default as LeftDrawer
930
+ };
931
+ //# sourceMappingURL=index.js.map