@appcorp/fusion-storybook 0.1.90 → 0.1.93

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.
@@ -66,12 +66,12 @@ const createAttendanceConfig = ({ cancelLabel, dispatch, drawerTitle, labelActio
66
66
  moduleName: "attendance",
67
67
  tableColumns: [
68
68
  { label: labelId, width: "5%" },
69
- { label: labelStudent, width: "15%" },
70
- { label: labelDate, width: "15%" },
69
+ { label: labelStudent, width: "20%" },
70
+ { label: labelDate, width: "20%" },
71
71
  { label: labelStatus, width: "10%" },
72
72
  { label: labelRemarks, width: "20%" },
73
- { label: labelEnabled, width: "15%" },
74
- { label: labelActions, width: "20%" },
73
+ { label: labelEnabled, width: "20%" },
74
+ { label: labelActions, width: "5%" },
75
75
  ],
76
76
  cancelLabel,
77
77
  drawerTitle,
@@ -33,8 +33,11 @@ export declare const COURSE_ACTION_TYPES: {
33
33
  id: string;
34
34
  schoolId: string;
35
35
  sectionId: string;
36
+ sectionLabel: string;
36
37
  subjectId: string;
38
+ subjectLabel: string;
37
39
  teacherId: string;
40
+ teacherLabel: string;
38
41
  }>, initialCourseState: {
39
42
  items: CourseBE[];
40
43
  count: number;
@@ -50,8 +53,11 @@ export declare const COURSE_ACTION_TYPES: {
50
53
  id: string;
51
54
  schoolId: string;
52
55
  sectionId: string;
56
+ sectionLabel: string;
53
57
  subjectId: string;
58
+ subjectLabel: string;
54
59
  teacherId: string;
60
+ teacherLabel: string;
55
61
  }, CourseProvider: import("react").FC<{
56
62
  children: React.ReactNode;
57
63
  }>, courseReducer: (state: {
@@ -69,8 +75,11 @@ export declare const COURSE_ACTION_TYPES: {
69
75
  id: string;
70
76
  schoolId: string;
71
77
  sectionId: string;
78
+ sectionLabel: string;
72
79
  subjectId: string;
80
+ subjectLabel: string;
73
81
  teacherId: string;
82
+ teacherLabel: string;
74
83
  }, action: any) => {
75
84
  items: CourseBE[];
76
85
  count: number;
@@ -86,8 +95,11 @@ export declare const COURSE_ACTION_TYPES: {
86
95
  id: string;
87
96
  schoolId: string;
88
97
  sectionId: string;
98
+ sectionLabel: string;
89
99
  subjectId: string;
100
+ subjectLabel: string;
90
101
  teacherId: string;
102
+ teacherLabel: string;
91
103
  }, useCourseContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContext<{
92
104
  items: CourseBE[];
93
105
  count: number;
@@ -103,8 +115,11 @@ export declare const COURSE_ACTION_TYPES: {
103
115
  id: string;
104
116
  schoolId: string;
105
117
  sectionId: string;
118
+ sectionLabel: string;
106
119
  subjectId: string;
120
+ subjectLabel: string;
107
121
  teacherId: string;
122
+ teacherLabel: string;
108
123
  }>;
109
124
  export declare const useCourseModule: () => {
110
125
  applyFilters: () => void;
@@ -149,8 +164,11 @@ export declare const useCourseModule: () => {
149
164
  id: string;
150
165
  schoolId: string;
151
166
  sectionId: string;
167
+ sectionLabel: string;
152
168
  subjectId: string;
169
+ subjectLabel: string;
153
170
  teacherId: string;
171
+ teacherLabel: string;
154
172
  };
155
173
  dispatch: React.Dispatch<any>;
156
174
  };
@@ -61,8 +61,11 @@ const courseConfig = {
61
61
  id: "",
62
62
  schoolId: "",
63
63
  sectionId: "",
64
+ sectionLabel: "",
64
65
  subjectId: "",
66
+ subjectLabel: "",
65
67
  teacherId: "",
68
+ teacherLabel: "",
66
69
  },
67
70
  };
68
71
  // ============================================================================
@@ -169,7 +172,7 @@ export const useCourseModule = () => {
169
172
  }
170
173
  }, [resetFormAndCloseDrawer, showToast, t]);
171
174
  const byIdCallback = useCallback(({ data, error }) => {
172
- var _a;
175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
173
176
  if (error) {
174
177
  showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
175
178
  return;
@@ -196,14 +199,39 @@ export const useCourseModule = () => {
196
199
  type: COURSE_ACTION_TYPES.SET_INPUT_FIELD,
197
200
  payload: { key: "sectionId", value: course.sectionId },
198
201
  });
202
+ dispatch({
203
+ type: COURSE_ACTION_TYPES.SET_INPUT_FIELD,
204
+ payload: {
205
+ key: "sectionLabel",
206
+ value: ((_c = (_b = course.section) === null || _b === void 0 ? void 0 : _b.class) === null || _c === void 0 ? void 0 : _c.code) && ((_d = course.section) === null || _d === void 0 ? void 0 : _d.name)
207
+ ? `${course.section.class.code}-${course.section.name}`
208
+ : ((_e = course.section) === null || _e === void 0 ? void 0 : _e.name) || course.sectionId,
209
+ },
210
+ });
199
211
  dispatch({
200
212
  type: COURSE_ACTION_TYPES.SET_INPUT_FIELD,
201
213
  payload: { key: "subjectId", value: course.subjectId },
202
214
  });
215
+ dispatch({
216
+ type: COURSE_ACTION_TYPES.SET_INPUT_FIELD,
217
+ payload: {
218
+ key: "subjectLabel",
219
+ value: ((_f = course.subject) === null || _f === void 0 ? void 0 : _f.name) || course.subjectId,
220
+ },
221
+ });
203
222
  dispatch({
204
223
  type: COURSE_ACTION_TYPES.SET_INPUT_FIELD,
205
224
  payload: { key: "teacherId", value: course.teacherId },
206
225
  });
226
+ dispatch({
227
+ type: COURSE_ACTION_TYPES.SET_INPUT_FIELD,
228
+ payload: {
229
+ key: "teacherLabel",
230
+ value: `${((_g = course.teacher) === null || _g === void 0 ? void 0 : _g.firstName) || ""} ${((_h = course.teacher) === null || _h === void 0 ? void 0 : _h.lastName) || ""}`.trim() ||
231
+ ((_j = course.teacher) === null || _j === void 0 ? void 0 : _j.teacherCode) ||
232
+ course.teacherId,
233
+ },
234
+ });
207
235
  dispatch({
208
236
  type: COURSE_ACTION_TYPES.SET_FORM_DATA,
209
237
  payload: { form: { filterEnabled: undefined } },
@@ -25,7 +25,7 @@ export const CourseForm = () => {
25
25
  const { state, handleChange } = useCourseModule();
26
26
  const workspace = getCachedWorkspaceSync();
27
27
  const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
28
- const { code, enabled, errors, sectionId, subjectId, teacherId } = state;
28
+ const { code, enabled, errors, sectionId, sectionLabel, subjectId, subjectLabel, teacherId, teacherLabel, } = state;
29
29
  const cachedSections = getCachedSectionsSync();
30
30
  const cachedSubjects = getCachedSubjectsSync();
31
31
  const cachedTeachers = getCachedTeachersSync();
@@ -91,8 +91,15 @@ export const CourseForm = () => {
91
91
  value: selectedSection.id,
92
92
  },
93
93
  ]
94
- : [];
95
- }, [cachedSections.items, sectionId]);
94
+ : sectionId && sectionLabel
95
+ ? [
96
+ {
97
+ label: sectionLabel,
98
+ value: sectionId,
99
+ },
100
+ ]
101
+ : [];
102
+ }, [cachedSections.items, sectionId, sectionLabel]);
96
103
  const selectedSubjectOption = useMemo(() => {
97
104
  const selectedSubject = cachedSubjects.items.find((subject) => subject.id === subjectId);
98
105
  return selectedSubject
@@ -102,8 +109,15 @@ export const CourseForm = () => {
102
109
  value: selectedSubject.id,
103
110
  },
104
111
  ]
105
- : [];
106
- }, [cachedSubjects.items, subjectId]);
112
+ : subjectId && subjectLabel
113
+ ? [
114
+ {
115
+ label: subjectLabel,
116
+ value: subjectId,
117
+ },
118
+ ]
119
+ : [];
120
+ }, [cachedSubjects.items, subjectId, subjectLabel]);
107
121
  const selectedTeacherOption = useMemo(() => {
108
122
  const selectedTeacher = cachedTeachers.items.find((teacher) => teacher.id === teacherId);
109
123
  return selectedTeacher
@@ -115,8 +129,15 @@ export const CourseForm = () => {
115
129
  value: selectedTeacher.id,
116
130
  },
117
131
  ]
118
- : [];
119
- }, [cachedTeachers.items, teacherId]);
132
+ : teacherId && teacherLabel
133
+ ? [
134
+ {
135
+ label: teacherLabel,
136
+ value: teacherId,
137
+ },
138
+ ]
139
+ : [];
140
+ }, [cachedTeachers.items, teacherId, teacherLabel]);
120
141
  const displayedSectionOptions = useMemo(() => {
121
142
  const sourceOptions = trimmedSectionSearchQuery
122
143
  ? remoteSectionOptions
@@ -271,6 +292,17 @@ export const CourseForm = () => {
271
292
  isActive = false;
272
293
  };
273
294
  }, [schoolId, trimmedTeacherSearchQuery]);
274
- console.log("CourseForm Render", state, teacherId, displayedTeacherOptions);
275
- return (_jsxs("div", { className: "space-y-4", children: [_jsx(EnhancedInput, { error: errors.code, id: "code", info: t("courseCodeInfo"), label: t("courseCode"), onChange: (e) => handleChange("code", e.target.value), placeholder: t("courseCodePlaceholder"), required: true, value: code }), _jsx(EnhancedCombobox, { emptyText: t("noSectionFound"), error: errors.sectionId, id: "sectionId", info: t("sectionInfo"), label: t("section"), loading: sectionOptionsLoading && Boolean(trimmedSectionSearchQuery), onValueChange: (value) => handleChange("sectionId", value), onSearchChange: setSectionSearchQuery, options: displayedSectionOptions, placeholder: t("sectionPlaceholder"), required: true, searchPlaceholder: t("searchSections"), value: sectionId }), _jsx(EnhancedCombobox, { emptyText: t("noSubjectFound"), error: errors.subjectId, id: "subjectId", info: t("subjectInfo"), label: t("subject"), loading: subjectOptionsLoading && Boolean(trimmedSubjectSearchQuery), onValueChange: (value) => handleChange("subjectId", value), onSearchChange: setSubjectSearchQuery, options: displayedSubjectOptions, placeholder: t("subjectPlaceholder"), required: true, searchPlaceholder: t("searchSubjects"), value: subjectId }), _jsx(EnhancedCombobox, { emptyText: t("noTeacherFound"), error: errors.teacherId, id: "teacherId", info: t("teacherInfo"), label: t("teacher"), loading: teacherOptionsLoading && Boolean(trimmedTeacherSearchQuery), onValueChange: (value) => handleChange("teacherId", value), onSearchChange: setTeacherSearchQuery, options: displayedTeacherOptions, placeholder: t("teacherPlaceholder"), required: true, searchPlaceholder: t("searchTeachers"), value: teacherId }), _jsx(EnhancedCheckbox, { label: t("activeCourse"), defaultChecked: enabled, onCheckedChange: (checked) => handleChange("enabled", checked), info: t("toggleToEnableOrDisableCourse") })] }));
295
+ return (_jsxs("div", { className: "space-y-4", children: [_jsx(EnhancedInput, { error: errors.code, id: "code", info: t("courseCodeInfo"), label: t("courseCode"), onChange: (e) => handleChange("code", e.target.value), placeholder: t("courseCodePlaceholder"), required: true, value: code }), _jsx(EnhancedCombobox, { emptyText: t("noSectionFound"), error: errors.sectionId, id: "sectionId", info: t("sectionInfo"), label: t("section"), loading: sectionOptionsLoading && Boolean(trimmedSectionSearchQuery), onValueChange: (value) => {
296
+ var _a;
297
+ handleChange("sectionId", value);
298
+ handleChange("sectionLabel", ((_a = displayedSectionOptions.find((option) => option.value === value)) === null || _a === void 0 ? void 0 : _a.label) || "");
299
+ }, onSearchChange: setSectionSearchQuery, options: displayedSectionOptions, placeholder: t("sectionPlaceholder"), required: true, searchPlaceholder: t("searchSections"), value: sectionId }), _jsx(EnhancedCombobox, { emptyText: t("noSubjectFound"), error: errors.subjectId, id: "subjectId", info: t("subjectInfo"), label: t("subject"), loading: subjectOptionsLoading && Boolean(trimmedSubjectSearchQuery), onValueChange: (value) => {
300
+ var _a;
301
+ handleChange("subjectId", value);
302
+ handleChange("subjectLabel", ((_a = displayedSubjectOptions.find((option) => option.value === value)) === null || _a === void 0 ? void 0 : _a.label) || "");
303
+ }, onSearchChange: setSubjectSearchQuery, options: displayedSubjectOptions, placeholder: t("subjectPlaceholder"), required: true, searchPlaceholder: t("searchSubjects"), value: subjectId }), _jsx(EnhancedCombobox, { emptyText: t("noTeacherFound"), error: errors.teacherId, id: "teacherId", info: t("teacherInfo"), label: t("teacher"), loading: teacherOptionsLoading && Boolean(trimmedTeacherSearchQuery), onValueChange: (value) => {
304
+ var _a;
305
+ handleChange("teacherId", value);
306
+ handleChange("teacherLabel", ((_a = displayedTeacherOptions.find((option) => option.value === value)) === null || _a === void 0 ? void 0 : _a.label) || "");
307
+ }, onSearchChange: setTeacherSearchQuery, options: displayedTeacherOptions, placeholder: t("teacherPlaceholder"), required: true, searchPlaceholder: t("searchTeachers"), value: teacherId }), _jsx(EnhancedCheckbox, { label: t("activeCourse"), defaultChecked: enabled, onCheckedChange: (checked) => handleChange("enabled", checked), info: t("toggleToEnableOrDisableCourse") })] }));
276
308
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.90",
3
+ "version": "0.1.93",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@appcorp/app-corp-vista": "^1.0.0",
40
- "@appcorp/shadcn": "^1.1.80",
40
+ "@appcorp/shadcn": "^1.1.83",
41
41
  "@chromatic-com/storybook": "^5.1.2",
42
42
  "@commitlint/cli": "^20.5.0",
43
43
  "@commitlint/config-conventional": "^20.5.0",