@appcorp/fusion-storybook 0.3.65 → 0.3.66

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.
@@ -14,6 +14,7 @@ export declare const useStudentFeeModule: () => {
14
14
  handleDelete: (row?: TableRow) => void;
15
15
  handleEdit: (row?: TableRow) => void;
16
16
  handleFilters: () => void;
17
+ setPendingFilter: (field: string, value: boolean | undefined | string) => void;
17
18
  handleMoreActions: () => void;
18
19
  handlePageChange: (page: number | unknown) => void;
19
20
  handlePageLimitChange: (k: string, value: object) => void;
@@ -40,6 +40,13 @@ export const useStudentFeeModule = () => {
40
40
  const workspace = getCachedWorkspaceSync();
41
41
  const listFetchNowRef = useRef(null);
42
42
  const debouncedQuery = useDebounce(state.searchQuery, 800);
43
+ const pendingFiltersRef = useRef({
44
+ filterEnabled: state.filterEnabled,
45
+ filterStatus: state.filterStatus || "",
46
+ });
47
+ const setPendingFilter = useCallback((field, value) => {
48
+ pendingFiltersRef.current = Object.assign(Object.assign({}, pendingFiltersRef.current), { [field]: value });
49
+ }, []);
43
50
  // ============================================================================
44
51
  // 1.4.2 API PARAMETERS
45
52
  // ============================================================================
@@ -501,6 +508,16 @@ export const useStudentFeeModule = () => {
501
508
  });
502
509
  }, [dispatch]);
503
510
  const applyFilters = useCallback(() => {
511
+ const pending = pendingFiltersRef.current;
512
+ dispatch({
513
+ type: STUDENT_FEE_ACTION_TYPES.SET_FILTERS,
514
+ payload: {
515
+ filters: {
516
+ filterEnabled: pending.filterEnabled,
517
+ filterStatus: pending.filterStatus,
518
+ },
519
+ },
520
+ });
504
521
  dispatch({
505
522
  type: STUDENT_FEE_ACTION_TYPES.SET_CURRENT_PAGE,
506
523
  payload: { currentPage: 1 },
@@ -508,6 +525,10 @@ export const useStudentFeeModule = () => {
508
525
  closeDrawer();
509
526
  }, [dispatch, closeDrawer]);
510
527
  const clearFilters = useCallback(() => {
528
+ pendingFiltersRef.current = {
529
+ filterEnabled: undefined,
530
+ filterStatus: "",
531
+ };
511
532
  dispatch({
512
533
  type: STUDENT_FEE_ACTION_TYPES.SET_CURRENT_PAGE,
513
534
  payload: { currentPage: 1 },
@@ -699,6 +720,7 @@ export const useStudentFeeModule = () => {
699
720
  handleDelete,
700
721
  handleEdit,
701
722
  handleFilters,
723
+ setPendingFilter,
702
724
  handleMoreActions,
703
725
  handlePageChange,
704
726
  handlePageLimitChange,
@@ -6,6 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  * Filter UI for the student-fee list. Supports filterEnabled (radio) and
7
7
  * filterStatus (payment status combobox).
8
8
  */
9
+ import { useState } from "react";
9
10
  import { EnhancedRadio } from "@appcorp/shadcn/components/enhanced-radio";
10
11
  import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
11
12
  import { useStudentFeeModule } from "./context";
@@ -13,9 +14,11 @@ import { PAYMENT_STATUS_OPTIONS } from "./constants";
13
14
  import { STUDENT_FEE_API_ROUTES } from "../../constants";
14
15
  import { useTranslations } from "next-intl";
15
16
  export const StudentFeeFilter = () => {
16
- const { state, handleChange } = useStudentFeeModule();
17
+ const { state, setPendingFilter } = useStudentFeeModule();
17
18
  const { filterEnabled, filterStatus } = state;
18
19
  const t = useTranslations("studentFee");
20
+ const [localFilterEnabled, setLocalFilterEnabled] = useState(filterEnabled);
21
+ const [localFilterStatus, setLocalFilterStatus] = useState(filterStatus || "");
19
22
  const paymentStatusLabelMap = {
20
23
  PENDING: t("formOptionPending"),
21
24
  PARTIAL: t("formOptionPartial"),
@@ -24,17 +27,26 @@ export const StudentFeeFilter = () => {
24
27
  CANCELLED: t("formOptionCancelled"),
25
28
  REFUNDED: t("formOptionRefunded"),
26
29
  };
27
- const filterEnabledValue = filterEnabled === undefined
30
+ const filterEnabledValue = localFilterEnabled === undefined
28
31
  ? "undefined"
29
- : filterEnabled
32
+ : localFilterEnabled
30
33
  ? "true"
31
34
  : "false";
35
+ const handleStatusChange = (value) => {
36
+ setLocalFilterStatus(value);
37
+ setPendingFilter("filterStatus", value);
38
+ };
39
+ const handleEnabledChange = (next) => {
40
+ const parsed = next === "true" ? true : next === "false" ? false : undefined;
41
+ setLocalFilterEnabled(parsed);
42
+ setPendingFilter("filterEnabled", parsed);
43
+ };
32
44
  const { enhancedComboboxElement: filterStatusCombo } = useEnhancedCombobox({
33
45
  emptyText: t("filterNoStatusFoundLabel"),
34
46
  id: "filterStatus",
35
47
  info: t("filterByPaymentStatus"),
36
48
  label: t("filterPaymentStatusLabel"),
37
- onValueChange: (value) => handleChange("filterStatus", value),
49
+ onValueChange: handleStatusChange,
38
50
  options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
39
51
  value: opt.value,
40
52
  label: paymentStatusLabelMap[opt.value] || opt.label,
@@ -49,14 +61,11 @@ export const StudentFeeFilter = () => {
49
61
  value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
50
62
  });
51
63
  },
52
- value: filterStatus || "",
64
+ value: localFilterStatus,
53
65
  });
54
66
  return (_jsxs("div", { className: "space-y-4", children: [filterStatusCombo, _jsx(EnhancedRadio, { label: t("filterEnabledLabel"), name: "filterEnabled", value: filterEnabledValue, options: [
55
67
  { label: t("filterOptionAll"), value: "undefined" },
56
68
  { label: t("filterOptionEnabled"), value: "true" },
57
69
  { label: t("filterOptionDisabled"), value: "false" },
58
- ], onValueChange: (next) => {
59
- const parsed = next === "true" ? true : next === "false" ? false : undefined;
60
- handleChange("filterEnabled", parsed);
61
- } })] }));
70
+ ], onValueChange: handleEnabledChange })] }));
62
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.3.65",
3
+ "version": "0.3.66",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",