@appcorp/fusion-storybook 0.5.37 → 0.5.40

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.
Files changed (35) hide show
  1. package/base-modules/admission/context/use-admission-module.d.ts +4 -1
  2. package/base-modules/admission/context/use-admission-module.js +63 -40
  3. package/base-modules/expense/context/shared.d.ts +5 -0
  4. package/base-modules/expense/context/shared.js +1 -0
  5. package/base-modules/expense/context/use-expense-module.d.ts +2 -1
  6. package/base-modules/expense/context/use-expense-module.js +49 -5
  7. package/base-modules/expense/form.js +4 -2
  8. package/base-modules/school/context.d.ts +13 -7
  9. package/base-modules/school/context.js +46 -5
  10. package/base-modules/school/form.js +11 -1
  11. package/base-modules/student-profile/context/use-student-profile-module.js +4 -0
  12. package/base-modules/teacher/context.js +9 -37
  13. package/base-modules/user/context/use-user-module.d.ts +1 -0
  14. package/base-modules/user/context/use-user-module.js +22 -43
  15. package/base-modules/user/context.d.ts +5 -0
  16. package/base-modules/user/context.js +1 -0
  17. package/base-modules/workspace/context.d.ts +13 -37
  18. package/base-modules/workspace/context.js +47 -25
  19. package/base-modules/workspace/form.js +11 -1
  20. package/base-modules/workspace/view.js +12 -9
  21. package/constants.d.ts +0 -4
  22. package/constants.js +0 -4
  23. package/package.json +2 -1
  24. package/tsconfig.build.tsbuildinfo +1 -1
  25. package/types/user-management.d.ts +2 -12
  26. package/utils/student-usage-api.d.ts +6 -0
  27. package/utils/student-usage-api.js +16 -0
  28. package/utils/student-usage.d.ts +20 -0
  29. package/utils/student-usage.js +40 -0
  30. package/utils/upload-file.d.ts +42 -0
  31. package/utils/upload-file.js +116 -0
  32. package/base-modules/teacher/avatar-upload.d.ts +0 -36
  33. package/base-modules/teacher/avatar-upload.js +0 -104
  34. package/utils/file-to-base64.d.ts +0 -1
  35. package/utils/file-to-base64.js +0 -10
@@ -10,13 +10,14 @@ import { useTranslations } from "next-intl";
10
10
  import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@appcorp/shadcn/components/ui/card";
11
11
  import { Badge } from "@appcorp/shadcn/components/ui/badge";
12
12
  import { Separator } from "@appcorp/shadcn/components/ui/separator";
13
- import { Building2, Globe, FileText, Image as LucideImage, CheckCircle2, XCircle, Calendar, CreditCard, Users, BookOpen, GraduationCap, Home, HardDrive, Clock, Shield, } from "lucide-react";
13
+ import { Progress } from "@appcorp/shadcn/components/ui/progress";
14
+ import { Building2, Globe, FileText, Image as LucideImage, CheckCircle2, XCircle, Calendar, CreditCard, Users, GraduationCap, Clock, Shield, } from "lucide-react";
14
15
  import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
15
16
  import { formatValue } from "@react-pakistan/util-functions/general/format-value";
16
17
  import { secretKeys } from "./constants";
17
18
  const APP_DOMAIN = process.env.NEXT_PUBLIC_APP_DOMAIN || "edupilotpro.com";
18
19
  export const WorkspaceView = () => {
19
- var _a, _b, _c;
20
+ var _a, _b, _c, _d;
20
21
  const { state, workspace } = useWorkspaceModule();
21
22
  const t = useTranslations("workspace");
22
23
  const appDomain = APP_DOMAIN;
@@ -39,19 +40,21 @@ export const WorkspaceView = () => {
39
40
  return "—";
40
41
  return interval.charAt(0).toUpperCase() + interval.slice(1).toLowerCase();
41
42
  };
42
- // Helper function to format storage
43
- const formatStorage = (mb) => {
44
- if (mb < 1024)
45
- return `${mb} MB`;
46
- return `${(mb / 1024).toFixed(1)} GB`;
47
- };
48
43
  return (_jsxs("div", { className: "space-y-6", children: [_jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Building2, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionBasicInfo") })] }), _jsx(CardDescription, { children: t("viewBasicInfoDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-2 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Building2, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formNameLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(state.name) })] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Globe, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formSubdomainLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(state.subdomain) }), state.subdomain && (_jsxs("p", { className: "text-muted-foreground text-sm", children: [t("viewFieldUrlPrefix"), state.subdomain, ".", appDomain] }))] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FileText, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formDescriptionLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(state.description) === "—"
49
44
  ? t("viewTextDescriptionNotProvided")
50
45
  : state.description })] }), state.logo && (_jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(LucideImage, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formLogoLabel") })] }), _jsx("div", { className: "mt-2", children: _jsx("img", { src: state.logo, alt: t("viewFieldLogoAlt"), width: 64, height: 64, className: "h-16 w-16 rounded border object-contain", onError: (e) => {
51
46
  e.currentTarget.style.display = "none";
52
47
  } }) })] })), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStatus") }), _jsxs(Badge, { variant: state.enabled ? "default" : "destructive", className: "gap-1", children: [state.enabled ? (_jsx(CheckCircle2, { className: "h-3 w-3" })) : (_jsx(XCircle, { className: "h-3 w-3" })), state.enabled
53
48
  ? t("viewStatusEnabled")
54
- : t("viewStatusDisabled")] })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CreditCard, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionPlanBilling") })] }), _jsx(CardDescription, { children: t("viewPlanBillingDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CreditCard, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPlanIdLabel") })] }), _jsx("p", { className: "text-base", children: planName })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPlanStartDateLabel") })] }), _jsx("p", { className: "text-base", children: formatDate(state.planStartDate || "", DATE_FORMATS.LOCALE_DATE) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPlanEndDateLabel") })] }), _jsx("p", { className: "text-base", children: formatDate(state.planEndDate || "", DATE_FORMATS.LOCALE_DATE) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Clock, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldBillingIntervalLabel") })] }), _jsx("p", { className: "text-base", children: formatBillingInterval(state.billingInterval) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CreditCard, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldAgreedPriceLabel") })] }), _jsx("p", { className: "text-base", children: formatCurrency(state.agreedPrice, state.agreedCurrency) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Globe, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCurrencyLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(state.agreedCurrency) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionUsageStats") })] }), _jsx(CardDescription, { children: t("viewUsageStatsDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-2 gap-6 md:grid-cols-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(GraduationCap, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStudentsLabel") })] }), _jsx("p", { className: "text-primary text-2xl font-bold", children: state.studentsCount })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldTeachersLabel") })] }), _jsx("p", { className: "text-primary text-2xl font-bold", children: state.teachersCount })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldClassesLabel") })] }), _jsx("p", { className: "text-primary text-2xl font-bold", children: state.classesCount })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCoursesLabel") })] }), _jsx("p", { className: "text-primary text-2xl font-bold", children: state.coursesCount })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Home, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldFamiliesLabel") })] }), _jsx("p", { className: "text-primary text-2xl font-bold", children: state.familiesCount })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(HardDrive, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStorageUsedLabel") })] }), _jsx("p", { className: "text-primary text-2xl font-bold", children: formatStorage(state.storageUsedMB) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Shield, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionSecrets") })] }), _jsx(CardDescription, { children: t("viewSecretsDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("div", { className: "space-y-4", children: _jsxs("div", { children: [_jsxs("div", { className: "mb-2 flex items-center gap-2", children: [_jsx(Shield, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldSecretsJsonLabel") })] }), state.secrets ? (_jsx("div", { className: "space-y-2", children: visibleSecrets.length === 0 ? (_jsx("p", { className: "text-muted-foreground italic", children: t("viewFieldNoSecretsConfigured") })) : (visibleSecrets.map(([k, v]) => (_jsxs("div", { className: "bg-muted/10 border-border/60 flex items-center justify-between rounded-md border p-3", children: [_jsx("div", { className: "text-foreground text-sm font-medium", children: k }), _jsx("div", { className: "text-foreground/80 text-sm", children: typeof v === "string" && v.length > 0
49
+ : t("viewStatusDisabled")] })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CreditCard, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionPlanBilling") })] }), _jsx(CardDescription, { children: t("viewPlanBillingDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CreditCard, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPlanIdLabel") })] }), _jsx("p", { className: "text-base", children: planName })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPlanStartDateLabel") })] }), _jsx("p", { className: "text-base", children: formatDate(state.planStartDate || "", DATE_FORMATS.LOCALE_DATE) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPlanEndDateLabel") })] }), _jsx("p", { className: "text-base", children: formatDate(state.planEndDate || "", DATE_FORMATS.LOCALE_DATE) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Clock, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldBillingIntervalLabel") })] }), _jsx("p", { className: "text-base", children: formatBillingInterval(state.billingInterval) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CreditCard, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldAgreedPriceLabel") })] }), _jsx("p", { className: "text-base", children: formatCurrency(state.agreedPrice, state.agreedCurrency) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Globe, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCurrencyLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(state.agreedCurrency) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionUsageStats") })] }), _jsx(CardDescription, { children: t("viewUsageStatsDescription") })] }), _jsx(Separator, {}), _jsxs(CardContent, { className: "pt-6", children: [_jsxs("div", { className: "flex flex-wrap items-end justify-between gap-4", children: [_jsxs("div", { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(GraduationCap, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStudentsLabel") })] }), _jsxs("p", { className: "text-primary mt-1 text-3xl font-bold", children: [state.studentsCount, _jsxs("span", { className: "text-muted-foreground ml-1 text-base font-medium", children: ["/ ", (_d = state.studentLimit) !== null && _d !== void 0 ? _d : t("viewUnlimitedLabel")] })] })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: state.studentLimit === null
50
+ ? t("viewUnlimitedDescription")
51
+ : t("viewStudentsRemaining", {
52
+ remaining: Math.max(state.studentLimit - state.studentsCount, 0),
53
+ }) })] }), state.studentLimit !== null && (_jsx(Progress, { className: "mt-4", value: state.studentLimit > 0
54
+ ? Math.min(Math.round((state.studentsCount / state.studentLimit) * 100), 100)
55
+ : state.studentsCount > 0
56
+ ? 100
57
+ : 0 }))] })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Shield, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionSecrets") })] }), _jsx(CardDescription, { children: t("viewSecretsDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("div", { className: "space-y-4", children: _jsxs("div", { children: [_jsxs("div", { className: "mb-2 flex items-center gap-2", children: [_jsx(Shield, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldSecretsJsonLabel") })] }), state.secrets ? (_jsx("div", { className: "space-y-2", children: visibleSecrets.length === 0 ? (_jsx("p", { className: "text-muted-foreground italic", children: t("viewFieldNoSecretsConfigured") })) : (visibleSecrets.map(([k, v]) => (_jsxs("div", { className: "bg-muted/10 border-border/60 flex items-center justify-between rounded-md border p-3", children: [_jsx("div", { className: "text-foreground text-sm font-medium", children: k }), _jsx("div", { className: "text-foreground/80 text-sm", children: typeof v === "string" && v.length > 0
55
58
  ? t("viewFieldSecretConfigured")
56
59
  : "—" })] }, k)))) })) : (_jsx("p", { className: "text-muted-foreground italic", children: t("viewFieldNoSecretsConfigured") })), _jsx("p", { className: "text-muted-foreground mt-2 text-xs", children: t("viewFieldSecretsHelpText") })] }) }) })] })] }));
57
60
  };
package/constants.d.ts CHANGED
@@ -19,9 +19,6 @@ export declare const BULK_OPERATIONS_API_ROUTES: {
19
19
  export declare const ADMISSION_API_ROUTES: {
20
20
  readonly UNIT: "/api/v1/admission";
21
21
  };
22
- export declare const DOCUMENT_UPLOAD_API_ROUTES: {
23
- readonly UNIT: "/api/v1/document-upload";
24
- };
25
22
  export declare const STORAGE_WAKE_URL = "https://storage.edupilotpro.com/";
26
23
  export declare const CAMPUS_API_ROUTES: {
27
24
  readonly UNIT: "/api/v1/campus";
@@ -104,7 +101,6 @@ export declare const SUBJECT_API_ROUTES: {
104
101
  export declare const TEACHER_API_ROUTES: {
105
102
  readonly LIST: "/api/v1/teacher";
106
103
  readonly UNIT: "/api/v1/teacher";
107
- readonly AVATAR: "/api/v1/teacher-avatar";
108
104
  readonly BULK: "/api/v1/teacher/bulk";
109
105
  readonly BULK_STATUS: (jobId: string) => string;
110
106
  };
package/constants.js CHANGED
@@ -22,9 +22,6 @@ export const BULK_OPERATIONS_API_ROUTES = {
22
22
  export const ADMISSION_API_ROUTES = {
23
23
  UNIT: "/api/v1/admission",
24
24
  };
25
- export const DOCUMENT_UPLOAD_API_ROUTES = {
26
- UNIT: "/api/v1/document-upload",
27
- };
28
25
  export const STORAGE_WAKE_URL = "https://storage.edupilotpro.com/";
29
26
  export const CAMPUS_API_ROUTES = {
30
27
  UNIT: "/api/v1/campus",
@@ -107,7 +104,6 @@ export const SUBJECT_API_ROUTES = {
107
104
  export const TEACHER_API_ROUTES = {
108
105
  LIST: "/api/v1/teacher",
109
106
  UNIT: "/api/v1/teacher",
110
- AVATAR: "/api/v1/teacher-avatar",
111
107
  BULK: "/api/v1/teacher/bulk",
112
108
  BULK_STATUS: (jobId) => `/api/v1/teacher/bulk/${jobId}`,
113
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.5.37",
3
+ "version": "0.5.40",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",
@@ -65,6 +65,7 @@
65
65
  "@storybook/addon-onboarding": "^10.3.4",
66
66
  "@storybook/addon-vitest": "^10.3.4",
67
67
  "@storybook/nextjs-vite": "^10.3.4",
68
+ "@supabase/ssr": "^0",
68
69
  "@supabase/supabase-js": "^2.103.0",
69
70
  "@tailwindcss/forms": "^0.5.11",
70
71
  "@tailwindcss/postcss": "^4",