@appcorp/fusion-storybook 0.5.4 → 0.5.6
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.
- package/base-modules/user/context/use-user-module.d.ts +0 -1
- package/base-modules/user/context/use-user-module.js +57 -37
- package/base-modules/user/context.d.ts +0 -1
- package/base-modules/user/context.js +0 -1
- package/base-modules/user/form.js +12 -28
- package/base-modules/user/page.d.ts +5 -0
- package/base-modules/user/page.js +16 -10
- package/base-modules/user/validate.d.ts +10 -0
- package/base-modules/user/validate.js +32 -2
- package/base-modules/user/view.js +3 -3
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/base-modules/user/drawer.d.ts +0 -1
- package/base-modules/user/drawer.js +0 -25
- package/base-modules/user/more-actions.d.ts +0 -1
- package/base-modules/user/more-actions.js +0 -51
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Drawer: () => import("react").JSX.Element;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { EnhancedDrawerHeader } from "@appcorp/shadcn/components/enhanced-drawer-header";
|
|
4
|
-
import { EnhancedDrawerFooter, DRAWER_FOOTER_COMPONENT_TYPE, } from "@appcorp/shadcn/components/enhanced-drawer-footer";
|
|
5
|
-
import { useUserModule, USER_DRAWER } from "./context";
|
|
6
|
-
import { UserForm } from "./form";
|
|
7
|
-
import { UserView } from "./view";
|
|
8
|
-
import { UserFilter } from "./filter";
|
|
9
|
-
import { DrawerGeneric } from "@appcorp/shadcn/components/drawer-generic";
|
|
10
|
-
import { UserMoreActions } from "./more-actions";
|
|
11
|
-
export const Drawer = () => {
|
|
12
|
-
const { applyFilters, clearFilters,
|
|
13
|
-
// closeDrawer,
|
|
14
|
-
// drawer,
|
|
15
|
-
handleSubmit,
|
|
16
|
-
// errors,
|
|
17
|
-
// disableSaveButton,
|
|
18
|
-
updateLoading, state, } = useUserModule();
|
|
19
|
-
const { drawer, errors, disableSaveButton } = state;
|
|
20
|
-
const isMoreActionDrawer = drawer === USER_DRAWER.MORE_ACTIONS_DRAWER;
|
|
21
|
-
const isFilterDrawer = drawer === USER_DRAWER.FILTER_DRAWER;
|
|
22
|
-
const isFormDrawer = drawer === USER_DRAWER.FORM_DRAWER;
|
|
23
|
-
const isViewDrawer = drawer === USER_DRAWER.VIEW_DRAWER;
|
|
24
|
-
return (_jsx(_Fragment, { children: _jsx(DrawerGeneric, { moreActionsDrawer: isMoreActionDrawer ? _jsx(UserMoreActions, {}) : null, filterDrawer: isFilterDrawer ? _jsx(UserFilter, {}) : null, formDrawer: isFormDrawer ? _jsx(UserForm, {}) : null, viewDrawer: isViewDrawer ? _jsx(UserView, {}) : null, moreActionsDrawerHeader: isMoreActionDrawer ? (_jsx(EnhancedDrawerHeader, { title: "More Actions", description: "Additional actions for users" })) : null, filterDrawerHeader: isFilterDrawer ? (_jsx(EnhancedDrawerHeader, { title: "Filter Users", description: "Apply filters to narrow down your search" })) : null, formDrawerHeader: isFormDrawer ? (_jsx(EnhancedDrawerHeader, { title: "User Information", description: "Fill in the user details below" })) : null, viewDrawerHeader: isViewDrawer ? (_jsx(EnhancedDrawerHeader, { title: "View User", description: "View the details of the user" })) : null, moreActionsDrawerFooter: isMoreActionDrawer ? (_jsx(EnhancedDrawerFooter, { applyFilters: applyFilters, clearFilters: clearFilters, closeDrawer: () => void 0, disableSaveButton: disableSaveButton, drawerType: DRAWER_FOOTER_COMPONENT_TYPE.MORE_ACTIONS_DRAWER, errors: errors, handleSubmit: handleSubmit, updateLoading: updateLoading })) : null, filterDrawerFooter: isFilterDrawer ? (_jsx(EnhancedDrawerFooter, { applyFilters: applyFilters, clearFilters: clearFilters, closeDrawer: () => void 0, disableSaveButton: disableSaveButton, drawerType: DRAWER_FOOTER_COMPONENT_TYPE.FILTER_DRAWER, errors: errors, handleSubmit: handleSubmit, updateLoading: updateLoading })) : null, formDrawerFooter: isFormDrawer ? (_jsx(EnhancedDrawerFooter, { applyFilters: applyFilters, clearFilters: clearFilters, closeDrawer: () => void 0, disableSaveButton: disableSaveButton, drawerType: DRAWER_FOOTER_COMPONENT_TYPE.FORM_DRAWER, errors: errors, handleSubmit: handleSubmit, updateLoading: updateLoading })) : null, viewDrawerFooter: isViewDrawer ? (_jsx(EnhancedDrawerFooter, { applyFilters: applyFilters, clearFilters: clearFilters, closeDrawer: () => void 0, disableSaveButton: disableSaveButton, drawerType: DRAWER_FOOTER_COMPONENT_TYPE.VIEW_DRAWER, errors: errors, handleSubmit: handleSubmit, updateLoading: updateLoading })) : null, onOpenChange: (open) => !open && (() => void 0)(), open: isMoreActionDrawer || isFormDrawer || isFilterDrawer || isViewDrawer }) }));
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const UserMoreActions: () => import("react").JSX.Element;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
|
-
import { downloadFromUrl } from "@react-pakistan/util-functions/general/download-from-url";
|
|
5
|
-
import { API_METHODS } from "@react-pakistan/util-functions/constants/api-methods";
|
|
6
|
-
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
7
|
-
import converter from "json-2-csv";
|
|
8
|
-
import { Timeline } from "../../components/timeline";
|
|
9
|
-
export const UserMoreActions = () => {
|
|
10
|
-
const t = useTranslations("user");
|
|
11
|
-
const workspace = getCachedWorkspaceSync();
|
|
12
|
-
const handleGetAllRecords = async (schoolId) => {
|
|
13
|
-
const response = await fetch(`/api/user?pageLimit=1000¤tPage=1&schoolId=${schoolId}`, { method: API_METHODS.GET });
|
|
14
|
-
const result = await response.json();
|
|
15
|
-
const csv = await converter.json2csv(result.items || [], {});
|
|
16
|
-
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
17
|
-
await downloadFromUrl(blob, "user.csv");
|
|
18
|
-
};
|
|
19
|
-
const create = [
|
|
20
|
-
{
|
|
21
|
-
id: "1",
|
|
22
|
-
title: t("moreActionsDownloadEmptyCsvTemplate"),
|
|
23
|
-
handleOnClick: async () => {
|
|
24
|
-
await downloadFromUrl("https://nwolvgylwmjuqxsngjxt.supabase.co/storage/v1/object/public/public-blob/common-assets/user.csv", "user-template.csv");
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{ id: "2", title: t("moreActionsAddYourDataToTheCsv") },
|
|
28
|
-
{
|
|
29
|
-
id: "3",
|
|
30
|
-
title: t("moreActionsUploadTheCompletedCsvToTheSystem"),
|
|
31
|
-
handleOnClick: () => { },
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
const update = [
|
|
35
|
-
{
|
|
36
|
-
id: "1",
|
|
37
|
-
title: t("moreActionsDownloadPopulatedCsvTemplate"),
|
|
38
|
-
handleOnClick: async () => {
|
|
39
|
-
var _a;
|
|
40
|
-
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "");
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{ id: "2", title: t("moreActionsUpdateYourDataToTheCsv") },
|
|
44
|
-
{
|
|
45
|
-
id: "3",
|
|
46
|
-
title: t("moreActionsUploadTheCompletedCsvToTheSystem"),
|
|
47
|
-
handleOnClick: () => { },
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Timeline, { events: create, heading: t("moreActionsBulkCreate") }), _jsx(Timeline, { events: update, heading: t("moreActionsBulkUpdate") })] }));
|
|
51
|
-
};
|