@tuturuuu/utils 0.0.3 → 0.6.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +313 -0
  2. package/biome.json +5 -0
  3. package/jsr.json +8 -8
  4. package/package.json +63 -32
  5. package/src/__tests__/ai-temp-auth.test.ts +309 -0
  6. package/src/__tests__/api-proxy-guard.test.ts +1451 -0
  7. package/src/__tests__/app-url.test.ts +270 -0
  8. package/src/__tests__/avatar-url.test.ts +97 -0
  9. package/src/__tests__/color-helper.test.ts +179 -0
  10. package/src/__tests__/constants.test.ts +351 -0
  11. package/src/__tests__/crypto.test.ts +107 -0
  12. package/src/__tests__/date-helper.test.ts +408 -0
  13. package/src/__tests__/fixtures/task-description-full-featured.json +456 -0
  14. package/src/__tests__/format.test.ts +317 -0
  15. package/src/__tests__/html-sanitizer.test.ts +360 -0
  16. package/src/__tests__/interest-calculator.test.ts +336 -0
  17. package/src/__tests__/interest-detector.test.ts +222 -0
  18. package/src/__tests__/label-colors.test.ts +241 -0
  19. package/src/__tests__/name-helper.test.ts +158 -0
  20. package/src/__tests__/node-diff.test.ts +576 -0
  21. package/src/__tests__/notification-service.test.ts +210 -0
  22. package/src/__tests__/onboarding-helper.test.ts +331 -0
  23. package/src/__tests__/path-helper.test.ts +152 -0
  24. package/src/__tests__/permissions.test.tsx +81 -0
  25. package/src/__tests__/request-emoji-limit.test.ts +172 -0
  26. package/src/__tests__/search-helper.test.ts +51 -0
  27. package/src/__tests__/storage-display-name.test.ts +37 -0
  28. package/src/__tests__/storage-path.test.ts +238 -0
  29. package/src/__tests__/tag-utils.test.ts +205 -0
  30. package/src/__tests__/task-description-yjs-state.test.ts +581 -0
  31. package/src/__tests__/task-helper-board-api-routing.test.ts +94 -0
  32. package/src/__tests__/task-helper-create-task.test.ts +129 -0
  33. package/src/__tests__/task-helpers.test.ts +464 -0
  34. package/src/__tests__/task-overrides.test.ts +305 -0
  35. package/src/__tests__/task-reorder-cache.test.ts +74 -0
  36. package/src/__tests__/task-sort-keys.test.ts +36 -0
  37. package/src/__tests__/task-transformers.test.ts +62 -0
  38. package/src/__tests__/text-helper.test.ts +776 -0
  39. package/src/__tests__/time-helper.test.ts +70 -0
  40. package/src/__tests__/time-tracker-period.test.ts +55 -0
  41. package/src/__tests__/timezone.test.ts +117 -0
  42. package/src/__tests__/upstash-rest.test.ts +77 -0
  43. package/src/__tests__/uuid-helper.test.ts +133 -0
  44. package/src/__tests__/workspace-helper.test.ts +859 -0
  45. package/src/__tests__/workspace-limits.test.ts +255 -0
  46. package/src/__tests__/yjs-helper.test.ts +581 -0
  47. package/src/abuse-protection/__tests__/backend-rate-limit.test.ts +113 -0
  48. package/src/abuse-protection/__tests__/edge.test.ts +136 -0
  49. package/src/abuse-protection/__tests__/index.test.ts +562 -0
  50. package/src/abuse-protection/__tests__/reputation.test.ts +192 -0
  51. package/src/abuse-protection/backend-rate-limit.ts +44 -0
  52. package/src/abuse-protection/constants.ts +117 -0
  53. package/src/abuse-protection/edge.ts +223 -0
  54. package/src/abuse-protection/index.ts +1545 -0
  55. package/src/abuse-protection/reputation.ts +587 -0
  56. package/src/abuse-protection/types.ts +97 -0
  57. package/src/abuse-protection/user-agent.ts +124 -0
  58. package/src/abuse-protection/user-suspension.ts +231 -0
  59. package/src/ai-temp-auth.ts +315 -0
  60. package/src/api-proxy-guard.ts +965 -0
  61. package/src/app-url.ts +96 -0
  62. package/src/avatar-url.ts +64 -0
  63. package/src/break-duration.ts +84 -0
  64. package/src/calendar-auth-token.test.ts +37 -0
  65. package/src/calendar-auth-token.ts +19 -0
  66. package/src/calendar-sync-coordination.md +197 -0
  67. package/src/calendar-utils.test.ts +169 -0
  68. package/src/calendar-utils.ts +91 -0
  69. package/src/color-helper.ts +110 -0
  70. package/src/common/nextjs.tsx +99 -0
  71. package/src/common/scan.tsx +15 -0
  72. package/src/configs/reports.ts +160 -0
  73. package/src/constants.ts +85 -0
  74. package/src/crypto.ts +21 -0
  75. package/src/currencies.ts +97 -0
  76. package/src/date-helper.ts +313 -0
  77. package/src/editor/convert-to-task.ts +264 -0
  78. package/src/editor/index.ts +5 -0
  79. package/src/email/__tests__/client.test.ts +141 -0
  80. package/src/email/__tests__/validation.test.ts +46 -0
  81. package/src/email/client.ts +92 -0
  82. package/src/email/server.ts +128 -0
  83. package/src/email/validation.ts +11 -0
  84. package/src/encryption/__tests__/calendar-events.test.ts +411 -0
  85. package/src/encryption/__tests__/configuration.test.ts +114 -0
  86. package/src/encryption/__tests__/field-encryption.test.ts +232 -0
  87. package/src/encryption/__tests__/key-generation.test.ts +30 -0
  88. package/src/encryption/__tests__/performance-edge-cases.test.ts +187 -0
  89. package/src/encryption/__tests__/test-helpers.ts +22 -0
  90. package/src/encryption/__tests__/workspace-key-encryption.test.ts +129 -0
  91. package/src/encryption/encryption-service.ts +343 -0
  92. package/src/encryption/index.ts +25 -0
  93. package/src/encryption/types.ts +57 -0
  94. package/src/exchange-rates.ts +49 -0
  95. package/src/feature-flags/__tests__/feature-flags.test.ts +302 -0
  96. package/src/feature-flags/core.ts +322 -0
  97. package/src/feature-flags/data.ts +16 -0
  98. package/src/feature-flags/default.ts +18 -0
  99. package/src/feature-flags/index.ts +7 -0
  100. package/src/feature-flags/requestable-features.ts +79 -0
  101. package/src/feature-flags/types.ts +4 -0
  102. package/src/fetcher.ts +2 -0
  103. package/src/finance/index.ts +4 -0
  104. package/src/finance/interest-calculator.ts +456 -0
  105. package/src/finance/interest-detector.ts +141 -0
  106. package/src/finance/transform-invoice-results.ts +219 -0
  107. package/src/finance/wallet-permissions.test.ts +169 -0
  108. package/src/finance/wallet-permissions.ts +82 -0
  109. package/src/format.ts +120 -1
  110. package/src/generated/platform-build-metadata.ts +11 -0
  111. package/src/hooks/use-platform.ts +64 -0
  112. package/src/html-sanitizer.ts +155 -0
  113. package/src/internal-domains.ts +497 -0
  114. package/src/keyboard-preset.ts +109 -0
  115. package/src/label-colors.ts +213 -0
  116. package/src/launchable-apps.test.ts +126 -0
  117. package/src/launchable-apps.ts +490 -0
  118. package/src/name-helper.ts +269 -0
  119. package/src/next-config.test.ts +234 -0
  120. package/src/next-config.ts +203 -0
  121. package/src/node-diff.ts +375 -0
  122. package/src/notification-service.ts +379 -0
  123. package/src/nova/scores/__tests__/calculate.test.ts +254 -0
  124. package/src/nova/scores/calculate.ts +132 -0
  125. package/src/nova/submissions/check-permission.ts +132 -0
  126. package/src/onboarding-helper.ts +213 -0
  127. package/src/path-helper.ts +93 -0
  128. package/src/permissions.tsx +1170 -0
  129. package/src/plan-helpers.test.ts +188 -0
  130. package/src/plan-helpers.ts +80 -0
  131. package/src/platform-release.test.ts +74 -0
  132. package/src/platform-release.ts +155 -0
  133. package/src/portless.ts +124 -0
  134. package/src/priority-styles.ts +42 -0
  135. package/src/request-emoji-limit.ts +335 -0
  136. package/src/search-helper.ts +18 -0
  137. package/src/search.test.ts +89 -0
  138. package/src/search.ts +355 -0
  139. package/src/storage-display-name.ts +30 -0
  140. package/src/storage-path.ts +147 -0
  141. package/src/tag-utils.ts +159 -0
  142. package/src/task/reorder.ts +245 -0
  143. package/src/task/transformers.ts +149 -0
  144. package/src/task-date-timezone.ts +133 -0
  145. package/src/task-description-content.ts +240 -0
  146. package/src/task-helper/board.ts +193 -0
  147. package/src/task-helper/bulk-actions.ts +564 -0
  148. package/src/task-helper/personal-external-staging.ts +21 -0
  149. package/src/task-helper/recycle-bin.ts +202 -0
  150. package/src/task-helper/relationships.ts +346 -0
  151. package/src/task-helper/shared.ts +109 -0
  152. package/src/task-helper/sort-keys.ts +337 -0
  153. package/src/task-helper/task-hooks-basic.ts +342 -0
  154. package/src/task-helper/task-hooks-move.ts +264 -0
  155. package/src/task-helper/task-operations.ts +278 -0
  156. package/src/task-helper.ts +12 -0
  157. package/src/task-helpers.ts +241 -0
  158. package/src/task-list-status.ts +62 -0
  159. package/src/task-overrides.ts +82 -0
  160. package/src/task-snapshot.ts +374 -0
  161. package/src/text-diff.ts +81 -0
  162. package/src/text-helper.ts +537 -0
  163. package/src/time-helper.ts +63 -0
  164. package/src/time-tracker-period.ts +73 -0
  165. package/src/timeblock-helper.ts +418 -0
  166. package/src/timezone.ts +190 -0
  167. package/src/timezones.json +1271 -0
  168. package/src/upstash-rest.ts +56 -0
  169. package/src/user-helper.ts +296 -0
  170. package/src/uuid-helper.ts +11 -0
  171. package/src/workspace-handle.ts +10 -0
  172. package/src/workspace-helper.ts +1408 -0
  173. package/src/workspace-limits.ts +68 -0
  174. package/src/yjs-helper.ts +217 -0
  175. package/src/yjs-task-description.ts +81 -0
  176. package/tsconfig.json +3 -5
  177. package/tsconfig.typecheck.json +33 -0
  178. package/vitest.config.ts +36 -0
  179. package/dist/index.d.ts +0 -8
  180. package/dist/index.js +0 -2
  181. package/dist/index.js.map +0 -1
  182. package/dist/index.mjs +0 -2
  183. package/dist/index.mjs.map +0 -1
  184. package/eslint.config.mjs +0 -20
  185. package/rollup.config.js +0 -41
  186. package/src/index.ts +0 -1
@@ -0,0 +1,1170 @@
1
+ import {
2
+ Archive,
3
+ ArrowDown,
4
+ ArrowUp,
5
+ Banknote,
6
+ BriefcaseBusiness,
7
+ Calendar,
8
+ CalendarCheck,
9
+ CalendarCog,
10
+ ChartBar,
11
+ CircleCheck,
12
+ CircuitBoard,
13
+ Clock,
14
+ CreditCard,
15
+ DatabaseZap,
16
+ Download,
17
+ Edit,
18
+ Eye,
19
+ FileKey2,
20
+ FileText,
21
+ FlaskConical,
22
+ HandCoins,
23
+ HardDrive,
24
+ House,
25
+ KeyRound,
26
+ LayoutTemplate,
27
+ ListTodo,
28
+ Lock,
29
+ MessageCircleIcon,
30
+ MessagesSquare,
31
+ Newspaper,
32
+ Plus,
33
+ ScrollText,
34
+ Search,
35
+ Send,
36
+ ServerCog,
37
+ Settings2,
38
+ Shield,
39
+ ShieldCheck,
40
+ Sparkles,
41
+ Trash,
42
+ UserCheck,
43
+ UserCog,
44
+ UserMinus,
45
+ UserPlus,
46
+ Users,
47
+ UserX,
48
+ Wallet,
49
+ } from '@tuturuuu/icons';
50
+ import type { SupabaseUser } from '@tuturuuu/supabase/next/user';
51
+ import type { PermissionId } from '@tuturuuu/types';
52
+ import { ROOT_WORKSPACE_ID } from '@tuturuuu/utils/constants';
53
+ import type { ReactNode } from 'react';
54
+
55
+ export type RolePermission = {
56
+ id: PermissionId;
57
+ icon?: ReactNode;
58
+ title: string;
59
+ description: string;
60
+ disableOnProduction?: boolean;
61
+ disabled?: boolean;
62
+ };
63
+
64
+ export type RolePermissionGroup = {
65
+ id: string;
66
+ icon?: ReactNode;
67
+ title: string;
68
+ description?: string;
69
+ permissions: RolePermission[];
70
+ };
71
+
72
+ export type PermissionCatalog = 'workspace' | 'full';
73
+
74
+ export type PermissionGroupsOptions = {
75
+ catalog?: PermissionCatalog;
76
+ t?: (key: string) => string;
77
+ user: SupabaseUser | null;
78
+ wsId: string;
79
+ };
80
+
81
+ export const permissionGroups = ({
82
+ catalog = 'workspace',
83
+ t = (key: string) => key,
84
+ wsId,
85
+ user,
86
+ }: PermissionGroupsOptions) => {
87
+ const includeFullCatalog = catalog === 'full';
88
+ const includeRootPermissions =
89
+ includeFullCatalog || wsId === ROOT_WORKSPACE_ID;
90
+ const includeInternalWorkspacePermissions =
91
+ includeFullCatalog ||
92
+ wsId === ROOT_WORKSPACE_ID ||
93
+ user?.email?.endsWith('@tuturuuu.com');
94
+
95
+ return (
96
+ [
97
+ ...(includeRootPermissions
98
+ ? [
99
+ {
100
+ id: 'infrastructure',
101
+ icon: <CircuitBoard />,
102
+ title: t('ws-roles.infrastructure'),
103
+ description: t('ws-roles.infrastructure_description'),
104
+ permissions: [
105
+ {
106
+ id: 'view_infrastructure',
107
+ icon: <Eye />,
108
+ title: t('ws-roles.view_infrastructure'),
109
+ description: t('ws-roles.view_infrastructure_description'),
110
+ disableOnProduction: false,
111
+ disabled: false,
112
+ },
113
+ {
114
+ id: 'manage_infrastructure_stress_tests' as PermissionId,
115
+ icon: <FlaskConical />,
116
+ title: t('ws-roles.manage_infrastructure_stress_tests'),
117
+ description: t(
118
+ 'ws-roles.manage_infrastructure_stress_tests_description'
119
+ ),
120
+ disableOnProduction: false,
121
+ disabled: false,
122
+ },
123
+ {
124
+ id: 'manage_external_migrations',
125
+ icon: <DatabaseZap />,
126
+ title: t('ws-roles.manage_external_migrations'),
127
+ description: t(
128
+ 'ws-roles.manage_external_migrations_description'
129
+ ),
130
+ disableOnProduction: false,
131
+ disabled: false,
132
+ },
133
+ {
134
+ id: 'manage_workspace_audit_logs',
135
+ icon: <ScrollText />,
136
+ title: t('ws-roles.manage_workspace_audit_logs'),
137
+ description: t(
138
+ 'ws-roles.manage_workspace_audit_logs_description'
139
+ ),
140
+ disableOnProduction: true,
141
+ disabled: true,
142
+ },
143
+ {
144
+ id: 'manage_changelog',
145
+ icon: <Newspaper />,
146
+ title: t('ws-roles.manage_changelog'),
147
+ description: t('ws-roles.manage_changelog_description'),
148
+ disableOnProduction: false,
149
+ disabled: false,
150
+ },
151
+ ],
152
+ },
153
+ ]
154
+ : []),
155
+ {
156
+ id: 'workspace',
157
+ icon: <House />,
158
+ title: t('ws-roles.workspace'),
159
+ description: t('ws-roles.workspace_description'),
160
+ permissions: [
161
+ ...(includeInternalWorkspacePermissions
162
+ ? [
163
+ {
164
+ id: 'manage_workspace_secrets',
165
+ icon: <KeyRound />,
166
+ title: t('ws-roles.manage_workspace_secrets'),
167
+ description: t(
168
+ 'ws-roles.manage_workspace_secrets_description'
169
+ ),
170
+ disableOnProduction: false,
171
+ disabled: false,
172
+ },
173
+ ]
174
+ : []),
175
+ {
176
+ id: 'manage_external_projects',
177
+ icon: <BriefcaseBusiness />,
178
+ title: t('ws-roles.manage_external_projects'),
179
+ description: t('ws-roles.manage_external_projects_description'),
180
+ disableOnProduction: false,
181
+ disabled: false,
182
+ },
183
+ {
184
+ id: 'publish_external_projects',
185
+ icon: <Send />,
186
+ title: t('ws-roles.publish_external_projects'),
187
+ description: t('ws-roles.publish_external_projects_description'),
188
+ disableOnProduction: false,
189
+ disabled: false,
190
+ },
191
+ {
192
+ id: 'admin',
193
+ icon: <ShieldCheck />,
194
+ title: t('ws-roles.admin'),
195
+ description: t('ws-roles.admin_description'),
196
+ disableOnProduction: false,
197
+ disabled: false,
198
+ },
199
+ {
200
+ id: 'manage_api_keys',
201
+ icon: <KeyRound />,
202
+ title: t('ws-roles.manage_api_keys'),
203
+ description: t('ws-roles.manage_api_keys_description'),
204
+ disableOnProduction: false,
205
+ disabled: false,
206
+ },
207
+ {
208
+ id: 'manage_workspace_roles',
209
+ icon: <UserCog />,
210
+ title: t('ws-roles.manage_workspace_roles'),
211
+ description: t('ws-roles.manage_workspace_roles_description'),
212
+ disableOnProduction: false,
213
+ disabled: false,
214
+ },
215
+ {
216
+ id: 'manage_workspace_members',
217
+ icon: <UserCheck />,
218
+ title: t('ws-roles.manage_workspace_members'),
219
+ description: t('ws-roles.manage_workspace_members_description'),
220
+ disableOnProduction: false,
221
+ disabled: false,
222
+ },
223
+ {
224
+ id: 'manage_workspace_settings',
225
+ icon: <Settings2 />,
226
+ title: t('ws-roles.manage_workspace_settings'),
227
+ description: t('ws-roles.manage_workspace_settings_description'),
228
+ disableOnProduction: false,
229
+ disabled: false,
230
+ },
231
+ {
232
+ id: 'manage_workspace_integrations',
233
+ icon: <CircuitBoard />,
234
+ title: t('ws-roles.manage_workspace_integrations'),
235
+ description: t(
236
+ 'ws-roles.manage_workspace_integrations_description'
237
+ ),
238
+ disableOnProduction: false,
239
+ disabled: false,
240
+ },
241
+ {
242
+ id: 'manage_workspace_security',
243
+ icon: <Shield />,
244
+ title: t('ws-roles.manage_workspace_security'),
245
+ description: t('ws-roles.manage_workspace_security_description'),
246
+ disableOnProduction: false,
247
+ disabled: false,
248
+ },
249
+ {
250
+ id: 'manage_e2ee',
251
+ icon: <Lock />,
252
+ title: t('ws-roles.manage_e2ee'),
253
+ description: t('ws-roles.manage_e2ee_description'),
254
+ disableOnProduction: false,
255
+ disabled: false,
256
+ },
257
+ {
258
+ id: 'manage_subscription',
259
+ icon: <CreditCard />,
260
+ title: t('ws-roles.manage_subscription'),
261
+ description: t('ws-roles.manage_subscription_description'),
262
+ disableOnProduction: false,
263
+ disabled: false,
264
+ },
265
+ {
266
+ id: 'manage_workspace_billing',
267
+ icon: <CreditCard />,
268
+ title: t('ws-roles.manage_workspace_billing'),
269
+ description: t('ws-roles.manage_workspace_billing_description'),
270
+ disableOnProduction: false,
271
+ disabled: false,
272
+ },
273
+ ],
274
+ },
275
+ {
276
+ id: 'ai',
277
+ icon: <Sparkles />,
278
+ title: t('ws-roles.ai'),
279
+ description: t('ws-roles.ai_description'),
280
+ permissions: [
281
+ {
282
+ id: 'ai_chat',
283
+ icon: <MessagesSquare />,
284
+ title: t('ws-roles.ai_chat'),
285
+ description: t('ws-roles.ai_chat_description'),
286
+ disableOnProduction: false,
287
+ disabled: false,
288
+ },
289
+ {
290
+ id: 'ai_lab',
291
+ icon: <FlaskConical />,
292
+ title: t('ws-roles.ai_lab'),
293
+ description: t('ws-roles.ai_lab_description'),
294
+ disableOnProduction: false,
295
+ disabled: false,
296
+ },
297
+ ],
298
+ },
299
+ {
300
+ id: 'chat',
301
+ icon: <MessageCircleIcon />,
302
+ title: t('ws-roles.chat'),
303
+ description: t('ws-roles.chat_description'),
304
+ permissions: [
305
+ {
306
+ id: 'view_chat',
307
+ icon: <Eye />,
308
+ title: t('ws-roles.view_chat'),
309
+ description: t('ws-roles.view_chat_description'),
310
+ disableOnProduction: false,
311
+ disabled: false,
312
+ },
313
+ {
314
+ id: 'create_chat',
315
+ icon: <Plus />,
316
+ title: t('ws-roles.create_chat'),
317
+ description: t('ws-roles.create_chat_description'),
318
+ disableOnProduction: false,
319
+ disabled: false,
320
+ },
321
+ {
322
+ id: 'manage_chat',
323
+ icon: <Settings2 />,
324
+ title: t('ws-roles.manage_chat'),
325
+ description: t('ws-roles.manage_chat_description'),
326
+ disableOnProduction: false,
327
+ disabled: false,
328
+ },
329
+ {
330
+ id: 'moderate_chat',
331
+ icon: <Shield />,
332
+ title: t('ws-roles.moderate_chat'),
333
+ description: t('ws-roles.moderate_chat_description'),
334
+ disableOnProduction: false,
335
+ disabled: false,
336
+ },
337
+ ],
338
+ },
339
+ {
340
+ id: 'calendar',
341
+ icon: <Calendar />,
342
+ title: t('sidebar_tabs.calendar'),
343
+ permissions: [
344
+ {
345
+ id: 'manage_calendar',
346
+ icon: <CalendarCog />,
347
+ title: t('ws-roles.manage_calendar'),
348
+ description: t('ws-roles.manage_calendar_description'),
349
+ disableOnProduction: false,
350
+ disabled: false,
351
+ },
352
+ ],
353
+ },
354
+ {
355
+ id: 'projects',
356
+ icon: <CircleCheck />,
357
+ title: t('sidebar_tabs.projects'),
358
+ permissions: [
359
+ {
360
+ id: 'manage_projects',
361
+ icon: <ListTodo />,
362
+ title: t('ws-roles.manage_projects'),
363
+ description: t('ws-roles.manage_projects_description'),
364
+ disableOnProduction: false,
365
+ disabled: false,
366
+ },
367
+ ],
368
+ },
369
+ {
370
+ id: 'documents',
371
+ icon: <FileText />,
372
+ title: t('sidebar_tabs.documents'),
373
+ permissions: [
374
+ {
375
+ id: 'manage_documents',
376
+ icon: <FileKey2 />,
377
+ title: t('ws-roles.manage_documents'),
378
+ description: t('ws-roles.manage_documents_description'),
379
+ disableOnProduction: false,
380
+ disabled: false,
381
+ },
382
+ ],
383
+ },
384
+ {
385
+ id: 'forms',
386
+ icon: <LayoutTemplate />,
387
+ title: t('sidebar_tabs.forms'),
388
+ permissions: [
389
+ {
390
+ id: 'manage_forms',
391
+ icon: <Settings2 />,
392
+ title: t('ws-roles.manage_forms'),
393
+ description: t('ws-roles.manage_forms_description'),
394
+ disableOnProduction: false,
395
+ disabled: false,
396
+ },
397
+ {
398
+ id: 'view_form_analytics',
399
+ icon: <ChartBar />,
400
+ title: t('ws-roles.view_form_analytics'),
401
+ description: t('ws-roles.view_form_analytics_description'),
402
+ disableOnProduction: false,
403
+ disabled: false,
404
+ },
405
+ ],
406
+ },
407
+ {
408
+ id: 'time-tracker',
409
+ icon: <Clock />,
410
+ title: t('sidebar_tabs.time-tracker'),
411
+ permissions: [
412
+ {
413
+ id: 'manage_time_tracking_requests',
414
+ icon: <MessageCircleIcon />,
415
+ title: t('ws-roles.manage_time_tracking_requests'),
416
+ description: t(
417
+ 'ws-roles.manage_time_tracking_requests_description'
418
+ ),
419
+ disableOnProduction: false,
420
+ disabled: false,
421
+ },
422
+ {
423
+ id: 'bypass_time_tracking_request_approval',
424
+ icon: <CircleCheck />,
425
+ title: t('ws-roles.bypass_time_tracking_request_approval'),
426
+ description: t(
427
+ 'ws-roles.bypass_time_tracking_request_approval_description'
428
+ ),
429
+ disableOnProduction: false,
430
+ disabled: false,
431
+ },
432
+ ],
433
+ },
434
+ {
435
+ id: 'drive',
436
+ icon: <HardDrive />,
437
+ title: t('sidebar_tabs.drive'),
438
+ permissions: [
439
+ {
440
+ id: 'view_drive',
441
+ icon: <Eye />,
442
+ title: t('ws-roles.view_drive'),
443
+ description: t('ws-roles.view_drive_description'),
444
+ disableOnProduction: false,
445
+ disabled: false,
446
+ },
447
+ {
448
+ id: 'manage_drive',
449
+ icon: <ServerCog />,
450
+ title: t('ws-roles.manage_drive'),
451
+ description: t('ws-roles.manage_drive_description'),
452
+ disableOnProduction: false,
453
+ disabled: false,
454
+ },
455
+ {
456
+ id: 'manage_drive_tasks_directory',
457
+ icon: <ServerCog />,
458
+ title: t('ws-roles.manage_drive_tasks_directory'),
459
+ description: t('ws-roles.manage_drive_tasks_directory_description'),
460
+ disableOnProduction: false,
461
+ disabled: false,
462
+ },
463
+ ],
464
+ },
465
+ {
466
+ id: 'users',
467
+ icon: <Users />,
468
+ title: t('sidebar_tabs.users'),
469
+ permissions: [
470
+ {
471
+ id: 'manage_users',
472
+ icon: <UserCog />,
473
+ title: t('ws-roles.manage_users'),
474
+ description: t('ws-roles.manage_users_description'),
475
+ disableOnProduction: false,
476
+ disabled: false,
477
+ },
478
+ {
479
+ id: 'export_users_data',
480
+ icon: <Download />,
481
+ title: t('ws-roles.export_users_data'),
482
+ description: t('ws-roles.export_users_data_description'),
483
+ disableOnProduction: false,
484
+ disabled: false,
485
+ },
486
+ {
487
+ id: 'send_user_group_post_emails',
488
+ icon: <Send />,
489
+ title: t('ws-roles.send_user_group_post_emails'),
490
+ description: t('ws-roles.send_user_group_post_emails_description'),
491
+ disableOnProduction: false,
492
+ disabled: false,
493
+ },
494
+ {
495
+ id: 'manage_user_report_templates',
496
+ icon: <LayoutTemplate />,
497
+ title: t('ws-roles.manage_user_report_templates'),
498
+ description: t('ws-roles.manage_user_report_templates_description'),
499
+ disableOnProduction: false,
500
+ disabled: false,
501
+ },
502
+ {
503
+ id: 'view_users_public_info',
504
+ icon: <Eye />,
505
+ title: t('ws-roles.view_users_public_info'),
506
+ description: t('ws-roles.view_users_public_info_description'),
507
+ disableOnProduction: false,
508
+ disabled: false,
509
+ },
510
+ {
511
+ id: 'view_users_private_info',
512
+ icon: <UserX />,
513
+ title: t('ws-roles.view_users_private_info'),
514
+ description: t('ws-roles.view_users_private_info_description'),
515
+ disableOnProduction: false,
516
+ disabled: false,
517
+ },
518
+ {
519
+ id: 'create_users',
520
+ icon: <UserPlus />,
521
+ title: t('ws-roles.create_users'),
522
+ description: t('ws-roles.create_users_description'),
523
+ disableOnProduction: false,
524
+ disabled: false,
525
+ },
526
+ {
527
+ id: 'update_users',
528
+ icon: <UserCog />,
529
+ title: t('ws-roles.update_users'),
530
+ description: t('ws-roles.update_users_description'),
531
+ disableOnProduction: false,
532
+ disabled: false,
533
+ },
534
+ {
535
+ id: 'delete_users',
536
+ icon: <UserMinus />,
537
+ title: t('ws-roles.delete_users'),
538
+ description: t('ws-roles.delete_users_description'),
539
+ disableOnProduction: false,
540
+ disabled: false,
541
+ },
542
+ {
543
+ id: 'check_user_attendance',
544
+ icon: <CalendarCheck />,
545
+ title: t('ws-roles.check_user_attendance'),
546
+ description: t('ws-roles.check_user_attendance_description'),
547
+ disableOnProduction: false,
548
+ disabled: false,
549
+ },
550
+ {
551
+ id: 'update_user_attendance',
552
+ icon: <CalendarCheck />,
553
+ title: t('ws-roles.update_user_attendance'),
554
+ description: t('ws-roles.update_user_attendance_description'),
555
+ disableOnProduction: false,
556
+ disabled: false,
557
+ },
558
+ ],
559
+ },
560
+ {
561
+ id: 'user_groups',
562
+ icon: <Users />,
563
+ title: t('ws-roles.user_groups'),
564
+ permissions: [
565
+ {
566
+ id: 'view_user_groups',
567
+ icon: <Eye />,
568
+ title: t('ws-roles.view_user_groups'),
569
+ description: t('ws-roles.view_user_groups_description'),
570
+ disableOnProduction: false,
571
+ disabled: false,
572
+ },
573
+ {
574
+ id: 'create_user_groups',
575
+ icon: <Plus />,
576
+ title: t('ws-roles.create_user_groups'),
577
+ description: t('ws-roles.create_user_groups_description'),
578
+ disableOnProduction: false,
579
+ disabled: false,
580
+ },
581
+ {
582
+ id: 'update_user_groups',
583
+ icon: <Edit />,
584
+ title: t('ws-roles.update_user_groups'),
585
+ description: t('ws-roles.update_user_groups_description'),
586
+ disableOnProduction: false,
587
+ disabled: false,
588
+ },
589
+ {
590
+ id: 'delete_user_groups',
591
+ icon: <Trash />,
592
+ title: t('ws-roles.delete_user_groups'),
593
+ description: t('ws-roles.delete_user_groups_description'),
594
+ disableOnProduction: false,
595
+ disabled: false,
596
+ },
597
+ {
598
+ id: 'view_user_groups_scores',
599
+ icon: <ChartBar />,
600
+ title: t('ws-roles.view_user_groups_scores'),
601
+ description: t('ws-roles.view_user_groups_scores_description'),
602
+ disableOnProduction: false,
603
+ disabled: false,
604
+ },
605
+ {
606
+ id: 'create_user_groups_scores',
607
+ icon: <Plus />,
608
+ title: t('ws-roles.create_user_groups_scores'),
609
+ description: t('ws-roles.create_user_groups_scores_description'),
610
+ disableOnProduction: false,
611
+ disabled: false,
612
+ },
613
+ {
614
+ id: 'update_user_groups_scores',
615
+ icon: <Edit />,
616
+ title: t('ws-roles.update_user_groups_scores'),
617
+ description: t('ws-roles.update_user_groups_scores_description'),
618
+ disableOnProduction: false,
619
+ disabled: false,
620
+ },
621
+ {
622
+ id: 'delete_user_groups_scores',
623
+ icon: <Trash />,
624
+ title: t('ws-roles.delete_user_groups_scores'),
625
+ description: t('ws-roles.delete_user_groups_scores_description'),
626
+ disableOnProduction: false,
627
+ disabled: false,
628
+ },
629
+ {
630
+ id: 'view_user_groups_posts',
631
+ icon: <Eye />,
632
+ title: t('ws-roles.view_user_groups_posts'),
633
+ description: t('ws-roles.view_user_groups_posts_description'),
634
+ disableOnProduction: false,
635
+ disabled: false,
636
+ },
637
+ {
638
+ id: 'create_user_groups_posts',
639
+ icon: <Plus />,
640
+ title: t('ws-roles.create_user_groups_posts'),
641
+ description: t('ws-roles.create_user_groups_posts_description'),
642
+ disableOnProduction: false,
643
+ disabled: false,
644
+ },
645
+ {
646
+ id: 'update_user_groups_posts',
647
+ icon: <Edit />,
648
+ title: t('ws-roles.update_user_groups_posts'),
649
+ description: t('ws-roles.update_user_groups_posts_description'),
650
+ disableOnProduction: false,
651
+ disabled: false,
652
+ },
653
+ {
654
+ id: 'delete_user_groups_posts',
655
+ icon: <Trash />,
656
+ title: t('ws-roles.delete_user_groups_posts'),
657
+ description: t('ws-roles.delete_user_groups_posts_description'),
658
+ disableOnProduction: false,
659
+ disabled: false,
660
+ },
661
+ {
662
+ id: 'view_user_groups_reports',
663
+ icon: <Eye />,
664
+ title: t('ws-roles.view_user_groups_reports'),
665
+ description: t('ws-roles.view_user_groups_reports_description'),
666
+ disableOnProduction: false,
667
+ disabled: false,
668
+ },
669
+ {
670
+ id: 'create_user_groups_reports',
671
+ icon: <Plus />,
672
+ title: t('ws-roles.create_user_groups_reports'),
673
+ description: t('ws-roles.create_user_groups_reports_description'),
674
+ disableOnProduction: false,
675
+ disabled: false,
676
+ },
677
+ {
678
+ id: 'update_user_groups_reports',
679
+ icon: <Edit />,
680
+ title: t('ws-roles.update_user_groups_reports'),
681
+ description: t('ws-roles.update_user_groups_reports_description'),
682
+ disableOnProduction: false,
683
+ disabled: false,
684
+ },
685
+ {
686
+ id: 'delete_user_groups_reports',
687
+ icon: <Trash />,
688
+ title: t('ws-roles.delete_user_groups_reports'),
689
+ description: t('ws-roles.delete_user_groups_reports_description'),
690
+ disableOnProduction: false,
691
+ disabled: false,
692
+ },
693
+ {
694
+ id: 'approve_reports',
695
+ icon: <ShieldCheck />,
696
+ title: t('ws-roles.approve_reports'),
697
+ description: t('ws-roles.approve_reports_description'),
698
+ disableOnProduction: false,
699
+ disabled: false,
700
+ },
701
+ {
702
+ id: 'approve_posts',
703
+ icon: <ShieldCheck />,
704
+ title: t('ws-roles.approve_posts'),
705
+ description: t('ws-roles.approve_posts_description'),
706
+ disableOnProduction: false,
707
+ disabled: false,
708
+ },
709
+ ],
710
+ },
711
+ {
712
+ id: 'leads',
713
+ icon: <Users />,
714
+ title: t('ws-roles.leads'),
715
+ permissions: [
716
+ {
717
+ id: 'create_lead_generations',
718
+ icon: <Plus />,
719
+ title: t('ws-roles.create_lead_generations'),
720
+ description: t('ws-roles.create_lead_generations_description'),
721
+ disableOnProduction: false,
722
+ disabled: false,
723
+ },
724
+ ],
725
+ },
726
+ {
727
+ id: 'inventory',
728
+ icon: <Archive />,
729
+ title: t('sidebar_tabs.inventory'),
730
+ permissions: [
731
+ {
732
+ id: 'manage_inventory',
733
+ icon: <Archive />,
734
+ title: t('ws-roles.manage_inventory'),
735
+ description: t('ws-roles.manage_inventory_description'),
736
+ disableOnProduction: false,
737
+ disabled: false,
738
+ },
739
+ {
740
+ id: 'create_inventory',
741
+ icon: <Plus />,
742
+ title: t('ws-roles.create_inventory'),
743
+ description: t('ws-roles.create_inventory_description'),
744
+ disableOnProduction: false,
745
+ disabled: false,
746
+ },
747
+ {
748
+ id: 'update_inventory',
749
+ icon: <Edit />,
750
+ title: t('ws-roles.update_inventory'),
751
+ description: t('ws-roles.update_inventory_description'),
752
+ disableOnProduction: false,
753
+ disabled: false,
754
+ },
755
+ {
756
+ id: 'delete_inventory',
757
+ icon: <Trash />,
758
+ title: t('ws-roles.delete_inventory'),
759
+ description: t('ws-roles.delete_inventory_description'),
760
+ disableOnProduction: false,
761
+ disabled: false,
762
+ },
763
+ {
764
+ id: 'view_inventory',
765
+ icon: <Search />,
766
+ title: t('ws-roles.view_inventory'),
767
+ description: t('ws-roles.view_inventory_description'),
768
+ disableOnProduction: false,
769
+ disabled: false,
770
+ },
771
+ {
772
+ id: 'view_stock_quantity',
773
+ icon: <Eye />,
774
+ title: t('ws-roles.view_stock_quantity'),
775
+ description: t('ws-roles.view_stock_quantity_description'),
776
+ disableOnProduction: false,
777
+ disabled: false,
778
+ },
779
+ {
780
+ id: 'update_stock_quantity',
781
+ icon: <Edit />,
782
+ title: t('ws-roles.update_stock_quantity'),
783
+ description: t('ws-roles.update_stock_quantity_description'),
784
+ disableOnProduction: false,
785
+ disabled: false,
786
+ },
787
+ {
788
+ id: 'view_inventory_dashboard',
789
+ icon: <ChartBar />,
790
+ title: t('ws-roles.view_inventory_dashboard'),
791
+ description: t('ws-roles.view_inventory_dashboard_description'),
792
+ disableOnProduction: false,
793
+ disabled: false,
794
+ },
795
+ {
796
+ id: 'view_inventory_catalog',
797
+ icon: <Eye />,
798
+ title: t('ws-roles.view_inventory_catalog'),
799
+ description: t('ws-roles.view_inventory_catalog_description'),
800
+ disableOnProduction: false,
801
+ disabled: false,
802
+ },
803
+ {
804
+ id: 'manage_inventory_catalog',
805
+ icon: <Edit />,
806
+ title: t('ws-roles.manage_inventory_catalog'),
807
+ description: t('ws-roles.manage_inventory_catalog_description'),
808
+ disableOnProduction: false,
809
+ disabled: false,
810
+ },
811
+ {
812
+ id: 'view_inventory_stock',
813
+ icon: <Eye />,
814
+ title: t('ws-roles.view_inventory_stock'),
815
+ description: t('ws-roles.view_inventory_stock_description'),
816
+ disableOnProduction: false,
817
+ disabled: false,
818
+ },
819
+ {
820
+ id: 'adjust_inventory_stock',
821
+ icon: <Edit />,
822
+ title: t('ws-roles.adjust_inventory_stock'),
823
+ description: t('ws-roles.adjust_inventory_stock_description'),
824
+ disableOnProduction: false,
825
+ disabled: false,
826
+ },
827
+ {
828
+ id: 'manage_inventory_setup',
829
+ icon: <Settings2 />,
830
+ title: t('ws-roles.manage_inventory_setup'),
831
+ description: t('ws-roles.manage_inventory_setup_description'),
832
+ disableOnProduction: false,
833
+ disabled: false,
834
+ },
835
+ {
836
+ id: 'view_inventory_sales',
837
+ icon: <Eye />,
838
+ title: t('ws-roles.view_inventory_sales'),
839
+ description: t('ws-roles.view_inventory_sales_description'),
840
+ disableOnProduction: false,
841
+ disabled: false,
842
+ },
843
+ {
844
+ id: 'create_inventory_sales',
845
+ icon: <Plus />,
846
+ title: t('ws-roles.create_inventory_sales'),
847
+ description: t('ws-roles.create_inventory_sales_description'),
848
+ disableOnProduction: false,
849
+ disabled: false,
850
+ },
851
+ {
852
+ id: 'view_inventory_analytics',
853
+ icon: <ChartBar />,
854
+ title: t('ws-roles.view_inventory_analytics'),
855
+ description: t('ws-roles.view_inventory_analytics_description'),
856
+ disableOnProduction: false,
857
+ disabled: false,
858
+ },
859
+ {
860
+ id: 'view_inventory_audit_logs',
861
+ icon: <ScrollText />,
862
+ title: t('ws-roles.view_inventory_audit_logs'),
863
+ description: t('ws-roles.view_inventory_audit_logs_description'),
864
+ disableOnProduction: false,
865
+ disabled: false,
866
+ },
867
+ ],
868
+ },
869
+ {
870
+ id: 'finance',
871
+ icon: <Banknote />,
872
+ title: t('sidebar_tabs.finance'),
873
+ permissions: [
874
+ {
875
+ id: 'manage_finance',
876
+ icon: <HandCoins />,
877
+ title: t('ws-roles.manage_finance'),
878
+ description: t('ws-roles.manage_finance_description'),
879
+ disableOnProduction: false,
880
+ disabled: false,
881
+ },
882
+ {
883
+ id: 'export_finance_data',
884
+ icon: <Download />,
885
+ title: t('ws-roles.export_finance_data'),
886
+ description: t('ws-roles.export_finance_data_description'),
887
+ disableOnProduction: false,
888
+ disabled: false,
889
+ },
890
+ {
891
+ id: 'view_finance_stats',
892
+ icon: <ChartBar />,
893
+ title: t('ws-roles.view_finance_stats'),
894
+ description: t('ws-roles.view_finance_stats_description'),
895
+ disableOnProduction: false,
896
+ disabled: false,
897
+ },
898
+ {
899
+ id: 'set_finance_wallets_on_create',
900
+ icon: <Wallet />,
901
+ title: t('ws-roles.set_finance_wallets_on_create'),
902
+ description: t(
903
+ 'ws-roles.set_finance_wallets_on_create_description'
904
+ ),
905
+ disableOnProduction: false,
906
+ disabled: false,
907
+ },
908
+ {
909
+ id: 'change_finance_wallets',
910
+ icon: <CreditCard />,
911
+ title: t('ws-roles.change_finance_wallets'),
912
+ description: t('ws-roles.change_finance_wallets_description'),
913
+ disableOnProduction: false,
914
+ disabled: false,
915
+ },
916
+ {
917
+ id: 'create_wallets',
918
+ icon: <Plus />,
919
+ title: t('ws-roles.create_wallets'),
920
+ description: t('ws-roles.create_wallets_description'),
921
+ disableOnProduction: false,
922
+ disabled: false,
923
+ },
924
+ {
925
+ id: 'update_wallets',
926
+ icon: <Edit />,
927
+ title: t('ws-roles.update_wallets'),
928
+ description: t('ws-roles.update_wallets_description'),
929
+ disableOnProduction: false,
930
+ disabled: false,
931
+ },
932
+ {
933
+ id: 'delete_wallets',
934
+ icon: <Trash />,
935
+ title: t('ws-roles.delete_wallets'),
936
+ description: t('ws-roles.delete_wallets_description'),
937
+ disableOnProduction: false,
938
+ disabled: false,
939
+ },
940
+ ],
941
+ },
942
+ {
943
+ id: 'workforce',
944
+ icon: <Users />,
945
+ title: t('sidebar_tabs.workforce'),
946
+ permissions: [
947
+ {
948
+ id: 'manage_workforce',
949
+ icon: <UserCog />,
950
+ title: t('ws-roles.manage_workforce'),
951
+ description: t('ws-roles.manage_workforce_description'),
952
+ disableOnProduction: false,
953
+ disabled: false,
954
+ },
955
+ {
956
+ id: 'view_workforce',
957
+ icon: <Eye />,
958
+ title: t('ws-roles.view_workforce'),
959
+ description: t('ws-roles.view_workforce_description'),
960
+ disableOnProduction: false,
961
+ disabled: false,
962
+ },
963
+ {
964
+ id: 'manage_payroll',
965
+ icon: <HandCoins />,
966
+ title: t('ws-roles.manage_payroll'),
967
+ description: t('ws-roles.manage_payroll_description'),
968
+ disableOnProduction: false,
969
+ disabled: false,
970
+ },
971
+ {
972
+ id: 'view_payroll',
973
+ icon: <Eye />,
974
+ title: t('ws-roles.view_payroll'),
975
+ description: t('ws-roles.view_payroll_description'),
976
+ disableOnProduction: false,
977
+ disabled: false,
978
+ },
979
+ ],
980
+ },
981
+ {
982
+ id: 'transactions',
983
+ icon: <ScrollText />,
984
+ title: t('ws-roles.transactions'),
985
+ permissions: [
986
+ {
987
+ id: 'create_transactions',
988
+ icon: <Plus />,
989
+ title: t('ws-roles.create_transactions'),
990
+ description: t('ws-roles.create_transactions_description'),
991
+ disableOnProduction: false,
992
+ disabled: false,
993
+ },
994
+ {
995
+ id: 'update_transactions',
996
+ icon: <Edit />,
997
+ title: t('ws-roles.update_transactions'),
998
+ description: t('ws-roles.update_transactions_description'),
999
+ disableOnProduction: false,
1000
+ disabled: false,
1001
+ },
1002
+ {
1003
+ id: 'delete_transactions',
1004
+ icon: <Trash />,
1005
+ title: t('ws-roles.delete_transactions'),
1006
+ description: t('ws-roles.delete_transactions_description'),
1007
+ disableOnProduction: false,
1008
+ disabled: false,
1009
+ },
1010
+ {
1011
+ id: 'view_transactions',
1012
+ icon: <Search />,
1013
+ title: t('ws-roles.view_transactions'),
1014
+ description: t('ws-roles.view_transactions_description'),
1015
+ disableOnProduction: false,
1016
+ disabled: false,
1017
+ },
1018
+ {
1019
+ id: 'view_expenses',
1020
+ icon: <ArrowDown />,
1021
+ title: t('ws-roles.view_expenses'),
1022
+ description: t('ws-roles.view_expenses_description'),
1023
+ disableOnProduction: false,
1024
+ disabled: false,
1025
+ },
1026
+ {
1027
+ id: 'view_incomes',
1028
+ icon: <ArrowUp />,
1029
+ title: t('ws-roles.view_incomes'),
1030
+ description: t('ws-roles.view_incomes_description'),
1031
+ disableOnProduction: false,
1032
+ disabled: false,
1033
+ },
1034
+ {
1035
+ id: 'view_confidential_amount',
1036
+ icon: <Eye />,
1037
+ title: t('ws-roles.view_confidential_amount'),
1038
+ description: t('ws-roles.view_confidential_amount_description'),
1039
+ disableOnProduction: false,
1040
+ disabled: false,
1041
+ },
1042
+ {
1043
+ id: 'view_confidential_description',
1044
+ icon: <Eye />,
1045
+ title: t('ws-roles.view_confidential_description'),
1046
+ description: t(
1047
+ 'ws-roles.view_confidential_description_description'
1048
+ ),
1049
+ disableOnProduction: false,
1050
+ disabled: false,
1051
+ },
1052
+ {
1053
+ id: 'view_confidential_category',
1054
+ icon: <Eye />,
1055
+ title: t('ws-roles.view_confidential_category'),
1056
+ description: t('ws-roles.view_confidential_category_description'),
1057
+ disableOnProduction: false,
1058
+ disabled: false,
1059
+ },
1060
+ {
1061
+ id: 'create_confidential_transactions',
1062
+ icon: <ShieldCheck />,
1063
+ title: t('ws-roles.create_confidential_transactions'),
1064
+ description: t(
1065
+ 'ws-roles.create_confidential_transactions_description'
1066
+ ),
1067
+ disableOnProduction: false,
1068
+ disabled: false,
1069
+ },
1070
+ {
1071
+ id: 'update_confidential_transactions',
1072
+ icon: <Lock />,
1073
+ title: t('ws-roles.update_confidential_transactions'),
1074
+ description: t(
1075
+ 'ws-roles.update_confidential_transactions_description'
1076
+ ),
1077
+ disableOnProduction: false,
1078
+ disabled: false,
1079
+ },
1080
+ {
1081
+ id: 'delete_confidential_transactions',
1082
+ icon: <Trash />,
1083
+ title: t('ws-roles.delete_confidential_transactions'),
1084
+ description: t(
1085
+ 'ws-roles.delete_confidential_transactions_description'
1086
+ ),
1087
+ disableOnProduction: false,
1088
+ disabled: false,
1089
+ },
1090
+ ],
1091
+ },
1092
+ {
1093
+ id: 'invoices',
1094
+ icon: <FileText />,
1095
+ title: t('ws-roles.invoices'),
1096
+ permissions: [
1097
+ {
1098
+ id: 'create_invoices',
1099
+ icon: <Plus />,
1100
+ title: t('ws-roles.create_invoices'),
1101
+ description: t('ws-roles.create_invoices_description'),
1102
+ disableOnProduction: false,
1103
+ disabled: false,
1104
+ },
1105
+ {
1106
+ id: 'view_invoices',
1107
+ icon: <Search />,
1108
+ title: t('ws-roles.view_invoices'),
1109
+ description: t('ws-roles.view_invoices_description'),
1110
+ disableOnProduction: false,
1111
+ disabled: false,
1112
+ },
1113
+ {
1114
+ id: 'update_invoices',
1115
+ icon: <Edit />,
1116
+ title: t('ws-roles.update_invoices'),
1117
+ description: t('ws-roles.update_invoices_description'),
1118
+ disableOnProduction: false,
1119
+ disabled: false,
1120
+ },
1121
+ {
1122
+ id: 'delete_invoices',
1123
+ icon: <Trash />,
1124
+ title: t('ws-roles.delete_invoices'),
1125
+ description: t('ws-roles.delete_invoices_description'),
1126
+ disableOnProduction: false,
1127
+ disabled: false,
1128
+ },
1129
+ ],
1130
+ },
1131
+ ] as const
1132
+ )
1133
+ .map((group) => ({
1134
+ ...group,
1135
+ permissions: (
1136
+ group?.permissions?.filter((p) => p.title && p.description) || []
1137
+ ).map((p) => ({
1138
+ ...p,
1139
+ disabled: p.disableOnProduction
1140
+ ? process.env.NODE_ENV === 'production'
1141
+ : p.disabled,
1142
+ })),
1143
+ }))
1144
+ .filter(
1145
+ (group) =>
1146
+ group.title && group.permissions && group.permissions.length > 0
1147
+ ) as RolePermissionGroup[];
1148
+ };
1149
+
1150
+ export const permissions = (args: {
1151
+ catalog?: PermissionCatalog;
1152
+ t?: (key: string) => string;
1153
+ wsId: string;
1154
+ user: SupabaseUser | null;
1155
+ }) => {
1156
+ return permissionGroups(args).reduce(
1157
+ (acc, group) => acc.concat(group?.permissions || []),
1158
+ [] as RolePermission[]
1159
+ ) as RolePermission[];
1160
+ };
1161
+
1162
+ export const totalPermissions = ({
1163
+ catalog,
1164
+ wsId,
1165
+ user,
1166
+ }: {
1167
+ catalog?: PermissionCatalog;
1168
+ wsId: string;
1169
+ user: SupabaseUser | null;
1170
+ }) => permissions({ catalog, wsId, user }).length;