@appcorp/fusion-storybook 0.3.1 → 0.3.2

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.
@@ -472,6 +472,10 @@ export const useStudentFeeModule = () => {
472
472
  }, [dispatch, resetRecordFormState]);
473
473
  const handleCreateMonthly = useCallback(() => {
474
474
  resetRecordFormState();
475
+ dispatch({
476
+ type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
477
+ payload: { disabled: true },
478
+ });
475
479
  dispatch({
476
480
  type: STUDENT_FEE_ACTION_TYPES.SET_DRAWER,
477
481
  payload: { drawer: STUDENT_FEE_DRAWER.CREATE_MONTHLY_DRAWER },
@@ -1,7 +1,27 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useState } from "react";
3
4
  import { useTranslations } from "next-intl";
5
+ import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
6
+ import { useStudentFeeModule, STUDENT_FEE_ACTION_TYPES } from "./context";
7
+ const CHECKBOX_KEYS = [
8
+ "formMonthlyCheckStudentProfile",
9
+ "formMonthlyCheckFeeStructure",
10
+ "formMonthlyCheckGmail",
11
+ "formMonthlyCheckReady",
12
+ ];
4
13
  export const StudentFeeMonthlyForm = () => {
5
14
  const t = useTranslations("studentFee");
6
- return (_jsx("div", { className: "grid grid-cols-1 gap-4", children: _jsxs("div", { children: [_jsx("h3", { children: t("formMonthlyProceedInfo") }), _jsx("p", { children: t("formMonthlyAdjustmentNote") })] }) }));
15
+ const { dispatch } = useStudentFeeModule();
16
+ const [checked, setChecked] = useState(Object.fromEntries(CHECKBOX_KEYS.map((key) => [key, false])));
17
+ const allChecked = CHECKBOX_KEYS.every((key) => checked[key]);
18
+ const handleCheckChange = useCallback((key, value) => {
19
+ const next = Object.assign(Object.assign({}, checked), { [key]: value });
20
+ setChecked(next);
21
+ dispatch({
22
+ type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
23
+ payload: { disabled: !CHECKBOX_KEYS.every((k) => next[k]) },
24
+ });
25
+ }, [checked, dispatch]);
26
+ return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx("p", { className: "text-sm text-foreground", children: t("formMonthlyWarningMessage") }), _jsx("div", { className: "flex flex-col gap-3", children: CHECKBOX_KEYS.map((key) => (_jsx(EnhancedCheckbox, { checked: checked[key], id: key, label: t(key), onCheckedChange: (value) => handleCheckChange(key, value) }, key))) })] }));
7
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",