@appcorp/fusion-storybook 0.2.40 → 0.2.42
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/admission/constants.d.ts +5 -17
- package/base-modules/admission/constants.js +12 -7
- package/base-modules/admission/context/use-admission-module.js +11 -48
- package/base-modules/admission/filter.js +23 -3
- package/base-modules/admission/form.js +49 -19
- package/base-modules/attendance/context.js +3 -37
- package/base-modules/attendance/form.js +26 -10
- package/base-modules/attendance/more-actions.js +34 -25
- package/base-modules/campus/context.js +7 -7
- package/base-modules/class/cache.js +0 -1
- package/base-modules/class/context.js +10 -48
- package/base-modules/class/more-actions.js +0 -2
- package/base-modules/course/context.js +3 -37
- package/base-modules/course/form.js +91 -292
- package/base-modules/discount-code/constants.d.ts +5 -0
- package/base-modules/discount-code/constants.js +5 -0
- package/base-modules/discount-code/context.d.ts +1 -0
- package/base-modules/discount-code/context.js +40 -39
- package/base-modules/discount-code/form.js +21 -15
- package/base-modules/discount-code/more-actions.js +1 -1
- package/base-modules/enrollment/context.js +3 -37
- package/base-modules/enrollment/form.js +38 -11
- package/base-modules/enrollment/more-actions.js +0 -2
- package/base-modules/expense/constants.js +1 -1
- package/base-modules/expense/context.js +5 -32
- package/base-modules/expense/filter.js +50 -3
- package/base-modules/expense/form.js +82 -6
- package/base-modules/family/context.js +7 -38
- package/base-modules/family-member/context.js +7 -39
- package/base-modules/fee-structure/context.js +1 -25
- package/base-modules/fee-structure/form.js +77 -89
- package/base-modules/fee-structure/more-actions.js +0 -2
- package/base-modules/rbac/context.d.ts +1 -0
- package/base-modules/rbac/context.js +23 -32
- package/base-modules/school/context.js +1 -1
- package/base-modules/school/form.js +34 -14
- package/base-modules/section/context.d.ts +1 -0
- package/base-modules/section/context.js +40 -47
- package/base-modules/section/form.js +25 -80
- package/base-modules/section/more-actions.js +0 -2
- package/base-modules/section/view.js +9 -7
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +1 -0
- package/base-modules/student-fee/context/use-student-fee-module.js +48 -32
- package/base-modules/student-fee/context.d.ts +1 -1
- package/base-modules/student-fee/context.js +1 -1
- package/base-modules/student-fee/filter.js +23 -3
- package/base-modules/student-fee/form.js +93 -174
- package/base-modules/student-fee/view.d.ts +7 -1
- package/base-modules/student-fee/view.js +17 -20
- package/base-modules/student-profile/constants.d.ts +0 -6
- package/base-modules/student-profile/constants.js +1 -3
- package/base-modules/student-profile/context/use-student-profile-module.d.ts +1 -0
- package/base-modules/student-profile/context/use-student-profile-module.js +62 -55
- package/base-modules/student-profile/context.d.ts +1 -1
- package/base-modules/student-profile/context.js +1 -1
- package/base-modules/student-profile/filter.js +23 -3
- package/base-modules/student-profile/form.js +35 -3
- package/base-modules/subject/context.d.ts +1 -0
- package/base-modules/subject/context.js +38 -47
- package/base-modules/subject/more-actions.js +0 -2
- package/base-modules/teacher/constants.d.ts +0 -6
- package/base-modules/teacher/constants.js +0 -2
- package/base-modules/teacher/context.d.ts +1 -0
- package/base-modules/teacher/context.js +58 -39
- package/base-modules/teacher/form.js +46 -11
- package/base-modules/teacher/more-actions.js +0 -2
- package/base-modules/user/context/use-user-module.d.ts +1 -0
- package/base-modules/user/context/use-user-module.js +36 -32
- package/base-modules/user/context.js +1 -1
- package/base-modules/user/filter.js +6 -4
- package/base-modules/user/form.js +29 -5
- package/base-modules/user/more-actions.js +9 -7
- package/base-modules/user/view.js +3 -1
- package/base-modules/workspace/form.js +18 -8
- package/base-modules/workspace-user/context.d.ts +2 -1
- package/base-modules/workspace-user/context.js +31 -29
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/base-modules/admission/cache.d.ts +0 -14
- package/base-modules/admission/cache.js +0 -31
- package/base-modules/attendance/cache.d.ts +0 -14
- package/base-modules/attendance/cache.js +0 -31
- package/base-modules/course/cache.d.ts +0 -14
- package/base-modules/course/cache.js +0 -31
- package/base-modules/enrollment/cache.d.ts +0 -14
- package/base-modules/enrollment/cache.js +0 -31
- package/base-modules/expense/cache.d.ts +0 -14
- package/base-modules/expense/cache.js +0 -31
- package/base-modules/family/cache.d.ts +0 -14
- package/base-modules/family/cache.js +0 -31
- package/base-modules/family-member/cache.d.ts +0 -14
- package/base-modules/family-member/cache.js +0 -31
- package/base-modules/rbac/cache.d.ts +0 -27
- package/base-modules/rbac/cache.js +0 -46
- package/base-modules/student-fee/cache.d.ts +0 -15
- package/base-modules/student-fee/cache.js +0 -21
- package/base-modules/workspace-user/cache.d.ts +0 -14
- package/base-modules/workspace-user/cache.js +0 -31
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslations } from "next-intl";
|
|
3
4
|
import { useUserModule } from "./context";
|
|
4
5
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@appcorp/shadcn/components/ui/card";
|
|
5
6
|
import { Badge } from "@appcorp/shadcn/components/ui/badge";
|
|
@@ -19,7 +20,8 @@ const getInitials = (fullName) => {
|
|
|
19
20
|
.slice(0, 2);
|
|
20
21
|
};
|
|
21
22
|
export const UserView = () => {
|
|
23
|
+
const t = useTranslations("user");
|
|
22
24
|
const { state } = useUserModule();
|
|
23
25
|
const { avatar, email, enabled, name, phone } = state;
|
|
24
|
-
return (_jsx("div", { className: "space-y-4", children: _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(User, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: "
|
|
26
|
+
return (_jsx("div", { className: "space-y-4", children: _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(User, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldUserInformation") })] }), _jsx(CardDescription, { children: t("viewUserAccountDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldProfilePicture") }), _jsxs(Avatar, { className: "h-20 w-20", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: name || t("viewFieldName") }), _jsx(AvatarFallback, { className: "text-lg", children: getInitials(name) })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldName") }), _jsx("p", { className: "text-base", children: formatValue(name) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Mail, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldEmailAddress") })] }), _jsx("p", { className: "text-base", children: formatValue(email) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPhoneNumber") })] }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(phone) || formatValue(phone) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStatus") }), _jsxs(Badge, { variant: enabled ? "default" : "destructive", className: "gap-1", children: [enabled ? (_jsx(CheckCircle2, { className: "h-3 w-3" })) : (_jsx(XCircle, { className: "h-3 w-3" })), enabled ? t("badgeActive") : t("badgeInactive")] })] })] }) })] }) }));
|
|
25
27
|
};
|
|
@@ -10,9 +10,9 @@ import { useWorkspaceModule } from "./context";
|
|
|
10
10
|
import { useTranslations } from "next-intl";
|
|
11
11
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
12
12
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
13
|
-
import {
|
|
13
|
+
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
14
14
|
import { Shield, Eye, EyeOff } from "lucide-react";
|
|
15
|
-
import { secretKeys } from "./constants";
|
|
15
|
+
import { secretKeys, WORKSPACE_API_ROUTES } from "./constants";
|
|
16
16
|
const SecretsEditor = ({ secrets, errors, onChange, secretPlaceholder, }) => {
|
|
17
17
|
const [visibleMap, setVisibleMap] = useState(() => Object.fromEntries(secretKeys.map((k) => [k, false])));
|
|
18
18
|
const toggle = (key) => setVisibleMap((s) => (Object.assign(Object.assign({}, s), { [key]: !s[key] })));
|
|
@@ -31,10 +31,20 @@ export const WorkspaceForm = () => {
|
|
|
31
31
|
const handleSecretChange = (key, value) => {
|
|
32
32
|
handleChange("secrets", Object.assign(Object.assign({}, secrets), { [key]: value }));
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const { enhancedComboboxElement: planIdCombo } = useEnhancedCombobox({
|
|
35
|
+
id: "planId",
|
|
36
|
+
label: t("formPlanLabel"),
|
|
37
|
+
value: state.planId || "",
|
|
38
|
+
onValueChange: (value) => handleChange("planId", value),
|
|
39
|
+
options: plans
|
|
40
|
+
.filter(({ name }) => name.match("PKR"))
|
|
41
|
+
.map((plan) => ({
|
|
42
|
+
id: plan.id,
|
|
43
|
+
name: plan.name,
|
|
44
|
+
})),
|
|
45
|
+
placeholder: t("formPlanPlaceholder"),
|
|
46
|
+
info: t("formPlanInfo"),
|
|
47
|
+
searchEndpoint: WORKSPACE_API_ROUTES.UNIT,
|
|
48
|
+
});
|
|
49
|
+
return (_jsxs("div", { className: "space-y-6", children: [_jsx(EnhancedInput, { id: "name", label: t("formNameLabel"), value: state.name, onChange: (e) => handleChange("name", e.target.value), error: state.errors.name, placeholder: t("formNamePlaceholder"), required: true, readOnly: true }), _jsx(EnhancedInput, { id: "subdomain", label: t("formSubdomainLabel"), value: state.subdomain, onChange: (e) => handleChange("subdomain", e.target.value), error: state.errors.subdomain, placeholder: t("formSubdomainPlaceholder"), required: true, info: t("formSubdomainUrlInfo", { subdomain: state.subdomain }), readOnly: true }), _jsx(EnhancedTextarea, { id: "description", label: t("formDescriptionLabel"), value: state.description || "", onChange: (e) => handleChange("description", e.target.value), error: state.errors.description, placeholder: t("formDescriptionPlaceholder"), rows: 3 }), _jsx(EnhancedInput, { id: "logo", label: t("formLogoLabel"), value: state.logo || "", onChange: (e) => handleChange("logo", e.target.value), error: state.errors.logo, placeholder: t("formLogoPlaceholder"), type: "url", readOnly: true }), planIdCombo, _jsxs("div", { className: "mt-6 border-t pt-6", children: [_jsxs("div", { className: "mb-4 flex items-center gap-2", children: [_jsx(Shield, { className: "text-primary h-5 w-5" }), _jsx("h3", { className: "text-lg font-semibold", children: t("formSecretsTitleLabel") })] }), _jsx("p", { className: "text-muted-foreground mb-4 text-sm", children: t("formSecretsDescriptionLabel") }), _jsx(SecretsEditor, { secrets: secrets, errors: state.errors, onChange: handleSecretChange, secretPlaceholder: t("formSecretPlaceholder") })] })] }));
|
|
40
50
|
};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Key responsibilities:
|
|
10
10
|
* - Expose `useWorkspaceUserModule()` which UI components call for actions
|
|
11
11
|
* - Keep module-specific `apiParams` and callbacks in one place
|
|
12
|
-
* - Ensure
|
|
12
|
+
* - Ensure toast notifications on mutation
|
|
13
13
|
*
|
|
14
14
|
* Exported utilities:
|
|
15
15
|
* - `WorkspaceUserProvider` — provider component used by the page
|
|
@@ -150,6 +150,7 @@ export declare const useWorkspaceUserModule: () => {
|
|
|
150
150
|
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
151
151
|
}[];
|
|
152
152
|
listLoading: boolean;
|
|
153
|
+
resetRecordFormState: () => void;
|
|
153
154
|
rowActions: RowAction[];
|
|
154
155
|
updateLoading: boolean;
|
|
155
156
|
state: {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Key responsibilities:
|
|
10
10
|
* - Expose `useWorkspaceUserModule()` which UI components call for actions
|
|
11
11
|
* - Keep module-specific `apiParams` and callbacks in one place
|
|
12
|
-
* - Ensure
|
|
12
|
+
* - Ensure toast notifications on mutation
|
|
13
13
|
*
|
|
14
14
|
* Exported utilities:
|
|
15
15
|
* - `WorkspaceUserProvider` — provider component used by the page
|
|
@@ -26,7 +26,6 @@ import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
|
|
|
26
26
|
import { createGenericModule } from "@react-pakistan/util-functions/factory/generic-module-factory";
|
|
27
27
|
import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
|
|
28
28
|
import { WORKSPACE_USER_API_ROUTES, pageLimit } from "./constants";
|
|
29
|
-
import { getCachedWorkspaceUsers, invalidateWorkspaceUsersCache, } from "./cache";
|
|
30
29
|
import { workspaceUserFormValidation } from "./validate";
|
|
31
30
|
import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
|
|
32
31
|
import { useTranslations } from "next-intl";
|
|
@@ -111,10 +110,6 @@ export const useWorkspaceUserModule = () => {
|
|
|
111
110
|
}), [state.enabled, state.id, state.roleId, state.userId, workspace === null || workspace === void 0 ? void 0 : workspace.id]);
|
|
112
111
|
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
113
112
|
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
114
|
-
const isDefaultListState = state.currentPage === 1 &&
|
|
115
|
-
state.pageLimit === pageLimit &&
|
|
116
|
-
!debouncedQuery &&
|
|
117
|
-
state.filterEnabled === undefined;
|
|
118
113
|
// ============================================================================
|
|
119
114
|
// 1.4.3 UTILITIES
|
|
120
115
|
// ============================================================================
|
|
@@ -139,6 +134,31 @@ export const useWorkspaceUserModule = () => {
|
|
|
139
134
|
payload: { drawer: null },
|
|
140
135
|
});
|
|
141
136
|
}, [dispatch]);
|
|
137
|
+
const resetRecordFormState = useCallback(() => {
|
|
138
|
+
dispatch({
|
|
139
|
+
type: WORKSPACE_USER_ACTION_TYPES.SET_ERRORS,
|
|
140
|
+
payload: { errors: {} },
|
|
141
|
+
});
|
|
142
|
+
dispatch({
|
|
143
|
+
type: WORKSPACE_USER_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
144
|
+
payload: { disabled: false },
|
|
145
|
+
});
|
|
146
|
+
dispatch({
|
|
147
|
+
type: WORKSPACE_USER_ACTION_TYPES.SET_FORM_DATA,
|
|
148
|
+
payload: {
|
|
149
|
+
form: {
|
|
150
|
+
enabled: true,
|
|
151
|
+
filterEnabled: undefined,
|
|
152
|
+
id: "",
|
|
153
|
+
roleId: null,
|
|
154
|
+
userId: "",
|
|
155
|
+
workspaceId: "",
|
|
156
|
+
role: undefined,
|
|
157
|
+
workspace: undefined,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}, [dispatch]);
|
|
142
162
|
// ============================================================================
|
|
143
163
|
// 1.4.4 API CALLBACKS
|
|
144
164
|
// ============================================================================
|
|
@@ -167,7 +187,6 @@ export const useWorkspaceUserModule = () => {
|
|
|
167
187
|
}
|
|
168
188
|
if (data) {
|
|
169
189
|
showToast(t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
|
|
170
|
-
invalidateWorkspaceUsersCache();
|
|
171
190
|
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
172
191
|
resetFormAndCloseDrawer();
|
|
173
192
|
}
|
|
@@ -192,7 +211,6 @@ export const useWorkspaceUserModule = () => {
|
|
|
192
211
|
}
|
|
193
212
|
if (data) {
|
|
194
213
|
showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
|
|
195
|
-
invalidateWorkspaceUsersCache();
|
|
196
214
|
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
197
215
|
}
|
|
198
216
|
}, [showToast, t]);
|
|
@@ -338,14 +356,14 @@ export const useWorkspaceUserModule = () => {
|
|
|
338
356
|
{
|
|
339
357
|
enabled: false,
|
|
340
358
|
handleOnClick: handleFilters,
|
|
341
|
-
label: t("
|
|
359
|
+
label: t("actionsButtonFilters"),
|
|
342
360
|
order: 1,
|
|
343
361
|
icon: Filter,
|
|
344
362
|
},
|
|
345
363
|
{
|
|
346
364
|
enabled: false,
|
|
347
365
|
handleOnClick: handleMoreActions,
|
|
348
|
-
label: t("
|
|
366
|
+
label: t("actionsButtonMoreActions"),
|
|
349
367
|
order: 2,
|
|
350
368
|
icon: Plus,
|
|
351
369
|
},
|
|
@@ -354,7 +372,7 @@ export const useWorkspaceUserModule = () => {
|
|
|
354
372
|
{
|
|
355
373
|
enabled: true,
|
|
356
374
|
handleOnClick: handleView,
|
|
357
|
-
label: t("
|
|
375
|
+
label: t("actionsButtonView"),
|
|
358
376
|
order: 1,
|
|
359
377
|
icon: Eye,
|
|
360
378
|
},
|
|
@@ -366,25 +384,8 @@ export const useWorkspaceUserModule = () => {
|
|
|
366
384
|
var _a;
|
|
367
385
|
if (!(workspace === null || workspace === void 0 ? void 0 : workspace.id))
|
|
368
386
|
return;
|
|
369
|
-
if (isDefaultListState) {
|
|
370
|
-
(async () => {
|
|
371
|
-
try {
|
|
372
|
-
const { count, items } = await getCachedWorkspaceUsers({
|
|
373
|
-
params: listParams,
|
|
374
|
-
});
|
|
375
|
-
dispatch({
|
|
376
|
-
type: WORKSPACE_USER_ACTION_TYPES.SET_ITEMS,
|
|
377
|
-
payload: { items: items || [], count: count || 0 },
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
catch (_a) {
|
|
381
|
-
showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
382
|
-
}
|
|
383
|
-
})();
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
387
|
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
387
|
-
}, [dispatch,
|
|
388
|
+
}, [dispatch, listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, showToast, t]);
|
|
388
389
|
// ============================================================================
|
|
389
390
|
// 1.4.10 RETURN
|
|
390
391
|
// ============================================================================
|
|
@@ -406,6 +407,7 @@ export const useWorkspaceUserModule = () => {
|
|
|
406
407
|
handleView,
|
|
407
408
|
headerActions,
|
|
408
409
|
listLoading,
|
|
410
|
+
resetRecordFormState,
|
|
409
411
|
rowActions,
|
|
410
412
|
updateLoading });
|
|
411
413
|
};
|