@appcorp/fusion-storybook 0.1.31 → 0.1.34

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.
@@ -25,7 +25,7 @@ import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
25
25
  import { createGenericModule } from "@react-pakistan/util-functions/factory/generic-module-factory";
26
26
  import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
27
27
  import { SUBJECT_API_ROUTES, pageLimit } from "./constants";
28
- import { getCachedSubjects, getCachedSubjectsSync, invalidateSubjectsCache, isSubjectsCacheStale, } from "./cache";
28
+ import { getCachedSubjects, invalidateSubjectsCache } from "./cache";
29
29
  import { subjectFormValidation } from "./validate";
30
30
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
31
31
  import { useTranslations } from "next-intl";
@@ -185,38 +185,26 @@ export const useSubjectModule = () => {
185
185
  listFetchNow();
186
186
  }
187
187
  };
188
- // ============================================================================ // INITIAL DATA LOADING (sync cache to prevent UI hanging)
188
+ // ============================================================================
189
+ // INITIAL DATA LOADING (sync cache to prevent UI hanging)
189
190
  // ============================================================================
190
191
  useEffect(() => {
191
192
  if (!schoolId)
192
193
  return;
193
- // Use sync cache for initial load to prevent UI hanging
194
- const cachedData = getCachedSubjectsSync();
195
- if (cachedData && !isSubjectsCacheStale()) {
196
- // Cache is fresh, use it immediately
197
- const { count, items } = cachedData;
198
- dispatch({
199
- type: SUBJECT_ACTION_TYPES.SET_ITEMS,
200
- payload: { items: items || [], count: count || 0 },
201
- });
202
- }
203
- else {
204
- // Cache is stale or empty, fetch async
205
- (async () => {
206
- try {
207
- const { count, items } = await getCachedSubjects({
208
- params: listParams,
209
- });
210
- dispatch({
211
- type: SUBJECT_ACTION_TYPES.SET_ITEMS,
212
- payload: { items: items || [], count: count || 0 },
213
- });
214
- }
215
- catch (_a) {
216
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
217
- }
218
- })();
219
- }
194
+ (async () => {
195
+ try {
196
+ const { count, items } = await getCachedSubjects({
197
+ params: listParams,
198
+ });
199
+ dispatch({
200
+ type: SUBJECT_ACTION_TYPES.SET_ITEMS,
201
+ payload: { items: items || [], count: count || 0 },
202
+ });
203
+ }
204
+ catch (_a) {
205
+ showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
206
+ }
207
+ })();
220
208
  }, [listParams, schoolId, showToast, t, dispatch]);
221
209
  // ============================================================================
222
210
  // API HOOKS
@@ -412,25 +400,6 @@ export const useSubjectModule = () => {
412
400
  handleCloseDrawer();
413
401
  }, [dispatch, listFetchNow, handleCloseDrawer]);
414
402
  // ============================================================================
415
- // EFFECTS
416
- // ============================================================================
417
- useEffect(() => {
418
- (async () => {
419
- try {
420
- const { count, items } = await getCachedSubjects({
421
- params: listParams,
422
- });
423
- context.dispatch({
424
- type: SUBJECT_ACTION_TYPES.SET_ITEMS,
425
- payload: { items: items || [], count: count || 0 },
426
- });
427
- }
428
- catch (_a) {
429
- showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
430
- }
431
- })();
432
- }, [listParams, context, showToast, t]);
433
- // ============================================================================
434
403
  // RETURN
435
404
  // ============================================================================
436
405
  return Object.assign(Object.assign({}, context), { applyFilters,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.31",
3
+ "version": "0.1.34",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",