analytica-frontend-lib 1.1.55 → 1.1.57

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/dist/index.d.mts CHANGED
@@ -48,8 +48,8 @@ export { useApiConfig } from './Auth/useApiConfig/index.mjs';
48
48
  export { Quiz, QuizAlternative, QuizConnectDots, QuizContent, QuizDissertative, QuizFooter, QuizHeader, QuizHeaderResult, QuizImageQuestion, QuizListResult, QuizListResultByMateria, QuizMultipleChoice, QuizQuestionList, QuizResultHeaderTitle, QuizResultPerformance, QuizResultTitle, QuizTitle, QuizTrueOrFalse, getStatusBadge } from './Quiz/index.mjs';
49
49
  export { ANSWER_STATUS, Activity, Lesson, QUESTION_DIFFICULTY, QUESTION_STATUS, QUESTION_TYPE, Question, QuestionResult, QuizState, SUBTYPE_ENUM, Simulated, UserAnswerItem, useQuizStore } from './Quiz/useQuizStore/index.mjs';
50
50
  export { default as LoadingModal } from './LoadingModal/index.mjs';
51
- import { N as NotificationApiClient, a as Notification, F as FetchNotificationsParams, b as NotificationGroup, c as NotificationEntityType, d as NotificationType } from './NotificationCard-kGUKNOqT.mjs';
52
- export { B as BackendNotification, g as BackendNotificationsResponse, e as NotificationCard, f as NotificationItem, h as NotificationsResponse } from './NotificationCard-kGUKNOqT.mjs';
51
+ import { N as NotificationApiClient, a as Notification, F as FetchNotificationsParams, b as NotificationGroup, c as NotificationEntityType, d as NotificationType } from './NotificationCard-DpSGkWEa.mjs';
52
+ export { B as BackendNotification, g as BackendNotificationsResponse, e as NotificationCard, f as NotificationItem, h as NotificationsResponse } from './NotificationCard-DpSGkWEa.mjs';
53
53
  export { ThemeToggle } from './ThemeToggle/index.mjs';
54
54
  import 'react/jsx-runtime';
55
55
 
@@ -297,6 +297,7 @@ declare const createUseNotifications: (apiClient: NotificationApiClient) => () =
297
297
  type: NotificationType;
298
298
  isRead: boolean;
299
299
  createdAt: Date;
300
+ actionLink?: string | null;
300
301
  sender?: {
301
302
  id: string;
302
303
  user: {
@@ -364,6 +365,7 @@ declare const createNotificationsHook: (apiClient: NotificationApiClient) => ()
364
365
  type: NotificationType;
365
366
  isRead: boolean;
366
367
  createdAt: Date;
368
+ actionLink?: string | null;
367
369
  sender?: {
368
370
  id: string;
369
371
  user: {
package/dist/index.d.ts CHANGED
@@ -48,8 +48,8 @@ export { useApiConfig } from './Auth/useApiConfig/index.js';
48
48
  export { Quiz, QuizAlternative, QuizConnectDots, QuizContent, QuizDissertative, QuizFooter, QuizHeader, QuizHeaderResult, QuizImageQuestion, QuizListResult, QuizListResultByMateria, QuizMultipleChoice, QuizQuestionList, QuizResultHeaderTitle, QuizResultPerformance, QuizResultTitle, QuizTitle, QuizTrueOrFalse, getStatusBadge } from './Quiz/index.js';
49
49
  export { ANSWER_STATUS, Activity, Lesson, QUESTION_DIFFICULTY, QUESTION_STATUS, QUESTION_TYPE, Question, QuestionResult, QuizState, SUBTYPE_ENUM, Simulated, UserAnswerItem, useQuizStore } from './Quiz/useQuizStore/index.js';
50
50
  export { default as LoadingModal } from './LoadingModal/index.js';
51
- import { N as NotificationApiClient, a as Notification, F as FetchNotificationsParams, b as NotificationGroup, c as NotificationEntityType, d as NotificationType } from './NotificationCard-kGUKNOqT.js';
52
- export { B as BackendNotification, g as BackendNotificationsResponse, e as NotificationCard, f as NotificationItem, h as NotificationsResponse } from './NotificationCard-kGUKNOqT.js';
51
+ import { N as NotificationApiClient, a as Notification, F as FetchNotificationsParams, b as NotificationGroup, c as NotificationEntityType, d as NotificationType } from './NotificationCard-DpSGkWEa.js';
52
+ export { B as BackendNotification, g as BackendNotificationsResponse, e as NotificationCard, f as NotificationItem, h as NotificationsResponse } from './NotificationCard-DpSGkWEa.js';
53
53
  export { ThemeToggle } from './ThemeToggle/index.js';
54
54
  import 'react/jsx-runtime';
55
55
 
@@ -297,6 +297,7 @@ declare const createUseNotifications: (apiClient: NotificationApiClient) => () =
297
297
  type: NotificationType;
298
298
  isRead: boolean;
299
299
  createdAt: Date;
300
+ actionLink?: string | null;
300
301
  sender?: {
301
302
  id: string;
302
303
  user: {
@@ -364,6 +365,7 @@ declare const createNotificationsHook: (apiClient: NotificationApiClient) => ()
364
365
  type: NotificationType;
365
366
  isRead: boolean;
366
367
  createdAt: Date;
368
+ actionLink?: string | null;
367
369
  sender?: {
368
370
  id: string;
369
371
  user: {
package/dist/index.js CHANGED
@@ -10726,7 +10726,8 @@ var mapBackendNotification = (backendNotification) => {
10726
10726
  entityId: backendNotification.entityId,
10727
10727
  sender: backendNotification.sender,
10728
10728
  activity: backendNotification.activity,
10729
- goal: backendNotification.goal
10729
+ goal: backendNotification.goal,
10730
+ actionLink: backendNotification.actionLink ?? null
10730
10731
  };
10731
10732
  };
10732
10733
  var groupNotificationsByTime = (notifications) => {
@@ -10920,6 +10921,9 @@ var createNotificationStore = (apiClient) => {
10920
10921
  );
10921
10922
  };
10922
10923
 
10924
+ // src/assets/img/mock-content.png
10925
+ var mock_content_default = "./mock-content-K2CDVG6P.png";
10926
+
10923
10927
  // src/components/NotificationCard/NotificationCard.tsx
10924
10928
  var import_jsx_runtime42 = require("react/jsx-runtime");
10925
10929
  var NotificationEmpty = ({
@@ -11049,10 +11053,23 @@ var NotificationList = ({
11049
11053
  onMarkAsReadById,
11050
11054
  onDeleteById,
11051
11055
  onNavigateById,
11056
+ onGlobalNotificationClick,
11052
11057
  getActionLabel,
11053
11058
  renderEmpty,
11054
- className
11059
+ className,
11060
+ emptyStateImage
11055
11061
  }) => {
11062
+ const [globalNotificationModal, setGlobalNotificationModal] = (0, import_react32.useState)({ isOpen: false, notification: null });
11063
+ const handleGlobalNotificationClick = (notification) => {
11064
+ if (onGlobalNotificationClick) {
11065
+ onGlobalNotificationClick(notification);
11066
+ } else {
11067
+ setGlobalNotificationModal({
11068
+ isOpen: true,
11069
+ notification
11070
+ });
11071
+ }
11072
+ };
11056
11073
  if (error) {
11057
11074
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [
11058
11075
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "text-sm text-error-600", children: error }),
@@ -11081,28 +11098,59 @@ var NotificationList = ({
11081
11098
  if (!groupedNotifications || groupedNotifications.length === 0) {
11082
11099
  return renderEmpty ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(NotificationEmpty, {});
11083
11100
  }
11084
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: cn("flex flex-col gap-0 w-full", className), children: groupedNotifications.map((group, idx) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-col", children: [
11085
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
11086
- group.notifications.map((notification) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11087
- SingleNotificationCard,
11101
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: cn("flex flex-col gap-0 w-full", className), children: [
11102
+ groupedNotifications.map((group, idx) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-col", children: [
11103
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
11104
+ group.notifications.map((notification) => {
11105
+ const isGlobalNotification = !notification.entityType && !notification.entityId && !notification.activity && !notification.goal;
11106
+ let navigationHandler;
11107
+ if (isGlobalNotification) {
11108
+ navigationHandler = () => handleGlobalNotificationClick(notification);
11109
+ } else if (notification.entityType && notification.entityId && onNavigateById) {
11110
+ navigationHandler = () => onNavigateById(
11111
+ notification.entityType ?? void 0,
11112
+ notification.entityId ?? void 0
11113
+ );
11114
+ }
11115
+ let actionLabel;
11116
+ if (isGlobalNotification) {
11117
+ actionLabel = getActionLabel?.(void 0);
11118
+ } else {
11119
+ actionLabel = getActionLabel?.(
11120
+ notification.entityType ?? void 0
11121
+ );
11122
+ }
11123
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11124
+ SingleNotificationCard,
11125
+ {
11126
+ title: notification.title,
11127
+ message: notification.message,
11128
+ time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)),
11129
+ isRead: notification.isRead,
11130
+ onMarkAsRead: () => onMarkAsReadById?.(notification.id),
11131
+ onDelete: () => onDeleteById?.(notification.id),
11132
+ onNavigate: navigationHandler,
11133
+ actionLabel
11134
+ },
11135
+ notification.id
11136
+ );
11137
+ })
11138
+ ] }, `${group.label}-${idx}`)),
11139
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11140
+ Modal_default,
11088
11141
  {
11089
- title: notification.title,
11090
- message: notification.message,
11091
- time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)),
11092
- isRead: notification.isRead,
11093
- onMarkAsRead: () => onMarkAsReadById?.(notification.id),
11094
- onDelete: () => onDeleteById?.(notification.id),
11095
- onNavigate: notification.entityType && notification.entityId && onNavigateById ? () => onNavigateById(
11096
- notification.entityType ?? void 0,
11097
- notification.entityId ?? void 0
11098
- ) : void 0,
11099
- actionLabel: getActionLabel?.(
11100
- notification.entityType ?? void 0
11101
- )
11102
- },
11103
- notification.id
11104
- ))
11105
- ] }, `${group.label}-${idx}`)) });
11142
+ isOpen: globalNotificationModal.isOpen,
11143
+ onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
11144
+ title: globalNotificationModal.notification?.title || "",
11145
+ description: globalNotificationModal.notification?.message || "",
11146
+ variant: "activity",
11147
+ image: emptyStateImage || mock_content_default,
11148
+ actionLink: globalNotificationModal.notification?.actionLink || void 0,
11149
+ actionLabel: "Ver mais",
11150
+ size: "lg"
11151
+ }
11152
+ )
11153
+ ] });
11106
11154
  };
11107
11155
  var NotificationCenter = ({
11108
11156
  isActive,
@@ -11125,6 +11173,7 @@ var NotificationCenter = ({
11125
11173
  }) => {
11126
11174
  const { isMobile } = useMobile();
11127
11175
  const [isModalOpen, setIsModalOpen] = (0, import_react32.useState)(false);
11176
+ const [globalNotificationModal, setGlobalNotificationModal] = (0, import_react32.useState)({ isOpen: false, notification: null });
11128
11177
  const handleMobileClick = () => {
11129
11178
  setIsModalOpen(true);
11130
11179
  onFetchNotifications?.();
@@ -11137,10 +11186,6 @@ var NotificationCenter = ({
11137
11186
  onFetchNotifications?.();
11138
11187
  }
11139
11188
  }, [isActive, onFetchNotifications]);
11140
- const handleNavigate = (entityType, entityId, onCleanup) => {
11141
- onCleanup?.();
11142
- onNavigateById?.(entityType, entityId);
11143
- };
11144
11189
  const renderEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11145
11190
  NotificationEmpty,
11146
11191
  {
@@ -11191,13 +11236,20 @@ var NotificationCenter = ({
11191
11236
  onRetry,
11192
11237
  onMarkAsReadById,
11193
11238
  onDeleteById,
11194
- onNavigateById: (entityType, entityId) => handleNavigate(
11195
- entityType,
11196
- entityId,
11197
- () => setIsModalOpen(false)
11198
- ),
11239
+ onNavigateById: (entityType, entityId) => {
11240
+ setIsModalOpen(false);
11241
+ onNavigateById?.(entityType, entityId);
11242
+ },
11243
+ onGlobalNotificationClick: (notification) => {
11244
+ setIsModalOpen(false);
11245
+ setGlobalNotificationModal({
11246
+ isOpen: true,
11247
+ notification
11248
+ });
11249
+ },
11199
11250
  getActionLabel,
11200
- renderEmpty: renderEmptyState
11251
+ renderEmpty: renderEmptyState,
11252
+ emptyStateImage
11201
11253
  }
11202
11254
  ) })
11203
11255
  ] })
@@ -11205,56 +11257,85 @@ var NotificationCenter = ({
11205
11257
  )
11206
11258
  ] });
11207
11259
  }
11208
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(DropdownMenu_default, { children: [
11209
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11210
- IconButton_default,
11211
- {
11212
- active: isActive,
11213
- onClick: handleDesktopClick,
11214
- icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11215
- import_phosphor_react22.Bell,
11216
- {
11217
- size: 24,
11218
- className: isActive ? "text-primary-950" : "text-primary"
11219
- }
11220
- ),
11221
- className
11222
- }
11223
- ) }),
11224
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11225
- DropdownMenuContent,
11226
- {
11227
- className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
11228
- side: "bottom",
11229
- align: "end",
11230
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-col", children: [
11231
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "px-4 py-3 border-b border-border-200", children: [
11232
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(NotificationHeader, { unreadCount, variant: "dropdown" }),
11233
- unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11234
- "button",
11235
- {
11236
- type: "button",
11237
- onClick: onMarkAllAsRead,
11238
- className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2",
11239
- children: "Marcar todas como lidas"
11240
- }
11241
- )
11242
- ] }),
11243
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11244
- NotificationList,
11260
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
11261
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(DropdownMenu_default, { children: [
11262
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11263
+ IconButton_default,
11264
+ {
11265
+ active: isActive,
11266
+ onClick: handleDesktopClick,
11267
+ icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11268
+ import_phosphor_react22.Bell,
11245
11269
  {
11246
- groupedNotifications,
11247
- loading,
11248
- error,
11249
- onRetry,
11250
- onMarkAsReadById,
11251
- onDeleteById,
11252
- onNavigateById: (entityType, entityId) => handleNavigate(entityType, entityId),
11253
- getActionLabel,
11254
- renderEmpty: renderEmptyState
11270
+ size: 24,
11271
+ className: isActive ? "text-primary-950" : "text-primary"
11255
11272
  }
11256
- ) })
11257
- ] })
11273
+ ),
11274
+ className
11275
+ }
11276
+ ) }),
11277
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11278
+ DropdownMenuContent,
11279
+ {
11280
+ className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
11281
+ side: "bottom",
11282
+ align: "end",
11283
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-col", children: [
11284
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "px-4 py-3 border-b border-border-200", children: [
11285
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11286
+ NotificationHeader,
11287
+ {
11288
+ unreadCount,
11289
+ variant: "dropdown"
11290
+ }
11291
+ ),
11292
+ unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11293
+ "button",
11294
+ {
11295
+ type: "button",
11296
+ onClick: onMarkAllAsRead,
11297
+ className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2",
11298
+ children: "Marcar todas como lidas"
11299
+ }
11300
+ )
11301
+ ] }),
11302
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11303
+ NotificationList,
11304
+ {
11305
+ groupedNotifications,
11306
+ loading,
11307
+ error,
11308
+ onRetry,
11309
+ onMarkAsReadById,
11310
+ onDeleteById,
11311
+ onNavigateById,
11312
+ onGlobalNotificationClick: (notification) => {
11313
+ setGlobalNotificationModal({
11314
+ isOpen: true,
11315
+ notification
11316
+ });
11317
+ },
11318
+ getActionLabel,
11319
+ renderEmpty: renderEmptyState,
11320
+ emptyStateImage
11321
+ }
11322
+ ) })
11323
+ ] })
11324
+ }
11325
+ )
11326
+ ] }),
11327
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
11328
+ Modal_default,
11329
+ {
11330
+ isOpen: globalNotificationModal.isOpen,
11331
+ onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
11332
+ title: globalNotificationModal.notification?.title || "",
11333
+ variant: "activity",
11334
+ description: globalNotificationModal.notification?.message,
11335
+ image: emptyStateImage || mock_content_default,
11336
+ actionLink: globalNotificationModal.notification?.actionLink || void 0,
11337
+ actionLabel: "Ver mais",
11338
+ size: "lg"
11258
11339
  }
11259
11340
  )
11260
11341
  ] });
@@ -11292,9 +11373,11 @@ var NotificationCard = (props) => {
11292
11373
  onMarkAsReadById: props.onMarkAsReadById,
11293
11374
  onDeleteById: props.onDeleteById,
11294
11375
  onNavigateById: props.onNavigateById,
11376
+ onGlobalNotificationClick: props.onGlobalNotificationClick,
11295
11377
  getActionLabel: props.getActionLabel,
11296
11378
  renderEmpty: props.renderEmpty,
11297
- className: props.className
11379
+ className: props.className,
11380
+ emptyStateImage: props.emptyStateImage
11298
11381
  }
11299
11382
  );
11300
11383
  case "center":