@appcorp/fusion-storybook 0.1.94 → 0.1.95

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.
@@ -27,6 +27,7 @@ export declare const FEE_STRUCTURE_ACTION_TYPES: {
27
27
  disableSaveButton: boolean;
28
28
  drawer: string | null;
29
29
  amount: number;
30
+ classId: string | null;
30
31
  description: string | null;
31
32
  enabled: boolean;
32
33
  errors: Record<string, string>;
@@ -45,6 +46,7 @@ export declare const FEE_STRUCTURE_ACTION_TYPES: {
45
46
  disableSaveButton: boolean;
46
47
  drawer: string | null;
47
48
  amount: number;
49
+ classId: string | null;
48
50
  description: string | null;
49
51
  enabled: boolean;
50
52
  errors: Record<string, string>;
@@ -65,6 +67,7 @@ export declare const FEE_STRUCTURE_ACTION_TYPES: {
65
67
  disableSaveButton: boolean;
66
68
  drawer: string | null;
67
69
  amount: number;
70
+ classId: string | null;
68
71
  description: string | null;
69
72
  enabled: boolean;
70
73
  errors: Record<string, string>;
@@ -83,6 +86,7 @@ export declare const FEE_STRUCTURE_ACTION_TYPES: {
83
86
  disableSaveButton: boolean;
84
87
  drawer: string | null;
85
88
  amount: number;
89
+ classId: string | null;
86
90
  description: string | null;
87
91
  enabled: boolean;
88
92
  errors: Record<string, string>;
@@ -101,6 +105,7 @@ export declare const FEE_STRUCTURE_ACTION_TYPES: {
101
105
  disableSaveButton: boolean;
102
106
  drawer: string | null;
103
107
  amount: number;
108
+ classId: string | null;
104
109
  description: string | null;
105
110
  enabled: boolean;
106
111
  errors: Record<string, string>;
@@ -149,6 +154,7 @@ export declare const useFeeStructureModule: () => {
149
154
  disableSaveButton: boolean;
150
155
  drawer: string | null;
151
156
  amount: number;
157
+ classId: string | null;
152
158
  description: string | null;
153
159
  enabled: boolean;
154
160
  errors: Record<string, string>;
@@ -56,6 +56,7 @@ const feeStructureConfig = {
56
56
  drawer: null,
57
57
  // Form State
58
58
  amount: 0,
59
+ classId: null,
59
60
  description: null,
60
61
  enabled: true,
61
62
  errors: {},
@@ -100,7 +101,7 @@ export const useFeeStructureModule = () => {
100
101
  debouncedQuery,
101
102
  schoolId,
102
103
  ]);
103
- const updateParams = useMemo(() => (Object.assign(Object.assign(Object.assign({}, (state.id ? { id: state.id } : {})), (!state.id ? { schoolId } : {})), { amount: Number(state.amount), description: state.description || null, enabled: state.enabled, feeType: state.feeType, frequency: state.frequency || null, name: state.name })), [state, schoolId]);
104
+ const updateParams = useMemo(() => (Object.assign(Object.assign(Object.assign({}, (state.id ? { id: state.id } : {})), (!state.id ? { schoolId } : {})), { amount: Number(state.amount), classId: state.classId || null, description: state.description || null, enabled: state.enabled, feeType: state.feeType, frequency: state.frequency || null, name: state.name })), [state, schoolId]);
104
105
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
105
106
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
106
107
  const isDefaultListState = state.currentPage === 1 &&
@@ -11,21 +11,25 @@ import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
11
11
  import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
12
12
  import { useFeeStructureModule } from "./context";
13
13
  import { FEE_TYPE_OPTIONS, FREQUENCY_OPTIONS } from "./constants";
14
+ import { getCachedClassesSync } from "../class/cache";
14
15
  import { getCachedWorkspaceSync } from "../workspace/cache";
15
16
  import { useTranslations } from "next-intl";
16
17
  export const FeeStructureForm = () => {
17
18
  var _a, _b;
18
19
  const { state, handleChange } = useFeeStructureModule();
19
- const { amount, description, enabled, errors, feeType, frequency, name } = state;
20
+ const { amount, classId, description, enabled, errors, feeType, frequency, name, } = state;
20
21
  const t = useTranslations("feeStructure");
21
22
  const workspace = getCachedWorkspaceSync();
22
- return (_jsx("div", { className: "space-y-4", children: _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionFeeStructureInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { error: errors.name, id: "name", info: t("formNameInfo"), label: t("formNameLabel"), onChange: (e) => handleChange("name", e.target.value), placeholder: t("formNamePlaceholder"), required: true, value: name || "" }), _jsx(EnhancedCombobox, { emptyText: t("formNoFeeTypeEmpty"), error: errors.feeType, id: "feeType", info: t("formFeeTypeInfo"), label: t("formOptionFeeType"), onValueChange: (value) => handleChange("feeType", value), options: FEE_TYPE_OPTIONS.map((opt) => ({
23
- label: t(`feeType${opt.value.charAt(0).toUpperCase() + opt.value.slice(1).toLowerCase()}`),
24
- value: opt.value,
25
- })), placeholder: t("formFeeTypePlaceholder"), required: true, searchPlaceholder: t("formSearchFeeTypePlaceholder"), value: feeType || "" }), _jsx(EnhancedInput, { error: errors.amount, id: "amount", info: t(`amountInfo`, {
26
- currency: (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : "",
27
- }), label: t("formAmountLabel"), min: "0", onChange: (e) => handleChange("amount", Number(e.target.value)), placeholder: t("formAmountPlaceholder"), required: true, step: "0.01", type: "number", value: amount }), _jsx(EnhancedCombobox, { emptyText: t("formNoFrequencyEmpty"), id: "frequency", info: t("formFrequencyInfo"), label: t("formOptionFrequency"), onValueChange: (value) => handleChange("frequency", value), options: FREQUENCY_OPTIONS.map((opt) => ({
28
- label: t(`frequency${opt.value.replace(/-/g, "")}`),
29
- value: opt.value,
30
- })), placeholder: t("formFrequencyPlaceholder"), searchPlaceholder: t("formSearchFrequencyPlaceholder"), value: frequency || "" }), _jsx(EnhancedTextarea, { error: errors.description, id: "description", info: t("formDescriptionInfo"), label: t("formDescriptionLabel"), onChange: (e) => handleChange("description", e.target.value), placeholder: t("formDescriptionPlaceholder"), rows: 3, value: description || "" })] }), _jsx(EnhancedCheckbox, { defaultChecked: enabled, label: t("formActiveFeeStructureLabel"), onCheckedChange: (checked) => handleChange("enabled", checked) })] }) }));
23
+ const classOptions = (getCachedClassesSync().items || [])
24
+ .filter((c) => c.enabled)
25
+ .map((c) => ({ label: `${c.name} (${c.code})`, value: c.id }));
26
+ return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { error: errors.name, id: "name", info: t("formNameInfo"), label: t("formNameLabel"), onChange: (e) => handleChange("name", e.target.value), placeholder: t("formNamePlaceholder"), required: true, value: name || "" }), _jsx(EnhancedCombobox, { emptyText: t("formNoFeeTypeEmpty"), error: errors.feeType, id: "feeType", info: t("formFeeTypeInfo"), label: t("formOptionFeeType"), onValueChange: (value) => handleChange("feeType", value), options: FEE_TYPE_OPTIONS.map((opt) => ({
27
+ label: t(`feeType${opt.value.charAt(0).toUpperCase() + opt.value.slice(1).toLowerCase()}`),
28
+ value: opt.value,
29
+ })), placeholder: t("formFeeTypePlaceholder"), required: true, searchPlaceholder: t("formSearchFeeTypePlaceholder"), value: feeType || "" }), _jsx(EnhancedInput, { error: errors.amount, id: "amount", info: t(`amountInfo`, {
30
+ currency: (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : "",
31
+ }), label: t("formAmountLabel"), min: "0", onChange: (e) => handleChange("amount", Number(e.target.value)), placeholder: t("formAmountPlaceholder"), required: true, step: "0.01", type: "number", value: amount }), _jsx(EnhancedCombobox, { emptyText: t("formNoFrequencyEmpty"), id: "frequency", info: t("formFrequencyInfo"), label: t("formOptionFrequency"), onValueChange: (value) => handleChange("frequency", value), options: FREQUENCY_OPTIONS.map((opt) => ({
32
+ label: t(`frequency${opt.value.replace(/-/g, "")}`),
33
+ value: opt.value,
34
+ })), placeholder: t("formFrequencyPlaceholder"), searchPlaceholder: t("formSearchFrequencyPlaceholder"), value: frequency || "" }), _jsx(EnhancedCombobox, { emptyText: t("formNoClassEmpty"), id: "classId", info: t("formClassInfo"), label: t("formClassLabel"), onValueChange: (value) => handleChange("classId", value || null), options: classOptions, placeholder: t("formClassPlaceholder"), searchPlaceholder: t("formSearchClassPlaceholder"), value: classId || "" }), _jsx(EnhancedTextarea, { error: errors.description, id: "description", info: t("formDescriptionInfo"), label: t("formDescriptionLabel"), onChange: (e) => handleChange("description", e.target.value), placeholder: t("formDescriptionPlaceholder"), rows: 3, value: description || "" })] }), _jsx(EnhancedCheckbox, { defaultChecked: enabled, label: t("formActiveFeeStructureLabel"), onCheckedChange: (checked) => handleChange("enabled", checked) })] }));
31
35
  };
@@ -9,6 +9,7 @@ export declare const feeStructureFormValidation: z.ZodObject<{
9
9
  name: z.ZodString;
10
10
  feeType: z.ZodEnum<typeof FEE_TYPE>;
11
11
  amount: z.ZodNumber;
12
+ classId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
13
  frequency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
14
  description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
15
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -9,6 +9,7 @@ export const feeStructureFormValidation = z.object({
9
9
  name: z.string().min(1, "Name is required"),
10
10
  feeType: z.nativeEnum(FEE_TYPE, { error: "Fee type is required" }),
11
11
  amount: z.number().positive("Amount must be positive"),
12
+ classId: z.string().optional().nullable(),
12
13
  frequency: z.string().optional().nullable(),
13
14
  description: z.string().optional().nullable(),
14
15
  enabled: z.boolean().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.94",
3
+ "version": "0.1.95",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",