@appcorp/fusion-storybook 0.1.4
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/README.md +147 -0
- package/base-modules/admission/cache.d.ts +14 -0
- package/base-modules/admission/cache.js +31 -0
- package/base-modules/admission/constants.d.ts +32 -0
- package/base-modules/admission/constants.js +37 -0
- package/base-modules/admission/context.d.ts +369 -0
- package/base-modules/admission/context.js +755 -0
- package/base-modules/admission/filter.d.ts +1 -0
- package/base-modules/admission/filter.js +31 -0
- package/base-modules/admission/form.d.ts +1 -0
- package/base-modules/admission/form.js +86 -0
- package/base-modules/admission/more-actions.d.ts +1 -0
- package/base-modules/admission/more-actions.js +5 -0
- package/base-modules/admission/page.d.ts +16 -0
- package/base-modules/admission/page.js +128 -0
- package/base-modules/admission/validate.d.ts +38 -0
- package/base-modules/admission/validate.js +70 -0
- package/base-modules/admission/view.d.ts +1 -0
- package/base-modules/admission/view.js +40 -0
- package/base-modules/discount-code/cache.d.ts +27 -0
- package/base-modules/discount-code/cache.js +46 -0
- package/base-modules/discount-code/constants.d.ts +19 -0
- package/base-modules/discount-code/constants.js +26 -0
- package/base-modules/discount-code/context.d.ts +154 -0
- package/base-modules/discount-code/context.js +416 -0
- package/base-modules/discount-code/filter.d.ts +9 -0
- package/base-modules/discount-code/filter.js +14 -0
- package/base-modules/discount-code/form.d.ts +1 -0
- package/base-modules/discount-code/form.js +44 -0
- package/base-modules/discount-code/more-actions.d.ts +9 -0
- package/base-modules/discount-code/more-actions.js +13 -0
- package/base-modules/discount-code/page.d.ts +16 -0
- package/base-modules/discount-code/page.js +120 -0
- package/base-modules/discount-code/validate.d.ts +19 -0
- package/base-modules/discount-code/validate.js +38 -0
- package/base-modules/discount-code/view.d.ts +1 -0
- package/base-modules/discount-code/view.js +26 -0
- package/base-modules/family/cache.d.ts +14 -0
- package/base-modules/family/cache.js +31 -0
- package/base-modules/family/constants.d.ts +22 -0
- package/base-modules/family/constants.js +26 -0
- package/base-modules/family/context.d.ts +173 -0
- package/base-modules/family/context.js +441 -0
- package/base-modules/family/filter.d.ts +1 -0
- package/base-modules/family/filter.js +28 -0
- package/base-modules/family/form.d.ts +1 -0
- package/base-modules/family/form.js +12 -0
- package/base-modules/family/more-actions.d.ts +1 -0
- package/base-modules/family/more-actions.js +5 -0
- package/base-modules/family/page.d.ts +16 -0
- package/base-modules/family/page.js +120 -0
- package/base-modules/family/validate.d.ts +15 -0
- package/base-modules/family/validate.js +18 -0
- package/base-modules/family/view.d.ts +1 -0
- package/base-modules/family/view.js +18 -0
- package/base-modules/family-member/cache.d.ts +14 -0
- package/base-modules/family-member/cache.js +31 -0
- package/base-modules/family-member/constants.d.ts +22 -0
- package/base-modules/family-member/constants.js +26 -0
- package/base-modules/family-member/context.d.ts +215 -0
- package/base-modules/family-member/context.js +486 -0
- package/base-modules/family-member/filter.d.ts +1 -0
- package/base-modules/family-member/filter.js +28 -0
- package/base-modules/family-member/form.d.ts +1 -0
- package/base-modules/family-member/form.js +17 -0
- package/base-modules/family-member/more-actions.d.ts +1 -0
- package/base-modules/family-member/more-actions.js +5 -0
- package/base-modules/family-member/page.d.ts +16 -0
- package/base-modules/family-member/page.js +122 -0
- package/base-modules/family-member/validate.d.ts +24 -0
- package/base-modules/family-member/validate.js +27 -0
- package/base-modules/family-member/view.d.ts +1 -0
- package/base-modules/family-member/view.js +40 -0
- package/base-modules/student-profile/cache.d.ts +14 -0
- package/base-modules/student-profile/cache.js +31 -0
- package/base-modules/student-profile/constants.d.ts +105 -0
- package/base-modules/student-profile/constants.js +132 -0
- package/base-modules/student-profile/context.d.ts +290 -0
- package/base-modules/student-profile/context.js +583 -0
- package/base-modules/student-profile/filter.d.ts +1 -0
- package/base-modules/student-profile/filter.js +26 -0
- package/base-modules/student-profile/form.d.ts +1 -0
- package/base-modules/student-profile/form.js +19 -0
- package/base-modules/student-profile/more-actions.d.ts +1 -0
- package/base-modules/student-profile/more-actions.js +5 -0
- package/base-modules/student-profile/page.d.ts +9 -0
- package/base-modules/student-profile/page.js +86 -0
- package/base-modules/student-profile/validate.d.ts +23 -0
- package/base-modules/student-profile/validate.js +34 -0
- package/base-modules/student-profile/view.d.ts +1 -0
- package/base-modules/student-profile/view.js +29 -0
- package/base-modules/workspace/cache.d.ts +9 -0
- package/base-modules/workspace/cache.js +28 -0
- package/base-modules/workspace/constants.d.ts +10 -0
- package/base-modules/workspace/constants.js +18 -0
- package/base-modules/workspace/context.d.ts +187 -0
- package/base-modules/workspace/context.js +293 -0
- package/base-modules/workspace/drawer.d.ts +1 -0
- package/base-modules/workspace/drawer.js +24 -0
- package/base-modules/workspace/filter.d.ts +1 -0
- package/base-modules/workspace/filter.js +13 -0
- package/base-modules/workspace/form.d.ts +1 -0
- package/base-modules/workspace/form.js +40 -0
- package/base-modules/workspace/more-actions.d.ts +1 -0
- package/base-modules/workspace/more-actions.js +13 -0
- package/base-modules/workspace/page.d.ts +1 -0
- package/base-modules/workspace/page.js +31 -0
- package/base-modules/workspace/validate.d.ts +9 -0
- package/base-modules/workspace/validate.js +8 -0
- package/base-modules/workspace/view.d.ts +1 -0
- package/base-modules/workspace/view.js +52 -0
- package/components/rbac-no-access.d.ts +6 -0
- package/components/rbac-no-access.js +4 -0
- package/constants.d.ts +81 -0
- package/constants.js +81 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +5 -0
- package/package.json +104 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/type.d.ts +1141 -0
- package/type.js +427 -0
- package/utils/admission-pdf.d.ts +78 -0
- package/utils/admission-pdf.js +73 -0
- package/utils/clear-cache.d.ts +1 -0
- package/utils/clear-cache.js +8 -0
- package/utils/format-value.d.ts +1 -0
- package/utils/format-value.js +1 -0
- package/utils/pdf-generator.d.ts +41 -0
- package/utils/pdf-generator.js +107 -0
- package/utils/resolve-rbac-permissions.d.ts +11 -0
- package/utils/resolve-rbac-permissions.js +251 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* StudentProfile Page — generic page wrapper
|
|
5
|
+
*
|
|
6
|
+
* Uses `createGenericModulePage` to provide the table + drawer chrome while
|
|
7
|
+
* wiring the module-specific content (filter, form, view, more-actions)
|
|
8
|
+
* via the `ComponentConfig`.
|
|
9
|
+
*/
|
|
10
|
+
import { useMemo } from "react";
|
|
11
|
+
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
12
|
+
import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
|
|
13
|
+
import { useStudentProfileModule, StudentProfileProvider, STUDENT_PROFILE_DRAWER, STUDENT_PROFILE_ACTION_TYPES, } from "./context";
|
|
14
|
+
import { StudentProfileFilter } from "./filter";
|
|
15
|
+
import { StudentProfileForm } from "./form";
|
|
16
|
+
import { StudentProfileMoreActions } from "./more-actions";
|
|
17
|
+
import { StudentProfileView } from "./view";
|
|
18
|
+
// import { useAuthStateContext } from "@/contexts/auth-context";
|
|
19
|
+
import { resolveRbacPermissions } from "@/utils/resolve-rbac-permissions";
|
|
20
|
+
import { USER_ROLE } from "@/type";
|
|
21
|
+
import { RbacNoAccess } from "@/components/rbac-no-access";
|
|
22
|
+
import { useTranslations } from "next-intl";
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// TABLE COLUMN CONFIGURATION (static — no runtime deps)
|
|
25
|
+
// ============================================================================
|
|
26
|
+
const tableBodyCols = [
|
|
27
|
+
{ componentType: COMPONENT_TYPE.ID, key: "id" },
|
|
28
|
+
{ componentType: COMPONENT_TYPE.OBJECT, key: ["familyMember:firstName"] },
|
|
29
|
+
{ componentType: COMPONENT_TYPE.OBJECT, key: ["familyMember:lastName"] },
|
|
30
|
+
{ componentType: COMPONENT_TYPE.TEXT, key: "studentCode" },
|
|
31
|
+
{ componentType: COMPONENT_TYPE.TEXT, key: "status" },
|
|
32
|
+
{ componentType: COMPONENT_TYPE.BOOLEAN, key: "enabled" },
|
|
33
|
+
{ componentType: COMPONENT_TYPE.ACTIONS },
|
|
34
|
+
];
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// GENERIC PAGE COMPONENT
|
|
37
|
+
// ============================================================================
|
|
38
|
+
const StudentProfilePageInner = () => {
|
|
39
|
+
// const { user } = useAuthStateContext();
|
|
40
|
+
// const userRole = user?.user_metadata?.role as USER_ROLE;
|
|
41
|
+
const userRole = USER_ROLE.SCHOOL_ADMIN; // Default for storybook
|
|
42
|
+
const t = useTranslations("studentProfile");
|
|
43
|
+
const context = useStudentProfileModule();
|
|
44
|
+
// Config only changes when the locale changes or the drawer changes (size).
|
|
45
|
+
// Keeping this stable is critical: createGenericModulePage closes over config
|
|
46
|
+
// and produces a new React component type. If that type changes during render,
|
|
47
|
+
// React unmounts → remounts → effects fire → dispatch → infinite loop.
|
|
48
|
+
const studentProfileConfig = useMemo(() => ({
|
|
49
|
+
moduleName: "studentProfile",
|
|
50
|
+
tableColumns: [
|
|
51
|
+
{ label: t("id"), width: "5%" },
|
|
52
|
+
{ label: t("firstName"), width: "15%" },
|
|
53
|
+
{ label: t("lastName"), width: "15%" },
|
|
54
|
+
{ label: t("studentCode"), width: "15%" },
|
|
55
|
+
{ label: t("status"), width: "20%" },
|
|
56
|
+
{ label: t("enabled"), width: "10%" },
|
|
57
|
+
{ label: t("actions"), width: "5%" },
|
|
58
|
+
],
|
|
59
|
+
cancelLabel: t("cancel"),
|
|
60
|
+
drawerTitle: t("studentProfile"),
|
|
61
|
+
filterContent: _jsx(StudentProfileFilter, {}),
|
|
62
|
+
formContent: _jsx(StudentProfileForm, {}),
|
|
63
|
+
moreActionsContent: _jsx(StudentProfileMoreActions, {}),
|
|
64
|
+
saveLabel: t("save"),
|
|
65
|
+
searchPlaceholder: t("searchStudentProfiles"),
|
|
66
|
+
tableDescription: t("manageStudentProfilesAndTheirInformation"),
|
|
67
|
+
tableTitle: t("studentProfile"),
|
|
68
|
+
viewContent: _jsx(StudentProfileView, {}),
|
|
69
|
+
size: context.state.drawer === STUDENT_PROFILE_DRAWER.FORM_DRAWER
|
|
70
|
+
? "full"
|
|
71
|
+
: "small",
|
|
72
|
+
onClearFilters: () => {
|
|
73
|
+
context.dispatch({ type: STUDENT_PROFILE_ACTION_TYPES.RESET_FORM });
|
|
74
|
+
},
|
|
75
|
+
}), [t, context.state.drawer]);
|
|
76
|
+
const GenericStudentProfilePage = useMemo(() => createGenericModulePage(studentProfileConfig), [studentProfileConfig]);
|
|
77
|
+
const hasPermission = resolveRbacPermissions({
|
|
78
|
+
userRole,
|
|
79
|
+
moduleName: "People Management",
|
|
80
|
+
});
|
|
81
|
+
if (!hasPermission) {
|
|
82
|
+
return _jsx(RbacNoAccess, { moduleName: "People Management" });
|
|
83
|
+
}
|
|
84
|
+
return (_jsx("div", { className: "p-4", children: _jsx(GenericStudentProfilePage, { config: studentProfileConfig, context: context, tableBodyCols: tableBodyCols }) }));
|
|
85
|
+
};
|
|
86
|
+
export const StudentProfilePage = () => (_jsx(StudentProfileProvider, { children: _jsx(StudentProfilePageInner, {}) }));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Student Validation Schema
|
|
3
|
+
*
|
|
4
|
+
* Zod validation schemas for student form data.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
export declare const studentProfileFormValidation: z.ZodObject<{
|
|
8
|
+
firstName: z.ZodString;
|
|
9
|
+
lastName: z.ZodString;
|
|
10
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
11
|
+
emergencyPhone: z.ZodOptional<z.ZodString>;
|
|
12
|
+
status: z.ZodString;
|
|
13
|
+
dateOfBirth: z.ZodOptional<z.ZodString>;
|
|
14
|
+
enrollmentDate: z.ZodOptional<z.ZodString>;
|
|
15
|
+
gender: z.ZodOptional<z.ZodString>;
|
|
16
|
+
bloodGroup: z.ZodOptional<z.ZodString>;
|
|
17
|
+
address: z.ZodOptional<z.ZodString>;
|
|
18
|
+
city: z.ZodOptional<z.ZodString>;
|
|
19
|
+
state: z.ZodOptional<z.ZodString>;
|
|
20
|
+
postalCode: z.ZodOptional<z.ZodString>;
|
|
21
|
+
country: z.ZodOptional<z.ZodString>;
|
|
22
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Student Validation Schema
|
|
3
|
+
*
|
|
4
|
+
* Zod validation schemas for student form data.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// VALIDATION SCHEMA
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export const studentProfileFormValidation = z.object({
|
|
11
|
+
firstName: z.string().min(1, "First name is required"),
|
|
12
|
+
lastName: z.string().min(1, "Last name is required"),
|
|
13
|
+
phone: z
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.refine((val) => !val ||
|
|
17
|
+
/^([+]?[\s0-9]+)?(\d{3}|[(]?[0-9]+[)]?)?([-]?[\s]?[0-9])+$/.test(val), "Invalid phone number format"),
|
|
18
|
+
emergencyPhone: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.refine((val) => !val ||
|
|
22
|
+
/^([+]?[\s0-9]+)?(\d{3}|[(]?[0-9]+[)]?)?([-]?[\s]?[0-9])+$/.test(val), "Invalid phone number format"),
|
|
23
|
+
status: z.string().min(1, "Status is required"),
|
|
24
|
+
dateOfBirth: z.string().optional(),
|
|
25
|
+
enrollmentDate: z.string().optional(),
|
|
26
|
+
gender: z.string().optional(),
|
|
27
|
+
bloodGroup: z.string().optional(),
|
|
28
|
+
address: z.string().optional(),
|
|
29
|
+
city: z.string().optional(),
|
|
30
|
+
state: z.string().optional(),
|
|
31
|
+
postalCode: z.string().optional(),
|
|
32
|
+
country: z.string().optional(),
|
|
33
|
+
enabled: z.boolean().optional(),
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StudentProfileView: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@appcorp/shadcn/components/ui/card";
|
|
4
|
+
import { Badge } from "@appcorp/shadcn/components/ui/badge";
|
|
5
|
+
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
6
|
+
import { Avatar, AvatarFallback, AvatarImage, } from "@appcorp/shadcn/components/ui/avatar";
|
|
7
|
+
import { formatDate, DATE_FORMATS } from "@react-pakistan/util-functions";
|
|
8
|
+
import { User, Phone, MapPin, Calendar, GraduationCap, CheckCircle2, XCircle, } from "lucide-react";
|
|
9
|
+
import { useTranslations } from "next-intl";
|
|
10
|
+
import { useStudentProfileModule } from "./context";
|
|
11
|
+
import { formatValue } from "@/utils/format-value";
|
|
12
|
+
export const StudentProfileView = () => {
|
|
13
|
+
const t = useTranslations("studentProfile");
|
|
14
|
+
const context = useStudentProfileModule();
|
|
15
|
+
const { address, avatar, city, country, dateOfBirth, email, emergencyPhone, enabled, firstName, gender, lastName, phone, postalCode, status, studentCode, } = context.state;
|
|
16
|
+
const stateValue = context.state.state;
|
|
17
|
+
const fullName = `${firstName} ${lastName}`;
|
|
18
|
+
const initials = `${(firstName === null || firstName === void 0 ? void 0 : firstName[0]) || ""}${(lastName === null || lastName === void 0 ? void 0 : lastName[0]) || ""}`.toUpperCase();
|
|
19
|
+
const formatDateValue = (date) => {
|
|
20
|
+
if (!date)
|
|
21
|
+
return "\u2014";
|
|
22
|
+
return formatDate(new Date(date).toISOString(), DATE_FORMATS.LOCALE_DATE);
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "flex items-center gap-6", children: [_jsxs(Avatar, { className: "h-24 w-24", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: fullName }), _jsx(AvatarFallback, { className: "text-2xl", children: initials })] }), _jsxs("div", { className: "flex-1", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("h2", { className: "text-2xl font-bold", children: fullName }), enabled ? (_jsx(CheckCircle2, { className: "h-5 w-5 text-green-500" })) : (_jsx(XCircle, { className: "h-5 w-5 text-red-500" }))] }), _jsxs("p", { className: "text-muted-foreground mt-1", children: [t("studentCode"), ": ", studentCode || "N/A"] }), email && (_jsx("p", { className: "text-sm text-muted-foreground mt-1", children: email }))] })] }) }) }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(User, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { className: "text-lg", children: t("personalInformation") })] }), _jsx(CardDescription, { children: t("basicPersonalDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("firstName") }), _jsx("p", { className: "text-base", children: formatValue(firstName) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("lastName") }), _jsx("p", { className: "text-base", children: formatValue(lastName) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "h-4 w-4 text-muted-foreground" }), _jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("dateOfBirth") })] }), _jsx("p", { className: "text-base", children: formatDateValue(dateOfBirth) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("gender") }), _jsx(Badge, { variant: "secondary", className: "capitalize", children: formatValue(gender === null || gender === void 0 ? void 0 : gender.toLowerCase()) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { className: "text-lg", children: t("contactInformation") })] }), _jsx(CardDescription, { children: t("contactDetailsAndLocation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [email && (_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("email") }), _jsx("p", { className: "text-base", children: formatValue(email) })] })), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("phone") }), _jsx("p", { className: "text-base", children: formatValue(phone) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("emergencyPhone") }), _jsx("p", { className: "text-base", children: formatValue(emergencyPhone) })] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MapPin, { className: "h-4 w-4 text-muted-foreground" }), _jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("address") })] }), _jsx("p", { className: "text-base", children: formatValue(address) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("city") }), _jsx("p", { className: "text-base", children: formatValue(city) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("stateProvince") }), _jsx("p", { className: "text-base", children: formatValue(stateValue) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("country") }), _jsx("p", { className: "text-base", children: formatValue(country) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("postalCode") }), _jsx("p", { className: "text-base", children: formatValue(postalCode) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(GraduationCap, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { className: "text-lg", children: t("academicInformation") })] }), _jsx(CardDescription, { children: t("enrollmentAndAcademicStatus") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("status") }), _jsx(Badge, { variant: status === "ACTIVE"
|
|
25
|
+
? "default"
|
|
26
|
+
: status === "GRADUATED"
|
|
27
|
+
? "secondary"
|
|
28
|
+
: "outline", className: "capitalize", children: formatValue(status === null || status === void 0 ? void 0 : status.toLowerCase().replace(/_/g, " ")) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: t("accountStatus") }), _jsx("div", { className: "flex items-center gap-2", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-5 w-5 text-green-600 dark:text-green-400" }), _jsx(Badge, { variant: "outline", className: "border-green-600 text-green-700 dark:border-green-400 dark:text-green-400", children: t("active") })] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-5 w-5 text-gray-400" }), _jsx(Badge, { variant: "outline", className: "text-muted-foreground", children: t("inactive") })] })) })] })] }) })] })] }));
|
|
29
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Cache
|
|
3
|
+
*
|
|
4
|
+
* Cache utilities for workspace data using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { WorkspaceBE } from "@/type";
|
|
7
|
+
export declare const getCachedWorkspace: (id: string) => Promise<WorkspaceBE | null>;
|
|
8
|
+
export declare const getCachedWorkspaceSync: () => WorkspaceBE | null;
|
|
9
|
+
export declare const invalidateWorkspaceCache: () => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Cache
|
|
3
|
+
*
|
|
4
|
+
* Cache utilities for workspace data using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { getCachedSingleItem, getCachedSingleItemSync, invalidateCache, } from "@react-pakistan/util-functions";
|
|
7
|
+
import { WORKSPACE_API_ROUTES } from "./constants";
|
|
8
|
+
import { LS_KEYS } from "@/constants";
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// CACHE CONFIGURATION
|
|
11
|
+
// ============================================================================
|
|
12
|
+
const CACHE_CONFIG = {
|
|
13
|
+
cacheKey: LS_KEYS.WORKSPACE,
|
|
14
|
+
apiUrl: WORKSPACE_API_ROUTES.UNIT,
|
|
15
|
+
responseKey: "item",
|
|
16
|
+
};
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// CACHE WRAPPERS
|
|
19
|
+
// ============================================================================
|
|
20
|
+
export const getCachedWorkspace = (id) => {
|
|
21
|
+
return getCachedSingleItem(CACHE_CONFIG, { id });
|
|
22
|
+
};
|
|
23
|
+
export const getCachedWorkspaceSync = () => {
|
|
24
|
+
return getCachedSingleItemSync(LS_KEYS.WORKSPACE);
|
|
25
|
+
};
|
|
26
|
+
export const invalidateWorkspaceCache = () => {
|
|
27
|
+
invalidateCache(LS_KEYS.WORKSPACE);
|
|
28
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Constants
|
|
3
|
+
*
|
|
4
|
+
* Organization:
|
|
5
|
+
* - Page Configuration
|
|
6
|
+
* - API Routes
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// PAGE CONFIGURATION
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// API ROUTES
|
|
14
|
+
// ============================================================================
|
|
15
|
+
export const WORKSPACE_API_ROUTES = {
|
|
16
|
+
UNIT: "/api/v1/workspace",
|
|
17
|
+
};
|
|
18
|
+
export const secretKeys = ["GOOGLE_SMTP", "GEMINI_API_KEY", "GEMINI_MODEL"];
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export declare const WORKSPACE_ACTION_TYPES: {
|
|
2
|
+
readonly RESET_FORM: "RESET_FORM";
|
|
3
|
+
readonly SET_CURRENT_PAGE: "SET_CURRENT_PAGE";
|
|
4
|
+
readonly SET_PAGE_LIMIT: "SET_PAGE_LIMIT";
|
|
5
|
+
readonly SET_SEARCH_QUERY: "SET_SEARCH_QUERY";
|
|
6
|
+
readonly SET_DRAWER: "SET_DRAWER";
|
|
7
|
+
readonly SET_ITEMS: "SET_ITEMS";
|
|
8
|
+
readonly SET_FORM_DATA: "SET_FORM_DATA";
|
|
9
|
+
readonly SET_DISABLE_SAVE_BUTTON: "SET_DISABLE_SAVE_BUTTON";
|
|
10
|
+
readonly SET_INPUT_FIELD: "SET_INPUT_FIELD";
|
|
11
|
+
readonly SET_ERRORS: "SET_ERRORS";
|
|
12
|
+
readonly SET_FILTERS: "SET_FILTERS";
|
|
13
|
+
}, workspaceModuleConfig: import("@react-pakistan/util-functions/factory/generic-module-factory").ModuleConfig<{
|
|
14
|
+
agreedCurrency: string;
|
|
15
|
+
agreedPrice: number;
|
|
16
|
+
billingDate: null;
|
|
17
|
+
billingInterval: string;
|
|
18
|
+
classesCount: number;
|
|
19
|
+
coursesCount: number;
|
|
20
|
+
description: string;
|
|
21
|
+
dueDateLength: number;
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
familiesCount: number;
|
|
24
|
+
id: string;
|
|
25
|
+
logo: string;
|
|
26
|
+
name: string;
|
|
27
|
+
planEndDate: null;
|
|
28
|
+
planId: string;
|
|
29
|
+
planStartDate: null;
|
|
30
|
+
secrets: {};
|
|
31
|
+
staffAccountsCount: number;
|
|
32
|
+
storageUsedMB: number;
|
|
33
|
+
studentsCount: number;
|
|
34
|
+
subdomain: string;
|
|
35
|
+
teachersCount: number;
|
|
36
|
+
disableSaveButton: boolean;
|
|
37
|
+
drawer: null;
|
|
38
|
+
errors: Record<string, string>;
|
|
39
|
+
}>, initialWorkspaceState: {
|
|
40
|
+
agreedCurrency: string;
|
|
41
|
+
agreedPrice: number;
|
|
42
|
+
billingDate: null;
|
|
43
|
+
billingInterval: string;
|
|
44
|
+
classesCount: number;
|
|
45
|
+
coursesCount: number;
|
|
46
|
+
description: string;
|
|
47
|
+
dueDateLength: number;
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
familiesCount: number;
|
|
50
|
+
id: string;
|
|
51
|
+
logo: string;
|
|
52
|
+
name: string;
|
|
53
|
+
planEndDate: null;
|
|
54
|
+
planId: string;
|
|
55
|
+
planStartDate: null;
|
|
56
|
+
secrets: {};
|
|
57
|
+
staffAccountsCount: number;
|
|
58
|
+
storageUsedMB: number;
|
|
59
|
+
studentsCount: number;
|
|
60
|
+
subdomain: string;
|
|
61
|
+
teachersCount: number;
|
|
62
|
+
disableSaveButton: boolean;
|
|
63
|
+
drawer: null;
|
|
64
|
+
errors: Record<string, string>;
|
|
65
|
+
}, WorkspaceProvider: import("react").FC<{
|
|
66
|
+
children: React.ReactNode;
|
|
67
|
+
}>, workspaceReducer: (state: {
|
|
68
|
+
agreedCurrency: string;
|
|
69
|
+
agreedPrice: number;
|
|
70
|
+
billingDate: null;
|
|
71
|
+
billingInterval: string;
|
|
72
|
+
classesCount: number;
|
|
73
|
+
coursesCount: number;
|
|
74
|
+
description: string;
|
|
75
|
+
dueDateLength: number;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
familiesCount: number;
|
|
78
|
+
id: string;
|
|
79
|
+
logo: string;
|
|
80
|
+
name: string;
|
|
81
|
+
planEndDate: null;
|
|
82
|
+
planId: string;
|
|
83
|
+
planStartDate: null;
|
|
84
|
+
secrets: {};
|
|
85
|
+
staffAccountsCount: number;
|
|
86
|
+
storageUsedMB: number;
|
|
87
|
+
studentsCount: number;
|
|
88
|
+
subdomain: string;
|
|
89
|
+
teachersCount: number;
|
|
90
|
+
disableSaveButton: boolean;
|
|
91
|
+
drawer: null;
|
|
92
|
+
errors: Record<string, string>;
|
|
93
|
+
}, action: any) => {
|
|
94
|
+
agreedCurrency: string;
|
|
95
|
+
agreedPrice: number;
|
|
96
|
+
billingDate: null;
|
|
97
|
+
billingInterval: string;
|
|
98
|
+
classesCount: number;
|
|
99
|
+
coursesCount: number;
|
|
100
|
+
description: string;
|
|
101
|
+
dueDateLength: number;
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
familiesCount: number;
|
|
104
|
+
id: string;
|
|
105
|
+
logo: string;
|
|
106
|
+
name: string;
|
|
107
|
+
planEndDate: null;
|
|
108
|
+
planId: string;
|
|
109
|
+
planStartDate: null;
|
|
110
|
+
secrets: {};
|
|
111
|
+
staffAccountsCount: number;
|
|
112
|
+
storageUsedMB: number;
|
|
113
|
+
studentsCount: number;
|
|
114
|
+
subdomain: string;
|
|
115
|
+
teachersCount: number;
|
|
116
|
+
disableSaveButton: boolean;
|
|
117
|
+
drawer: null;
|
|
118
|
+
errors: Record<string, string>;
|
|
119
|
+
}, useWorkspaceContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContext<{
|
|
120
|
+
agreedCurrency: string;
|
|
121
|
+
agreedPrice: number;
|
|
122
|
+
billingDate: null;
|
|
123
|
+
billingInterval: string;
|
|
124
|
+
classesCount: number;
|
|
125
|
+
coursesCount: number;
|
|
126
|
+
description: string;
|
|
127
|
+
dueDateLength: number;
|
|
128
|
+
enabled: boolean;
|
|
129
|
+
familiesCount: number;
|
|
130
|
+
id: string;
|
|
131
|
+
logo: string;
|
|
132
|
+
name: string;
|
|
133
|
+
planEndDate: null;
|
|
134
|
+
planId: string;
|
|
135
|
+
planStartDate: null;
|
|
136
|
+
secrets: {};
|
|
137
|
+
staffAccountsCount: number;
|
|
138
|
+
storageUsedMB: number;
|
|
139
|
+
studentsCount: number;
|
|
140
|
+
subdomain: string;
|
|
141
|
+
teachersCount: number;
|
|
142
|
+
disableSaveButton: boolean;
|
|
143
|
+
drawer: null;
|
|
144
|
+
errors: Record<string, string>;
|
|
145
|
+
}>;
|
|
146
|
+
export declare const WORKSPACE_DRAWER: {
|
|
147
|
+
readonly FORM_DRAWER: string;
|
|
148
|
+
readonly MORE_ACTIONS_DRAWER: string;
|
|
149
|
+
readonly VIEW_DRAWER: string;
|
|
150
|
+
};
|
|
151
|
+
export declare const useWorkspaceModule: () => {
|
|
152
|
+
plans: any[];
|
|
153
|
+
handleChange: (field: string, value: string | number | boolean | undefined | Record<string, string>) => void;
|
|
154
|
+
handleCloseDrawer: () => void;
|
|
155
|
+
handleEdit: () => void;
|
|
156
|
+
handleSubmit: () => void;
|
|
157
|
+
handleView: () => void;
|
|
158
|
+
updateLoading: boolean;
|
|
159
|
+
state: {
|
|
160
|
+
agreedCurrency: string;
|
|
161
|
+
agreedPrice: number;
|
|
162
|
+
billingDate: null;
|
|
163
|
+
billingInterval: string;
|
|
164
|
+
classesCount: number;
|
|
165
|
+
coursesCount: number;
|
|
166
|
+
description: string;
|
|
167
|
+
dueDateLength: number;
|
|
168
|
+
enabled: boolean;
|
|
169
|
+
familiesCount: number;
|
|
170
|
+
id: string;
|
|
171
|
+
logo: string;
|
|
172
|
+
name: string;
|
|
173
|
+
planEndDate: null;
|
|
174
|
+
planId: string;
|
|
175
|
+
planStartDate: null;
|
|
176
|
+
secrets: {};
|
|
177
|
+
staffAccountsCount: number;
|
|
178
|
+
storageUsedMB: number;
|
|
179
|
+
studentsCount: number;
|
|
180
|
+
subdomain: string;
|
|
181
|
+
teachersCount: number;
|
|
182
|
+
disableSaveButton: boolean;
|
|
183
|
+
drawer: null;
|
|
184
|
+
errors: Record<string, string>;
|
|
185
|
+
};
|
|
186
|
+
dispatch: React.Dispatch<any>;
|
|
187
|
+
};
|