@appcorp/fusion-storybook 0.1.73 → 0.1.74
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
|
|
1
2
|
import { PermissionBE, RoleBE, RolePermissionBE } from "../../type";
|
|
2
3
|
export declare const RBAC_DRAWER: {
|
|
3
4
|
readonly FILTER_DRAWER: string;
|
|
@@ -120,8 +121,8 @@ export declare const useRbacModule: () => {
|
|
|
120
121
|
deleteLoading: boolean;
|
|
121
122
|
handleChange: (key: string, value: string | number | boolean | undefined) => void;
|
|
122
123
|
handleCreate: () => void;
|
|
123
|
-
handleDelete: (row?:
|
|
124
|
-
handleEdit: (row?:
|
|
124
|
+
handleDelete: (row?: TableRow) => void;
|
|
125
|
+
handleEdit: (row?: TableRow) => Promise<void>;
|
|
125
126
|
handleFilters: () => void;
|
|
126
127
|
handleMoreActions: () => void;
|
|
127
128
|
handleNextClick: () => void;
|
|
@@ -131,7 +132,7 @@ export declare const useRbacModule: () => {
|
|
|
131
132
|
handleSearch: (query: string) => void;
|
|
132
133
|
handleSubmit: () => void;
|
|
133
134
|
handleTogglePermission: (permissionId: string) => Promise<void>;
|
|
134
|
-
handleView: (row?:
|
|
135
|
+
handleView: (row?: TableRow) => void;
|
|
135
136
|
headerActions: {
|
|
136
137
|
enabled: boolean;
|
|
137
138
|
handleOnClick: () => void;
|
|
@@ -141,12 +142,7 @@ export declare const useRbacModule: () => {
|
|
|
141
142
|
listError: Error | undefined;
|
|
142
143
|
listFetchNow: (url?: string, config?: import("@react-pakistan/util-functions/hooks/use-fetch").FetchConfig) => void;
|
|
143
144
|
listLoading: boolean;
|
|
144
|
-
rowActions:
|
|
145
|
-
enabled: boolean;
|
|
146
|
-
handleOnClick: (row?: unknown) => void;
|
|
147
|
-
label: string;
|
|
148
|
-
order: number;
|
|
149
|
-
}[];
|
|
145
|
+
rowActions: RowAction[];
|
|
150
146
|
updateLoading: boolean;
|
|
151
147
|
state: {
|
|
152
148
|
description: string;
|
|
@@ -254,31 +254,27 @@ export const useRbacModule = () => {
|
|
|
254
254
|
}, [dispatch]);
|
|
255
255
|
// row actions
|
|
256
256
|
const handleView = useCallback((row) => {
|
|
257
|
-
|
|
258
|
-
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: record === null || record === void 0 ? void 0 : record.id } });
|
|
257
|
+
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
|
|
259
258
|
dispatch({
|
|
260
259
|
type: RBAC_ACTION_TYPES.SET_DRAWER,
|
|
261
260
|
payload: { drawer: RBAC_DRAWER.VIEW_DRAWER },
|
|
262
261
|
});
|
|
263
262
|
}, [byIdFetchNow, dispatch]);
|
|
264
|
-
const handleEdit = useCallback(
|
|
265
|
-
|
|
266
|
-
async (row) => {
|
|
267
|
-
const record = row;
|
|
268
|
-
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: record === null || record === void 0 ? void 0 : record.id } });
|
|
263
|
+
const handleEdit = useCallback(async (row) => {
|
|
264
|
+
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
|
|
269
265
|
// loadAvailablePermissions is declared below in 1.4.7
|
|
270
|
-
//
|
|
271
|
-
await loadAvailablePermissions();
|
|
266
|
+
// await loadAvailablePermissions();
|
|
272
267
|
dispatch({
|
|
273
268
|
type: RBAC_ACTION_TYPES.SET_DRAWER,
|
|
274
269
|
payload: { drawer: RBAC_DRAWER.FORM_DRAWER },
|
|
275
270
|
});
|
|
276
271
|
}, [byIdFetchNow, dispatch]);
|
|
277
272
|
const handleDelete = useCallback((row) => {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
273
|
+
if (!confirm(t("messagesDeleteConfirmation")))
|
|
274
|
+
return;
|
|
275
|
+
deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
|
|
276
|
+
body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id }),
|
|
277
|
+
});
|
|
282
278
|
}, [deleteFetchNow, t]);
|
|
283
279
|
// header actions
|
|
284
280
|
const handleCreate = useCallback(() => {
|
|
@@ -360,28 +356,29 @@ export const useRbacModule = () => {
|
|
|
360
356
|
},
|
|
361
357
|
});
|
|
362
358
|
}, [dispatch, showToast, t, updateFetchNow, updateParams]);
|
|
363
|
-
const loadAvailablePermissions = useCallback(async () => {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
359
|
+
// const loadAvailablePermissions = useCallback(async () => {
|
|
360
|
+
// try {
|
|
361
|
+
// const res = await fetch(
|
|
362
|
+
// `${RBAC_API_ROUTES.PERMISSIONS_LIST}?pageLimit=1000`,
|
|
363
|
+
// {
|
|
364
|
+
// headers: {
|
|
365
|
+
// "Content-Type": "application/json",
|
|
366
|
+
// "x-api-token": process.env.NEXT_PUBLIC_API_KEY!,
|
|
367
|
+
// },
|
|
368
|
+
// }
|
|
369
|
+
// );
|
|
370
|
+
// if (!res.ok) throw new Error("Failed to load permissions");
|
|
371
|
+
// const data = (await res.json()) as { items: PermissionBE[] };
|
|
372
|
+
// // Use SET_INPUT_FIELD — the generic reducer handles it via state[key] = value.
|
|
373
|
+
// // Custom action types hit the reducer's default case and are silently ignored.
|
|
374
|
+
// dispatch({
|
|
375
|
+
// type: RBAC_ACTION_TYPES.SET_INPUT_FIELD,
|
|
376
|
+
// payload: { key: "availablePermissions", value: data.items },
|
|
377
|
+
// });
|
|
378
|
+
// } catch {
|
|
379
|
+
// showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
380
|
+
// }
|
|
381
|
+
// }, [dispatch, showToast, t]);
|
|
385
382
|
const handleTogglePermission = useCallback(async (permissionId) => {
|
|
386
383
|
const existing = state.rolePermissions.find((rp) => rp.permissionId === permissionId);
|
|
387
384
|
dispatch({
|
|
@@ -428,7 +425,7 @@ export const useRbacModule = () => {
|
|
|
428
425
|
// ============================================================================
|
|
429
426
|
const headerActions = useMemo(() => [
|
|
430
427
|
{
|
|
431
|
-
enabled:
|
|
428
|
+
enabled: false,
|
|
432
429
|
handleOnClick: handleMoreActions,
|
|
433
430
|
label: t("actionsButtonMoreActions"),
|
|
434
431
|
order: 0,
|
|
@@ -91,9 +91,6 @@ const createRbacConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, draw
|
|
|
91
91
|
// STABLE PAGE COMPONENT (created once, outside render)
|
|
92
92
|
// ============================================================================
|
|
93
93
|
const GenericRbacPage = createGenericModulePage();
|
|
94
|
-
// ============================================================================
|
|
95
|
-
// INNER PAGE (requires RbacProvider context)
|
|
96
|
-
// ============================================================================
|
|
97
94
|
const RbacPageInner = (props) => {
|
|
98
95
|
const context = useRbacModule();
|
|
99
96
|
// Memoize config creation — destructure props to avoid object reference changes
|
|
@@ -133,4 +130,7 @@ const RbacPageInner = (props) => {
|
|
|
133
130
|
}
|
|
134
131
|
return (_jsx("div", { className: "p-4", children: _jsx(GenericRbacPage, { context: context, overrideConfig: rbacConfig, tableBodyCols: tableBodyCols }) }));
|
|
135
132
|
};
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// PAGE EXPORTS
|
|
135
|
+
// ============================================================================
|
|
136
136
|
export const RbacPage = (props) => (_jsx(RbacProvider, { children: _jsx(RbacPageInner, Object.assign({}, props)) }));
|