@appcorp/fusion-storybook 0.1.75 → 0.1.76

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.
@@ -27,6 +27,7 @@ import { createGenericModule } from "@react-pakistan/util-functions/factory/gene
27
27
  import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
28
28
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
29
29
  import { GENDER } from "../../type";
30
+ import { formatPhoneDisplay, normalizePhone } from "../../utils/phone-helpers";
30
31
  import { TEACHER_API_ROUTES, pageLimit } from "./constants";
31
32
  import { teacherFormValidation } from "./validate";
32
33
  import { getCachedTeachers, invalidateTeachersCache } from "./cache";
@@ -123,7 +124,7 @@ export const useTeacherModule = () => {
123
124
  city: state.city,
124
125
  country: state.country,
125
126
  dateOfBirth: state.dateOfBirth,
126
- emergencyPhone: state.emergencyPhone,
127
+ emergencyPhone: normalizePhone(state.emergencyPhone),
127
128
  enabled: state.enabled,
128
129
  experience: state.experience,
129
130
  firstName: state.firstName,
@@ -131,7 +132,7 @@ export const useTeacherModule = () => {
131
132
  id: state.id,
132
133
  joiningDate: state.joiningDate,
133
134
  lastName: state.lastName,
134
- phone: state.phone,
135
+ phone: normalizePhone(state.phone),
135
136
  postalCode: state.postalCode,
136
137
  qualification: state.qualification,
137
138
  schoolId,
@@ -203,9 +204,12 @@ export const useTeacherModule = () => {
203
204
  return;
204
205
  }
205
206
  if (data) {
207
+ const teacher = data;
206
208
  dispatch({
207
209
  type: TEACHER_ACTION_TYPES.SET_FORM_DATA,
208
- payload: { form: Object.assign(Object.assign({}, data), { filterEnabled: undefined }) },
210
+ payload: {
211
+ form: Object.assign(Object.assign({}, teacher), { phone: formatPhoneDisplay(teacher.phone) || "", emergencyPhone: formatPhoneDisplay(teacher.emergencyPhone) || "", filterEnabled: undefined }),
212
+ },
209
213
  });
210
214
  }
211
215
  }, [dispatch, showToast, t]);
@@ -412,7 +416,7 @@ export const useTeacherModule = () => {
412
416
  {
413
417
  enabled: true,
414
418
  handleOnClick: handleCreate,
415
- label: t("headerActionsAddTeacher"),
419
+ label: t("headerActionsAdd"),
416
420
  order: 2,
417
421
  },
418
422
  ], [handleCreate, handleFilters, handleMoreActions, t]);
@@ -424,16 +428,17 @@ export const useTeacherModule = () => {
424
428
  order: 1,
425
429
  },
426
430
  {
427
- enabled: true,
431
+ enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === true,
428
432
  handleOnClick: handleEdit,
429
433
  label: t("rowActionsEdit"),
430
434
  order: 2,
431
435
  },
432
436
  {
433
- enabled: false,
437
+ enabled: (row) => (row === null || row === void 0 ? void 0 : row.enabled) === false,
434
438
  handleOnClick: handleDelete,
435
439
  label: t("rowActionsDelete"),
436
440
  order: 3,
441
+ variant: "destructive",
437
442
  },
438
443
  {
439
444
  enabled: false,
@@ -7,6 +7,7 @@ import { Avatar, AvatarFallback, AvatarImage, } from "@appcorp/shadcn/components
7
7
  import { User, Phone, MapPin, Calendar, GraduationCap, CheckCircle2, XCircle, Briefcase, } from "lucide-react";
8
8
  import { useTranslations } from "next-intl";
9
9
  import { formatValue } from "../../utils/format-value";
10
+ import { formatPhoneDisplay } from "../../utils/phone-helpers";
10
11
  import { formatDate, DATE_FORMATS } from "@react-pakistan/util-functions";
11
12
  import { useTeacherModule } from "./context";
12
13
  export const TeacherView = () => {
@@ -21,7 +22,8 @@ export const TeacherView = () => {
21
22
  const last = (lastName === null || lastName === void 0 ? void 0 : lastName.charAt(0)) || "";
22
23
  return (first + last).toUpperCase() || "T";
23
24
  };
24
- return (_jsxs("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("basicInformation") })] }), _jsx(CardDescription, { children: t("teachersPersonalDetails") })] }), _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("profilePicture") }), _jsxs(Avatar, { className: "h-20 w-20", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: fullName }), _jsx(AvatarFallback, { className: "text-lg", children: getInitials() })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("teacherCode") }), _jsx("p", { className: "font-mono text-base", children: formatValue(teacherCode) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("name") }), _jsx("p", { className: "text-base", children: fullName })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("gender") }), _jsx("p", { className: "text-base", children: formatValue(gender) })] }), _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("dateOfBirth") })] }), _jsx("p", { className: "text-base", children: formatDateValue(dateOfBirth) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("status") }), _jsx("div", { className: "flex items-center gap-2", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-green-600" }), _jsx(Badge, { variant: "default", children: t("active") })] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-4 w-4 text-red-600" }), _jsx(Badge, { variant: "destructive", children: t("inactive") })] })) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("contactInformation") })] }), _jsx(CardDescription, { children: t("howToReachTheTeacher") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_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("phone") })] }), _jsx("p", { className: "text-base", children: formatValue(phone) })] }), _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("emergencyPhone") })] }), _jsx("p", { className: "text-base", children: formatValue(emergencyPhone) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(GraduationCap, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("professionalInformation") })] }), _jsx(CardDescription, { children: t("teachingCredentialsAndExperience") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("qualification") }), _jsx("p", { className: "text-base", children: formatValue(qualification) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("specialization") }), _jsx("p", { className: "text-base", children: formatValue(specialization) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Briefcase, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("experience") })] }), _jsx("p", { className: "text-base", children: experience
25
+ return (_jsxs("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("basicInformation") })] }), _jsx(CardDescription, { children: t("teachersPersonalDetails") })] }), _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("profilePicture") }), _jsxs(Avatar, { className: "h-20 w-20", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: fullName }), _jsx(AvatarFallback, { className: "text-lg", children: getInitials() })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("teacherCode") }), _jsx("p", { className: "font-mono text-base", children: formatValue(teacherCode) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("name") }), _jsx("p", { className: "text-base", children: fullName })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("gender") }), _jsx("p", { className: "text-base", children: formatValue(gender) })] }), _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("dateOfBirth") })] }), _jsx("p", { className: "text-base", children: formatDateValue(dateOfBirth) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("status") }), _jsx("div", { className: "flex items-center gap-2", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-green-600" }), _jsx(Badge, { variant: "default", children: t("active") })] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-4 w-4 text-red-600" }), _jsx(Badge, { variant: "destructive", children: t("inactive") })] })) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("contactInformation") })] }), _jsx(CardDescription, { children: t("howToReachTheTeacher") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_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("phone") })] }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(phone) || formatValue(phone) })] }), _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("emergencyPhone") })] }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(emergencyPhone) ||
26
+ formatValue(emergencyPhone) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(GraduationCap, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("professionalInformation") })] }), _jsx(CardDescription, { children: t("teachingCredentialsAndExperience") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("qualification") }), _jsx("p", { className: "text-base", children: formatValue(qualification) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("specialization") }), _jsx("p", { className: "text-base", children: formatValue(specialization) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Briefcase, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("experience") })] }), _jsx("p", { className: "text-base", children: experience
25
27
  ? t("experienceYears", { years: experience })
26
28
  : "\u2014" })] }), _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("joiningDate") })] }), _jsx("p", { className: "text-base", children: formatDateValue(joiningDate) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MapPin, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("addressInformation") })] }), _jsx(CardDescription, { children: t("teachersResidentialAddress") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("address") }), _jsx("p", { className: "text-base", children: formatValue(address) })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("city") }), _jsx("p", { className: "text-base", children: formatValue(city) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("stateProvince") }), _jsx("p", { className: "text-base", children: formatValue(stateValue) })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("country") }), _jsx("p", { className: "text-base", children: formatValue(country) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("postalCode") }), _jsx("p", { className: "text-base", children: formatValue(postalCode) })] })] })] }) })] }), bio && (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsx(CardTitle, { className: "text-lg", children: t("biography") }), _jsx(CardDescription, { children: t("aboutTheTeacher") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("p", { className: "text-base", children: bio }) })] }))] }));
27
29
  };
@@ -34,6 +34,7 @@ import { invalidateWorkspaceUsersCache } from "../workspace-user/cache";
34
34
  import { blobToWebP } from "webp-converter-browser";
35
35
  import { supabasePublicStorageUrl } from "../../constants";
36
36
  import { toastNetworkError } from "../../utils/toast-network-error";
37
+ import { formatPhoneDisplay, normalizePhone } from "../../utils/phone-helpers";
37
38
  // ============================================================================
38
39
  // 1.1 DRAWER TYPES
39
40
  // ============================================================================
@@ -110,7 +111,7 @@ export const useUserModule = () => {
110
111
  id: state.id,
111
112
  name: (state.name || "").trim(),
112
113
  password: state.password,
113
- phone: (state.phone || "").trim(),
114
+ phone: normalizePhone(state.phone),
114
115
  userRole: state.userRole,
115
116
  workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id,
116
117
  }), [state, workspace === null || workspace === void 0 ? void 0 : workspace.id]);
@@ -203,7 +204,7 @@ export const useUserModule = () => {
203
204
  id: user.id,
204
205
  name: user.name || "",
205
206
  email: user.email,
206
- phone: user.phone || "",
207
+ phone: formatPhoneDisplay(user.phone) || "",
207
208
  avatar: user.avatar || "",
208
209
  enabled: user.enabled,
209
210
  userRole: parsedUserRole,
@@ -7,6 +7,7 @@ import { Separator } from "@appcorp/shadcn/components/ui/separator";
7
7
  import { Avatar, AvatarFallback, AvatarImage, } from "@appcorp/shadcn/components/ui/avatar";
8
8
  import { User, Phone, Mail, CheckCircle2, XCircle } from "lucide-react";
9
9
  import { formatValue } from "../../utils/format-value";
10
+ import { formatPhoneDisplay } from "../../utils/phone-helpers";
10
11
  const getInitials = (fullName) => {
11
12
  if (!fullName)
12
13
  return "U";
@@ -20,5 +21,5 @@ const getInitials = (fullName) => {
20
21
  export const UserView = () => {
21
22
  const { state } = useUserModule();
22
23
  const { avatar, email, enabled, name, phone } = state;
23
- 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: "User Information" })] }), _jsx(CardDescription, { children: "User account details" })] }), _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: "Profile Picture" }), _jsxs(Avatar, { className: "h-20 w-20", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: name || "User" }), _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: "Name" }), _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: "Email Address" })] }), _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: "Phone Number" })] }), _jsx("p", { className: "text-base", children: formatValue(phone) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: "Status" }), _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 ? "Active" : "Inactive"] })] })] }) })] }) }));
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: "User Information" })] }), _jsx(CardDescription, { children: "User account details" })] }), _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: "Profile Picture" }), _jsxs(Avatar, { className: "h-20 w-20", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: name || "User" }), _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: "Name" }), _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: "Email Address" })] }), _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: "Phone Number" })] }), _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: "Status" }), _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 ? "Active" : "Inactive"] })] })] }) })] }) }));
24
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.75",
3
+ "version": "0.1.76",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",