@appcorp/fusion-storybook 0.1.7 → 0.1.9

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.
@@ -11,6 +11,22 @@
11
11
  */
12
12
  import { FC } from "react";
13
13
  import { USER_ROLE } from "../../type";
14
- export declare const AdmissionPage: FC<{
14
+ interface Props {
15
+ cancelLabel: string;
16
+ drawerTitle: string;
17
+ labelActions: string;
18
+ labelClass: string;
19
+ labelEnabled: string;
20
+ labelFirstName: string;
21
+ labelId: string;
22
+ labelLastName: string;
23
+ labelRegistrationCode: string;
24
+ labelStatus: string;
25
+ saveLabel: string;
26
+ searchPlaceholder: string;
27
+ tableDescription: string;
28
+ tableTitle: string;
15
29
  userRole: USER_ROLE;
16
- }>;
30
+ }
31
+ export declare const AdmissionPage: FC<Props>;
32
+ export {};
@@ -20,7 +20,6 @@ import { AdmissionForm } from "./form";
20
20
  import { AdmissionView } from "./view";
21
21
  import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
22
22
  import { RbacNoAccess } from "../../components/rbac-no-access";
23
- import { useTranslations } from "next-intl";
24
23
  import { AdmissionMoreActions } from "./more-actions";
25
24
  // ============================================================================
26
25
  // TABLE COLUMN CONFIGURATION (static — no runtime deps)
@@ -41,20 +40,24 @@ const tableBodyCols = [
41
40
  { componentType: COMPONENT_TYPE.BOOLEAN, key: "enabled" },
42
41
  { componentType: COMPONENT_TYPE.ACTIONS },
43
42
  ];
44
- const tableColumns = [
45
- { label: "id", width: "5%" },
46
- { label: "firstName", width: "15%" },
47
- { label: "lastName", width: "15%" },
48
- { label: "registrationCode", width: "20%" },
49
- { label: "class", width: "20%" },
50
- { label: "status", width: "10%" },
51
- { label: "enabled", width: "10%" },
52
- { label: "actions", width: "5%" },
53
- ];
43
+ // const tableColumns = [
44
+ // { label: "id", width: "5%" },
45
+ // { label: "firstName", width: "15%" },
46
+ // { label: "lastName", width: "15%" },
47
+ // { label: "registrationCode", width: "20%" },
48
+ // { label: "class", width: "20%" },
49
+ // { label: "status", width: "10%" },
50
+ // { label: "enabled", width: "10%" },
51
+ // { label: "actions", width: "5%" },
52
+ // ] as const;
54
53
  // ============================================================================
55
54
  // TRANSLATED COLUMNS HELPER
56
55
  // ============================================================================
57
- const getTranslatedColumns = (t) => tableColumns.map((col) => (Object.assign(Object.assign({}, col), { label: t(col.label) })));
56
+ // const getTranslatedColumns = (t: (key: string) => string) =>
57
+ // tableColumns.map((col) => ({
58
+ // ...col,
59
+ // label: t(col.label),
60
+ // }));
58
61
  // ============================================================================
59
62
  // COMPONENT FACTORY (creates JSX elements when config is created, not during render)
60
63
  // ============================================================================
@@ -64,23 +67,29 @@ const createComponentInstances = () => ({
64
67
  moreActions: _jsx(AdmissionMoreActions, {}),
65
68
  view: _jsx(AdmissionView, {}),
66
69
  });
67
- // ============================================================================
68
- // CONFIG CREATION HELPER
69
- // ============================================================================
70
- const createAdmissionConfig = (t, drawer, dispatch) => {
70
+ const createAdmissionConfig = ({ cancelLabel, dispatch, drawer, drawerTitle, labelActions, labelClass, labelEnabled, labelFirstName, labelId, labelLastName, labelRegistrationCode, labelStatus, saveLabel, searchPlaceholder, tableDescription, tableTitle, }) => {
71
71
  const components = createComponentInstances();
72
72
  return {
73
73
  moduleName: "admission",
74
- tableColumns: getTranslatedColumns(t),
75
- cancelLabel: t("cancel"),
76
- drawerTitle: t("admission"),
74
+ tableColumns: [
75
+ { label: labelId, width: "5%" },
76
+ { label: labelFirstName, width: "15%" },
77
+ { label: labelLastName, width: "15%" },
78
+ { label: labelRegistrationCode, width: "20%" },
79
+ { label: labelClass, width: "20%" },
80
+ { label: labelStatus, width: "10%" },
81
+ { label: labelEnabled, width: "10%" },
82
+ { label: labelActions, width: "5%" },
83
+ ],
84
+ cancelLabel,
85
+ drawerTitle,
77
86
  filterContent: components.filter,
78
87
  formContent: components.form,
79
88
  moreActionsContent: components.moreActions,
80
- saveLabel: t("save"),
81
- searchPlaceholder: t("searchAdmissions"),
82
- tableDescription: t("manageAdmissionsInTheSystem"),
83
- tableTitle: t("admission"),
89
+ saveLabel,
90
+ searchPlaceholder,
91
+ tableDescription,
92
+ tableTitle,
84
93
  viewContent: components.view,
85
94
  size: drawer === ADMISSION_DRAWER.FORM_DRAWER ? "full" : "small",
86
95
  onClearFilters: () => {
@@ -92,37 +101,36 @@ const createAdmissionConfig = (t, drawer, dispatch) => {
92
101
  // STABLE PAGE COMPONENT (created once, outside render)
93
102
  // ============================================================================
94
103
  const GenericAdmissionPage = createGenericModulePage({
95
- moduleName: "admission",
96
- tableColumns: [],
97
104
  cancelLabel: "",
98
105
  drawerTitle: "",
99
106
  filterContent: _jsx(AdmissionFilter, {}),
100
107
  formContent: _jsx(AdmissionForm, {}),
108
+ moduleName: "admission",
101
109
  moreActionsContent: _jsx(AdmissionMoreActions, {}),
110
+ onClearFilters: () => { },
102
111
  saveLabel: "",
103
112
  searchPlaceholder: "",
113
+ size: "small",
114
+ tableColumns: [],
104
115
  tableDescription: "",
105
116
  tableTitle: "",
106
117
  viewContent: _jsx(AdmissionView, {}),
107
- size: "small",
108
- onClearFilters: () => { },
109
118
  });
110
119
  // ============================================================================
111
120
  // INNER PAGE (requires AdmissionProvider context)
112
121
  // ============================================================================
113
- const AdmissionPageInner = ({ userRole }) => {
114
- const t = useTranslations("admission");
122
+ const AdmissionPageInner = (props) => {
115
123
  const context = useAdmissionModule();
124
+ // Memoize config creation
125
+ const admissionConfig = useMemo(() => createAdmissionConfig(Object.assign({ dispatch: context.dispatch, drawer: context.state.drawer }, props)), [context.dispatch, context.state.drawer, props]);
116
126
  // Memoize permission check to avoid recalculation on every render
117
127
  const hasPermission = useMemo(() => resolveRbacPermissions({
118
- userRole,
128
+ userRole: props.userRole,
119
129
  moduleName: "Admission",
120
- }), [userRole]);
121
- // Memoize config creation
122
- const admissionConfig = useMemo(() => createAdmissionConfig(t, context.state.drawer, context.dispatch), [t, context.state.drawer, context.dispatch]);
130
+ }), [props.userRole]);
123
131
  if (!hasPermission) {
124
132
  return _jsx(RbacNoAccess, { moduleName: "Admission" });
125
133
  }
126
134
  return (_jsx("div", { className: "p-4", children: _jsx(GenericAdmissionPage, { config: admissionConfig, context: context, tableBodyCols: tableBodyCols }) }));
127
135
  };
128
- export const AdmissionPage = ({ userRole }) => (_jsx(AdmissionProvider, { children: _jsx(AdmissionPageInner, { userRole: userRole }) }));
136
+ export const AdmissionPage = (props) => (_jsx(AdmissionProvider, { children: _jsx(AdmissionPageInner, Object.assign({}, props)) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",