@appcorp/fusion-storybook 0.2.13 → 0.2.15

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 (58) hide show
  1. package/base-modules/admission/context/use-admission-module.d.ts +88 -0
  2. package/base-modules/admission/context/use-admission-module.js +771 -0
  3. package/base-modules/admission/context.d.ts +1 -87
  4. package/base-modules/admission/context.js +3 -769
  5. package/base-modules/attendance/more-actions.js +7 -2
  6. package/base-modules/campus/more-actions.js +0 -1
  7. package/base-modules/class/more-actions.js +1 -6
  8. package/base-modules/enrollment/context.d.ts +1 -13
  9. package/base-modules/enrollment/context.js +0 -3
  10. package/base-modules/enrollment/form.js +2 -6
  11. package/base-modules/enrollment/page.d.ts +0 -1
  12. package/base-modules/enrollment/page.js +5 -13
  13. package/base-modules/enrollment/validate.d.ts +0 -1
  14. package/base-modules/enrollment/validate.js +0 -1
  15. package/base-modules/enrollment/view.js +4 -7
  16. package/base-modules/expense/more-actions.js +1 -6
  17. package/base-modules/fee-structure/more-actions.js +1 -6
  18. package/base-modules/student-fee/context/shared.d.ts +178 -0
  19. package/base-modules/student-fee/context/shared.js +59 -0
  20. package/base-modules/student-fee/context/use-student-fee-module.d.ts +64 -0
  21. package/base-modules/student-fee/context/use-student-fee-module.js +610 -0
  22. package/base-modules/student-fee/context.d.ts +21 -235
  23. package/base-modules/student-fee/context.js +2 -674
  24. package/base-modules/student-fee/more-actions.js +1 -6
  25. package/base-modules/student-profile/constants.js +7 -3
  26. package/base-modules/student-profile/context/module-base.d.ts +187 -0
  27. package/base-modules/student-profile/context/module-base.js +50 -0
  28. package/base-modules/student-profile/context/use-student-profile-module.d.ts +70 -0
  29. package/base-modules/student-profile/context/use-student-profile-module.js +506 -0
  30. package/base-modules/student-profile/context.d.ts +20 -256
  31. package/base-modules/student-profile/context.js +2 -601
  32. package/base-modules/teacher/avatar-upload.js +1 -4
  33. package/base-modules/teacher/more-actions.js +1 -6
  34. package/base-modules/user/context/use-user-module.d.ts +53 -0
  35. package/base-modules/user/context/use-user-module.js +546 -0
  36. package/base-modules/user/context.d.ts +1 -52
  37. package/base-modules/user/context.js +5 -547
  38. package/base-modules/workspace-user/more-actions.js +1 -6
  39. package/components/module-error.d.ts +9 -0
  40. package/components/module-error.js +3 -0
  41. package/package.json +5 -4
  42. package/tsconfig.build.tsbuildinfo +1 -1
  43. package/type.d.ts +3 -1242
  44. package/type.js +3 -445
  45. package/types/academics.d.ts +262 -0
  46. package/types/academics.js +8 -0
  47. package/types/admission.d.ts +85 -0
  48. package/types/admission.js +6 -0
  49. package/types/communication.d.ts +165 -0
  50. package/types/communication.js +7 -0
  51. package/types/enums.d.ts +411 -0
  52. package/types/enums.js +442 -0
  53. package/types/finance.d.ts +126 -0
  54. package/types/finance.js +7 -0
  55. package/types/index.d.ts +12 -0
  56. package/types/index.js +12 -0
  57. package/types/user-management.d.ts +236 -0
  58. package/types/user-management.js +7 -0
@@ -17,25 +17,9 @@
17
17
  * - `USER_DRAWER` — drawer type constants
18
18
  * - `useUserModule()` — hook that returns state, dispatch, and handlers
19
19
  */
20
- import { useCallback, useEffect, useMemo, useRef } from "react";
21
- import { useTheme } from "next-themes";
22
- import { useTranslations } from "next-intl";
23
- import { isCreatedOrUpdated, validateForm, API_METHODS, fetchData, } from "@react-pakistan/util-functions";
24
- import { useModuleEntityV2, } from "@react-pakistan/util-functions/hooks/use-module-entity-v2";
25
- import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
26
20
  import { createGenericModule } from "@react-pakistan/util-functions/factory/generic-module-factory";
27
21
  import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
28
- import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
29
- import { USER_API_ROUTES, pageLimit } from "./constants";
30
- import { userFormValidation } from "./validate";
31
- import { getCachedUsers, invalidateUsersCache } from "./cache";
32
- import { getCachedWorkspaceSync } from "../workspace/cache";
33
- import { invalidateWorkspaceUsersCache } from "../workspace-user/cache";
34
- import { blobToWebP } from "webp-converter-browser";
35
- import { supabasePublicStorageUrl } from "../../constants";
36
- import { toastNetworkError } from "../../utils/toast-network-error";
37
- import { formatNumber } from "@react-pakistan/util-functions/general/format-number";
38
- import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
22
+ import { pageLimit } from "./constants";
39
23
  // ============================================================================
40
24
  // 1.1 DRAWER TYPES
41
25
  // ============================================================================
@@ -45,6 +29,9 @@ export const USER_DRAWER = {
45
29
  MORE_ACTIONS_DRAWER: DRAWER_TYPES.MORE_ACTIONS_DRAWER,
46
30
  VIEW_DRAWER: DRAWER_TYPES.VIEW_DRAWER,
47
31
  };
32
+ // ============================================================================
33
+ // 1.2 MODULE CONFIGURATION
34
+ // ============================================================================
48
35
  const userConfig = {
49
36
  name: "User",
50
37
  displayName: "User",
@@ -78,533 +65,4 @@ const userConfig = {
78
65
  // 1.3 CREATE USER MODULE
79
66
  // ============================================================================
80
67
  export const { actionTypes: USER_ACTION_TYPES, config: userModuleConfig, initialState: initialUserState, Provider: UserProvider, reducer: userReducer, useContext: useUserContext, } = createGenericModule(userConfig);
81
- // ============================================================================
82
- // 1.4 ENHANCED USER HOOK WITH API INTEGRATION
83
- // ============================================================================
84
- export const useUserModule = () => {
85
- // ============================================================================
86
- // 1.4.1 STATE & CORE HOOKS
87
- // ============================================================================
88
- const context = useUserContext();
89
- const { dispatch } = context;
90
- const state = context.state;
91
- const t = useTranslations("user");
92
- const { theme } = useTheme();
93
- const workspace = getCachedWorkspaceSync();
94
- const listFetchNowRef = useRef(null);
95
- const debouncedQuery = useDebounce(state.searchQuery, 800);
96
- // ============================================================================
97
- // 1.4.2 API PARAMETERS
98
- // ============================================================================
99
- const listParams = useMemo(() => (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, workspaceId: (workspace === null || workspace === void 0 ? void 0 : workspace.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
100
- ? { filterEnabled: String(state.filterEnabled) }
101
- : {}))), [
102
- state.currentPage,
103
- state.filterEnabled,
104
- state.pageLimit,
105
- debouncedQuery,
106
- workspace === null || workspace === void 0 ? void 0 : workspace.id,
107
- ]);
108
- const updateParams = useMemo(() => ({
109
- avatar: state.avatar,
110
- email: (state.email || "").trim(),
111
- enabled: state.enabled,
112
- id: state.id,
113
- name: (state.name || "").trim(),
114
- password: state.password,
115
- phone: formatNumber(state.phone),
116
- userRole: state.userRole,
117
- workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id,
118
- }), [state, workspace === null || workspace === void 0 ? void 0 : workspace.id]);
119
- const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
120
- const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
121
- const isDefaultListState = state.currentPage === 1 &&
122
- state.pageLimit === pageLimit &&
123
- !debouncedQuery &&
124
- state.filterEnabled === undefined;
125
- // ============================================================================
126
- // 1.4.3 UTILITIES
127
- // ============================================================================
128
- const showToast = useCallback((description, variant) => {
129
- generateThemeToast({
130
- description,
131
- theme: theme,
132
- variant,
133
- });
134
- }, [theme]);
135
- const resetFormAndCloseDrawer = useCallback(() => {
136
- dispatch({ type: USER_ACTION_TYPES.RESET_FORM });
137
- dispatch({
138
- type: USER_ACTION_TYPES.SET_ERRORS,
139
- payload: { errors: {} },
140
- });
141
- dispatch({
142
- type: USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
143
- payload: { disabled: false },
144
- });
145
- dispatch({
146
- type: USER_ACTION_TYPES.SET_DRAWER,
147
- payload: { drawer: null },
148
- });
149
- }, [dispatch]);
150
- // ============================================================================
151
- // 1.4.4 API CALLBACKS
152
- // ============================================================================
153
- const listCallback = useCallback(({ data, error }) => {
154
- var _a, _b;
155
- if (error) {
156
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
157
- return;
158
- }
159
- if (data) {
160
- const response = data;
161
- dispatch({
162
- type: USER_ACTION_TYPES.SET_ITEMS,
163
- payload: { items: (_a = response.items) !== null && _a !== void 0 ? _a : [], count: (_b = response.count) !== null && _b !== void 0 ? _b : 0 },
164
- });
165
- }
166
- }, [dispatch, showToast, t]);
167
- const updateCallback = useCallback(({ data, error }) => {
168
- var _a;
169
- if (error) {
170
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
171
- return;
172
- }
173
- if (data) {
174
- const isCreated = isCreatedOrUpdated(data);
175
- invalidateUsersCache();
176
- invalidateWorkspaceUsersCache();
177
- showToast(isCreated ? t("messagesUserCreated") : t("messagesUserUpdated"), TOAST_VARIANT.SUCCESS);
178
- resetFormAndCloseDrawer();
179
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
180
- }
181
- }, [resetFormAndCloseDrawer, showToast, t]);
182
- const byIdCallback = useCallback(({ data, error }) => {
183
- var _a;
184
- if (error) {
185
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
186
- return;
187
- }
188
- if (data) {
189
- const user = data;
190
- const maybeWithWorkspaces = data;
191
- const wsEntry = (_a = maybeWithWorkspaces.workspaces) === null || _a === void 0 ? void 0 : _a.find((ws) => ws.workspaceId === (workspace === null || workspace === void 0 ? void 0 : workspace.id));
192
- let roleValue = null;
193
- if (wsEntry && wsEntry.role !== undefined && wsEntry.role !== null) {
194
- const r = wsEntry.role;
195
- if (typeof r === "string") {
196
- roleValue = r;
197
- }
198
- else if (typeof r === "object" && r !== null) {
199
- roleValue =
200
- r.userRole ||
201
- r.name ||
202
- null;
203
- }
204
- }
205
- const parsedUserRole = roleValue || null;
206
- dispatch({
207
- type: USER_ACTION_TYPES.SET_FORM_DATA,
208
- payload: {
209
- form: {
210
- id: user.id,
211
- name: user.name || "",
212
- email: user.email,
213
- phone: formatPhoneDisplay(user.phone) || "",
214
- avatar: user.avatar || "",
215
- enabled: user.enabled,
216
- userRole: parsedUserRole,
217
- password: "",
218
- },
219
- },
220
- });
221
- }
222
- }, [dispatch, showToast, t, workspace === null || workspace === void 0 ? void 0 : workspace.id]);
223
- const deleteCallback = useCallback(({ data, error }) => {
224
- var _a;
225
- if (error) {
226
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
227
- return;
228
- }
229
- if (data) {
230
- invalidateUsersCache();
231
- invalidateWorkspaceUsersCache();
232
- showToast(t("messagesUserDeleted"), TOAST_VARIANT.SUCCESS);
233
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
234
- }
235
- }, [showToast, t]);
236
- // ============================================================================
237
- // 1.4.5 API HOOKS
238
- // ============================================================================
239
- const { byIdFetchNow, byIdLoading, deleteFetchNow, deleteLoading, listFetchNow, listLoading, updateFetchNow, updateLoading, } = useModuleEntityV2({
240
- byIdCallback,
241
- byIdParams,
242
- deleteCallback,
243
- deleteParams,
244
- listCallback,
245
- listParams,
246
- listUrl: USER_API_ROUTES.LIST,
247
- searchQuery: debouncedQuery,
248
- unitByIdUrl: USER_API_ROUTES.UNIT,
249
- unitUrl: USER_API_ROUTES.UNIT,
250
- updateCallback,
251
- updateParams,
252
- headers: {
253
- "Content-Type": "application/json",
254
- "x-api-token": process.env.NEXT_PUBLIC_API_KEY,
255
- },
256
- });
257
- // ============================================================================
258
- // 1.4.6 HANDLERS
259
- // ============================================================================
260
- const handleChange = useCallback((field, value) => {
261
- dispatch({
262
- type: USER_ACTION_TYPES.SET_ERRORS,
263
- payload: { errors: {} },
264
- });
265
- dispatch({
266
- type: USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
267
- payload: { disabled: false },
268
- });
269
- const normalized = field === "email" && typeof value === "string"
270
- ? value.toLowerCase()
271
- : value;
272
- dispatch({
273
- type: USER_ACTION_TYPES.SET_INPUT_FIELD,
274
- payload: {
275
- key: field,
276
- value: normalized,
277
- },
278
- });
279
- }, [dispatch]);
280
- const closeDrawer = useCallback(() => {
281
- resetFormAndCloseDrawer();
282
- }, [resetFormAndCloseDrawer]);
283
- const handleCreate = useCallback(() => {
284
- dispatch({
285
- type: USER_ACTION_TYPES.SET_DRAWER,
286
- payload: { drawer: USER_DRAWER.FORM_DRAWER },
287
- });
288
- }, [dispatch]);
289
- const handleView = useCallback((row) => {
290
- byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
291
- dispatch({
292
- type: USER_ACTION_TYPES.SET_DRAWER,
293
- payload: { drawer: USER_DRAWER.VIEW_DRAWER },
294
- });
295
- }, [byIdFetchNow, dispatch]);
296
- const handleEdit = useCallback((row) => {
297
- byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
298
- dispatch({
299
- type: USER_ACTION_TYPES.SET_DRAWER,
300
- payload: { drawer: USER_DRAWER.FORM_DRAWER },
301
- });
302
- }, [byIdFetchNow, dispatch]);
303
- const handleDelete = useCallback((row) => {
304
- if (!confirm(t("messagesDeleteConfirmation")))
305
- return;
306
- deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
307
- body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id }),
308
- });
309
- }, [deleteFetchNow, t]);
310
- const handleFilters = useCallback(() => {
311
- dispatch({
312
- type: USER_ACTION_TYPES.SET_DRAWER,
313
- payload: { drawer: USER_DRAWER.FILTER_DRAWER },
314
- });
315
- }, [dispatch]);
316
- const handleMoreActions = useCallback(() => {
317
- dispatch({
318
- type: USER_ACTION_TYPES.SET_DRAWER,
319
- payload: { drawer: USER_DRAWER.MORE_ACTIONS_DRAWER },
320
- });
321
- }, [dispatch]);
322
- const handlePageChange = useCallback((page) => {
323
- const nextPage = typeof page === "number" ? page : state.currentPage + 1;
324
- dispatch({
325
- type: USER_ACTION_TYPES.SET_CURRENT_PAGE,
326
- payload: { currentPage: nextPage },
327
- });
328
- }, [dispatch, state.currentPage]);
329
- const handlePageLimitChange = useCallback((k, value) => {
330
- const val = Object.assign({}, value);
331
- dispatch({
332
- type: USER_ACTION_TYPES.SET_PAGE_LIMIT,
333
- payload: { pageLimit: Number(val.option) },
334
- });
335
- dispatch({
336
- type: USER_ACTION_TYPES.SET_CURRENT_PAGE,
337
- payload: { currentPage: 1 },
338
- });
339
- }, [dispatch]);
340
- const handleSearch = useCallback((query) => {
341
- dispatch({
342
- type: USER_ACTION_TYPES.SET_SEARCH_QUERY,
343
- payload: { searchQuery: query },
344
- });
345
- }, [dispatch]);
346
- const clearSearch = useCallback(() => {
347
- dispatch({
348
- type: USER_ACTION_TYPES.SET_SEARCH_QUERY,
349
- payload: { searchQuery: "" },
350
- });
351
- }, [dispatch]);
352
- const handleAvatar = useCallback((files) => {
353
- if (!files || files.length === 0)
354
- return;
355
- const file = files[0];
356
- const blob = new Blob([file], { type: file.type });
357
- const url = URL.createObjectURL(blob);
358
- dispatch({
359
- type: USER_ACTION_TYPES.SET_INPUT_FIELD,
360
- payload: { key: "avatar", value: url },
361
- });
362
- }, [dispatch]);
363
- const applyFilters = useCallback(() => {
364
- dispatch({
365
- type: USER_ACTION_TYPES.SET_CURRENT_PAGE,
366
- payload: { currentPage: 1 },
367
- });
368
- closeDrawer();
369
- }, [dispatch, closeDrawer]);
370
- const clearFilters = useCallback(() => {
371
- dispatch({
372
- type: USER_ACTION_TYPES.SET_FILTERS,
373
- payload: { filters: { filterEnabled: undefined } },
374
- });
375
- dispatch({
376
- type: USER_ACTION_TYPES.SET_CURRENT_PAGE,
377
- payload: { currentPage: 1 },
378
- });
379
- }, [dispatch]);
380
- const toggleStatus = useCallback((row) => {
381
- updateFetchNow(undefined, {
382
- body: JSON.stringify(Object.assign(Object.assign({}, row), { workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id, enabled: !(row === null || row === void 0 ? void 0 : row.enabled) })),
383
- });
384
- }, [updateFetchNow, workspace === null || workspace === void 0 ? void 0 : workspace.id]);
385
- // ============================================================================
386
- // 1.4.7 NETWORK ACTIONS
387
- // ============================================================================
388
- const handleUploadImage = useCallback(async () => {
389
- var _a;
390
- if (!((_a = state.avatar) === null || _a === void 0 ? void 0 : _a.startsWith("blob:")))
391
- return undefined;
392
- const fileRef = `${workspace === null || workspace === void 0 ? void 0 : workspace.id}/${updateParams.id}/avatar/${updateParams.id}.webp`;
393
- try {
394
- const blob = await fetch(state.avatar).then((r) => r.blob());
395
- const webpBlob = await blobToWebP(blob, { quality: 0.8 });
396
- const arrayBuffer = await webpBlob.arrayBuffer();
397
- let binary = "";
398
- const bytes = new Uint8Array(arrayBuffer);
399
- const chunkSize = 0x8000;
400
- for (let i = 0; i < bytes.length; i += chunkSize) {
401
- const sub = bytes.subarray(i, i + chunkSize);
402
- for (let j = 0; j < sub.length; j++) {
403
- binary += String.fromCharCode(sub[j]);
404
- }
405
- }
406
- const base64 = btoa(binary);
407
- const res = await fetch("/api/uploads/avatar", {
408
- method: "POST",
409
- headers: { "Content-Type": "application/json" },
410
- body: JSON.stringify({
411
- fileBase64: base64,
412
- fileRef,
413
- contentType: webpBlob.type,
414
- }),
415
- });
416
- if (!res.ok)
417
- throw new Error("Upload failed");
418
- const responseData = await res.json();
419
- if (responseData === null || responseData === void 0 ? void 0 : responseData.path) {
420
- const url = `${supabasePublicStorageUrl}/${responseData.path}`;
421
- dispatch({
422
- type: USER_ACTION_TYPES.SET_INPUT_FIELD,
423
- payload: { key: "avatar", value: url },
424
- });
425
- return url;
426
- }
427
- }
428
- catch (_b) {
429
- toastNetworkError();
430
- }
431
- return undefined;
432
- }, [state.avatar, dispatch, workspace === null || workspace === void 0 ? void 0 : workspace.id, updateParams.id]);
433
- const checkUserEmailExists = useCallback(async (emailParam) => {
434
- var _a;
435
- const targetEmail = (typeof emailParam === "string" && emailParam) || state.email;
436
- if (!targetEmail)
437
- return null;
438
- const result = await fetchData({
439
- url: `${USER_API_ROUTES.UNIT_BY_EMAIL}?email=${encodeURIComponent(String(targetEmail))}`,
440
- method: API_METHODS.GET,
441
- headers: {
442
- "x-api-token": process.env.NEXT_PUBLIC_API_KEY,
443
- },
444
- });
445
- return (_a = result === null || result === void 0 ? void 0 : result.data) !== null && _a !== void 0 ? _a : null;
446
- }, [state.email]);
447
- const handleSubmit = useCallback(async () => {
448
- dispatch({
449
- type: USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
450
- payload: { disabled: true },
451
- });
452
- const uploadedUrl = await handleUploadImage();
453
- const finalParams = uploadedUrl
454
- ? Object.assign(Object.assign({}, updateParams), { avatar: uploadedUrl }) : updateParams;
455
- validateForm({
456
- params: finalParams,
457
- schema: userFormValidation,
458
- successCallback: async () => {
459
- try {
460
- const existing = await checkUserEmailExists(state.email);
461
- if (existing &&
462
- existing.id &&
463
- existing.id !== state.id) {
464
- dispatch({
465
- type: USER_ACTION_TYPES.SET_ERRORS,
466
- payload: { errors: { email: t("messagesEmailAlreadyInUse") } },
467
- });
468
- dispatch({
469
- type: USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
470
- payload: { disabled: false },
471
- });
472
- return;
473
- }
474
- updateFetchNow(undefined, { body: JSON.stringify(finalParams) });
475
- }
476
- catch (_a) {
477
- toastNetworkError();
478
- dispatch({
479
- type: USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
480
- payload: { disabled: false },
481
- });
482
- }
483
- },
484
- errorCallback: (errors) => {
485
- dispatch({
486
- type: USER_ACTION_TYPES.SET_ERRORS,
487
- payload: { errors },
488
- });
489
- dispatch({
490
- type: USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
491
- payload: { disabled: false },
492
- });
493
- showToast(t("messagesFormErrors"), TOAST_VARIANT.ERROR);
494
- },
495
- });
496
- }, [
497
- checkUserEmailExists,
498
- dispatch,
499
- handleUploadImage,
500
- showToast,
501
- state.email,
502
- state.id,
503
- t,
504
- updateFetchNow,
505
- updateParams,
506
- ]);
507
- // ============================================================================
508
- // 1.4.8 HEADER & ROW ACTIONS
509
- // ============================================================================
510
- const headerActions = useMemo(() => [
511
- {
512
- enabled: false,
513
- handleOnClick: handleMoreActions,
514
- label: t("actionsButtonMoreActions"),
515
- order: 0,
516
- },
517
- {
518
- enabled: false,
519
- handleOnClick: handleFilters,
520
- label: t("actionsButtonFilters"),
521
- order: 1,
522
- },
523
- {
524
- enabled: true,
525
- handleOnClick: handleCreate,
526
- label: t("actionsButtonAdd"),
527
- order: 2,
528
- },
529
- ], [handleCreate, handleFilters, handleMoreActions, t]);
530
- const rowActions = useMemo(() => [
531
- {
532
- enabled: true,
533
- handleOnClick: handleView,
534
- label: t("actionsButtonView"),
535
- order: 1,
536
- },
537
- {
538
- enabled: true,
539
- handleOnClick: handleEdit,
540
- label: t("actionsButtonEdit"),
541
- order: 2,
542
- },
543
- {
544
- enabled: false,
545
- handleOnClick: handleDelete,
546
- label: t("actionsButtonDelete"),
547
- order: 3,
548
- },
549
- {
550
- enabled: false,
551
- handleOnClick: toggleStatus,
552
- label: t("actionsButtonToggleStatus"),
553
- order: 4,
554
- },
555
- ], [handleDelete, handleEdit, handleView, t, toggleStatus]);
556
- // ============================================================================
557
- // 1.4.9 EFFECTS
558
- // ============================================================================
559
- useEffect(() => {
560
- var _a;
561
- if (!(workspace === null || workspace === void 0 ? void 0 : workspace.id))
562
- return;
563
- if (isDefaultListState) {
564
- (async () => {
565
- try {
566
- const { count, items } = await getCachedUsers({ params: listParams });
567
- dispatch({
568
- type: USER_ACTION_TYPES.SET_ITEMS,
569
- payload: { items: items || [], count: count || 0 },
570
- });
571
- }
572
- catch (_a) {
573
- showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
574
- }
575
- })();
576
- return;
577
- }
578
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
579
- }, [dispatch, isDefaultListState, listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, showToast, t]);
580
- useEffect(() => {
581
- listFetchNowRef.current = listFetchNow;
582
- }, [listFetchNow]);
583
- // ============================================================================
584
- // 1.4.10 RETURN
585
- // ============================================================================
586
- return Object.assign(Object.assign({}, context), { applyFilters,
587
- byIdLoading,
588
- clearFilters,
589
- clearSearch,
590
- closeDrawer,
591
- deleteLoading,
592
- handleAvatar,
593
- handleChange,
594
- handleCreate,
595
- handleDelete,
596
- handleEdit,
597
- handleFilters,
598
- handleMoreActions,
599
- handlePageChange,
600
- handlePageLimitChange,
601
- handleSearch,
602
- handleSubmit,
603
- handleView,
604
- headerActions,
605
- listFetchNow,
606
- listLoading,
607
- rowActions,
608
- toggleStatus,
609
- updateLoading });
610
- };
68
+ export { useUserModule } from "./context/use-user-module";
@@ -28,7 +28,6 @@ export const WorkspaceUserMoreActions = () => {
28
28
  {
29
29
  id: "3",
30
30
  title: t("uploadTheCompletedCsvToTheSystem"),
31
- handleOnClick: () => console.log("clicked"),
32
31
  },
33
32
  ];
34
33
  const update = [
@@ -41,11 +40,7 @@ export const WorkspaceUserMoreActions = () => {
41
40
  },
42
41
  },
43
42
  { id: "2", title: t("updateYourDataInTheCsv") },
44
- {
45
- id: "3",
46
- title: t("uploadTheCompletedCsvToTheSystem"),
47
- handleOnClick: () => console.log("clicked"),
48
- },
43
+ { id: "3", title: t("uploadTheCompletedCsvToTheSystem") },
49
44
  ];
50
45
  return (_jsxs("div", { className: "space-y-4", children: [_jsx(Timeline, { events: create, heading: t("bulkCreate") }), _jsx(Timeline, { events: update, heading: t("bulkUpdate") })] }));
51
46
  };
@@ -0,0 +1,9 @@
1
+ import { FC } from "react";
2
+ interface ModuleErrorProps {
3
+ error: Error & {
4
+ digest?: string;
5
+ };
6
+ reset: () => void;
7
+ }
8
+ export declare const ModuleError: FC<ModuleErrorProps>;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ export const ModuleError = ({ error, reset }) => (_jsxs("div", { className: "flex min-h-[400px] flex-col items-center justify-center gap-4 p-8", children: [_jsx("div", { className: "text-destructive text-6xl", children: "!" }), _jsx("h2", { className: "text-foreground text-2xl font-semibold", children: "Something went wrong" }), _jsx("p", { className: "text-muted-foreground max-w-md text-center text-sm", children: error.message || "An unexpected error occurred. Please try again." }), _jsx("button", { onClick: reset, className: "bg-primary text-primary-foreground hover:bg-primary/90 rounded-lg px-4 py-2 text-sm font-medium transition-colors", children: "Try again" })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",
@@ -24,7 +24,8 @@
24
24
  "test:e2e:ui": "playwright test --ui",
25
25
  "test:e2e": "playwright test",
26
26
  "test:watch": "jest --watch",
27
- "test": "jest --watchAll=false"
27
+ "test": "jest --watchAll=false",
28
+ "typecheck": "tsc --noEmit"
28
29
  },
29
30
  "lint-staged": {
30
31
  "*.{js,jsx,ts,tsx}": [
@@ -37,7 +38,7 @@
37
38
  },
38
39
  "devDependencies": {
39
40
  "@appcorp/app-corp-vista": "^1.0.0",
40
- "@appcorp/shadcn": "^1.1.88",
41
+ "@appcorp/shadcn": "^1.1.90",
41
42
  "@chromatic-com/storybook": "^5.1.2",
42
43
  "@commitlint/cli": "^20.5.0",
43
44
  "@commitlint/config-conventional": "^20.5.0",
@@ -100,7 +101,6 @@
100
101
  "react": "^19.2.5",
101
102
  "react-dom": "^19.2.5",
102
103
  "react-dropzone": "^15.0.0",
103
- "react-easy-crop": "^5.5.7",
104
104
  "rimraf": "^6.1.3",
105
105
  "sonner": "^2.0.7",
106
106
  "storybook": "^10.3.4",
@@ -115,6 +115,7 @@
115
115
  "vitest": "^4.1.2",
116
116
  "webp-converter-browser": "^1.0.4"
117
117
  },
118
+ "license": "MIT",
118
119
  "packageManager": "yarn@4.14.1",
119
120
  "engines": {
120
121
  "node": "24",