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.
@@ -1396,6 +1396,9 @@ var formatTimeAgo = (date) => {
1396
1396
  return new Date(date).toLocaleDateString("pt-BR");
1397
1397
  };
1398
1398
 
1399
+ // src/assets/img/mock-content.png
1400
+ var mock_content_default = "../mock-content-K2CDVG6P.png";
1401
+
1399
1402
  // src/components/NotificationCard/NotificationCard.tsx
1400
1403
  import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1401
1404
  var NotificationEmpty = ({
@@ -1525,10 +1528,23 @@ var NotificationList = ({
1525
1528
  onMarkAsReadById,
1526
1529
  onDeleteById,
1527
1530
  onNavigateById,
1531
+ onGlobalNotificationClick,
1528
1532
  getActionLabel,
1529
1533
  renderEmpty,
1530
- className
1534
+ className,
1535
+ emptyStateImage
1531
1536
  }) => {
1537
+ const [globalNotificationModal, setGlobalNotificationModal] = useState5({ isOpen: false, notification: null });
1538
+ const handleGlobalNotificationClick = (notification) => {
1539
+ if (onGlobalNotificationClick) {
1540
+ onGlobalNotificationClick(notification);
1541
+ } else {
1542
+ setGlobalNotificationModal({
1543
+ isOpen: true,
1544
+ notification
1545
+ });
1546
+ }
1547
+ };
1532
1548
  if (error) {
1533
1549
  return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [
1534
1550
  /* @__PURE__ */ jsx10("p", { className: "text-sm text-error-600", children: error }),
@@ -1557,28 +1573,59 @@ var NotificationList = ({
1557
1573
  if (!groupedNotifications || groupedNotifications.length === 0) {
1558
1574
  return renderEmpty ? /* @__PURE__ */ jsx10("div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ jsx10(NotificationEmpty, {});
1559
1575
  }
1560
- return /* @__PURE__ */ jsx10("div", { className: cn("flex flex-col gap-0 w-full", className), children: groupedNotifications.map((group, idx) => /* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
1561
- /* @__PURE__ */ jsx10("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ jsx10("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
1562
- group.notifications.map((notification) => /* @__PURE__ */ jsx10(
1563
- SingleNotificationCard,
1576
+ return /* @__PURE__ */ jsxs7("div", { className: cn("flex flex-col gap-0 w-full", className), children: [
1577
+ groupedNotifications.map((group, idx) => /* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
1578
+ /* @__PURE__ */ jsx10("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ jsx10("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
1579
+ group.notifications.map((notification) => {
1580
+ const isGlobalNotification = !notification.entityType && !notification.entityId && !notification.activity && !notification.goal;
1581
+ let navigationHandler;
1582
+ if (isGlobalNotification) {
1583
+ navigationHandler = () => handleGlobalNotificationClick(notification);
1584
+ } else if (notification.entityType && notification.entityId && onNavigateById) {
1585
+ navigationHandler = () => onNavigateById(
1586
+ notification.entityType ?? void 0,
1587
+ notification.entityId ?? void 0
1588
+ );
1589
+ }
1590
+ let actionLabel;
1591
+ if (isGlobalNotification) {
1592
+ actionLabel = getActionLabel?.(void 0);
1593
+ } else {
1594
+ actionLabel = getActionLabel?.(
1595
+ notification.entityType ?? void 0
1596
+ );
1597
+ }
1598
+ return /* @__PURE__ */ jsx10(
1599
+ SingleNotificationCard,
1600
+ {
1601
+ title: notification.title,
1602
+ message: notification.message,
1603
+ time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)),
1604
+ isRead: notification.isRead,
1605
+ onMarkAsRead: () => onMarkAsReadById?.(notification.id),
1606
+ onDelete: () => onDeleteById?.(notification.id),
1607
+ onNavigate: navigationHandler,
1608
+ actionLabel
1609
+ },
1610
+ notification.id
1611
+ );
1612
+ })
1613
+ ] }, `${group.label}-${idx}`)),
1614
+ /* @__PURE__ */ jsx10(
1615
+ Modal_default,
1564
1616
  {
1565
- title: notification.title,
1566
- message: notification.message,
1567
- time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)),
1568
- isRead: notification.isRead,
1569
- onMarkAsRead: () => onMarkAsReadById?.(notification.id),
1570
- onDelete: () => onDeleteById?.(notification.id),
1571
- onNavigate: notification.entityType && notification.entityId && onNavigateById ? () => onNavigateById(
1572
- notification.entityType ?? void 0,
1573
- notification.entityId ?? void 0
1574
- ) : void 0,
1575
- actionLabel: getActionLabel?.(
1576
- notification.entityType ?? void 0
1577
- )
1578
- },
1579
- notification.id
1580
- ))
1581
- ] }, `${group.label}-${idx}`)) });
1617
+ isOpen: globalNotificationModal.isOpen,
1618
+ onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
1619
+ title: globalNotificationModal.notification?.title || "",
1620
+ description: globalNotificationModal.notification?.message || "",
1621
+ variant: "activity",
1622
+ image: emptyStateImage || mock_content_default,
1623
+ actionLink: globalNotificationModal.notification?.actionLink || void 0,
1624
+ actionLabel: "Ver mais",
1625
+ size: "lg"
1626
+ }
1627
+ )
1628
+ ] });
1582
1629
  };
1583
1630
  var NotificationCenter = ({
1584
1631
  isActive,
@@ -1601,6 +1648,7 @@ var NotificationCenter = ({
1601
1648
  }) => {
1602
1649
  const { isMobile } = useMobile();
1603
1650
  const [isModalOpen, setIsModalOpen] = useState5(false);
1651
+ const [globalNotificationModal, setGlobalNotificationModal] = useState5({ isOpen: false, notification: null });
1604
1652
  const handleMobileClick = () => {
1605
1653
  setIsModalOpen(true);
1606
1654
  onFetchNotifications?.();
@@ -1613,10 +1661,6 @@ var NotificationCenter = ({
1613
1661
  onFetchNotifications?.();
1614
1662
  }
1615
1663
  }, [isActive, onFetchNotifications]);
1616
- const handleNavigate = (entityType, entityId, onCleanup) => {
1617
- onCleanup?.();
1618
- onNavigateById?.(entityType, entityId);
1619
- };
1620
1664
  const renderEmptyState = () => /* @__PURE__ */ jsx10(
1621
1665
  NotificationEmpty,
1622
1666
  {
@@ -1667,13 +1711,20 @@ var NotificationCenter = ({
1667
1711
  onRetry,
1668
1712
  onMarkAsReadById,
1669
1713
  onDeleteById,
1670
- onNavigateById: (entityType, entityId) => handleNavigate(
1671
- entityType,
1672
- entityId,
1673
- () => setIsModalOpen(false)
1674
- ),
1714
+ onNavigateById: (entityType, entityId) => {
1715
+ setIsModalOpen(false);
1716
+ onNavigateById?.(entityType, entityId);
1717
+ },
1718
+ onGlobalNotificationClick: (notification) => {
1719
+ setIsModalOpen(false);
1720
+ setGlobalNotificationModal({
1721
+ isOpen: true,
1722
+ notification
1723
+ });
1724
+ },
1675
1725
  getActionLabel,
1676
- renderEmpty: renderEmptyState
1726
+ renderEmpty: renderEmptyState,
1727
+ emptyStateImage
1677
1728
  }
1678
1729
  ) })
1679
1730
  ] })
@@ -1681,56 +1732,85 @@ var NotificationCenter = ({
1681
1732
  )
1682
1733
  ] });
1683
1734
  }
1684
- return /* @__PURE__ */ jsxs7(DropdownMenu_default, { children: [
1685
- /* @__PURE__ */ jsx10(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ jsx10(
1686
- IconButton_default,
1687
- {
1688
- active: isActive,
1689
- onClick: handleDesktopClick,
1690
- icon: /* @__PURE__ */ jsx10(
1691
- Bell2,
1692
- {
1693
- size: 24,
1694
- className: isActive ? "text-primary-950" : "text-primary"
1695
- }
1696
- ),
1697
- className
1698
- }
1699
- ) }),
1700
- /* @__PURE__ */ jsx10(
1701
- DropdownMenuContent,
1702
- {
1703
- className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
1704
- side: "bottom",
1705
- align: "end",
1706
- children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
1707
- /* @__PURE__ */ jsxs7("div", { className: "px-4 py-3 border-b border-border-200", children: [
1708
- /* @__PURE__ */ jsx10(NotificationHeader, { unreadCount, variant: "dropdown" }),
1709
- unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ jsx10(
1710
- "button",
1711
- {
1712
- type: "button",
1713
- onClick: onMarkAllAsRead,
1714
- className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2",
1715
- children: "Marcar todas como lidas"
1716
- }
1717
- )
1718
- ] }),
1719
- /* @__PURE__ */ jsx10("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ jsx10(
1720
- NotificationList,
1735
+ return /* @__PURE__ */ jsxs7(Fragment2, { children: [
1736
+ /* @__PURE__ */ jsxs7(DropdownMenu_default, { children: [
1737
+ /* @__PURE__ */ jsx10(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ jsx10(
1738
+ IconButton_default,
1739
+ {
1740
+ active: isActive,
1741
+ onClick: handleDesktopClick,
1742
+ icon: /* @__PURE__ */ jsx10(
1743
+ Bell2,
1721
1744
  {
1722
- groupedNotifications,
1723
- loading,
1724
- error,
1725
- onRetry,
1726
- onMarkAsReadById,
1727
- onDeleteById,
1728
- onNavigateById: (entityType, entityId) => handleNavigate(entityType, entityId),
1729
- getActionLabel,
1730
- renderEmpty: renderEmptyState
1745
+ size: 24,
1746
+ className: isActive ? "text-primary-950" : "text-primary"
1731
1747
  }
1732
- ) })
1733
- ] })
1748
+ ),
1749
+ className
1750
+ }
1751
+ ) }),
1752
+ /* @__PURE__ */ jsx10(
1753
+ DropdownMenuContent,
1754
+ {
1755
+ className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
1756
+ side: "bottom",
1757
+ align: "end",
1758
+ children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
1759
+ /* @__PURE__ */ jsxs7("div", { className: "px-4 py-3 border-b border-border-200", children: [
1760
+ /* @__PURE__ */ jsx10(
1761
+ NotificationHeader,
1762
+ {
1763
+ unreadCount,
1764
+ variant: "dropdown"
1765
+ }
1766
+ ),
1767
+ unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ jsx10(
1768
+ "button",
1769
+ {
1770
+ type: "button",
1771
+ onClick: onMarkAllAsRead,
1772
+ className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2",
1773
+ children: "Marcar todas como lidas"
1774
+ }
1775
+ )
1776
+ ] }),
1777
+ /* @__PURE__ */ jsx10("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ jsx10(
1778
+ NotificationList,
1779
+ {
1780
+ groupedNotifications,
1781
+ loading,
1782
+ error,
1783
+ onRetry,
1784
+ onMarkAsReadById,
1785
+ onDeleteById,
1786
+ onNavigateById,
1787
+ onGlobalNotificationClick: (notification) => {
1788
+ setGlobalNotificationModal({
1789
+ isOpen: true,
1790
+ notification
1791
+ });
1792
+ },
1793
+ getActionLabel,
1794
+ renderEmpty: renderEmptyState,
1795
+ emptyStateImage
1796
+ }
1797
+ ) })
1798
+ ] })
1799
+ }
1800
+ )
1801
+ ] }),
1802
+ /* @__PURE__ */ jsx10(
1803
+ Modal_default,
1804
+ {
1805
+ isOpen: globalNotificationModal.isOpen,
1806
+ onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
1807
+ title: globalNotificationModal.notification?.title || "",
1808
+ variant: "activity",
1809
+ description: globalNotificationModal.notification?.message,
1810
+ image: emptyStateImage || mock_content_default,
1811
+ actionLink: globalNotificationModal.notification?.actionLink || void 0,
1812
+ actionLabel: "Ver mais",
1813
+ size: "lg"
1734
1814
  }
1735
1815
  )
1736
1816
  ] });
@@ -1768,9 +1848,11 @@ var NotificationCard = (props) => {
1768
1848
  onMarkAsReadById: props.onMarkAsReadById,
1769
1849
  onDeleteById: props.onDeleteById,
1770
1850
  onNavigateById: props.onNavigateById,
1851
+ onGlobalNotificationClick: props.onGlobalNotificationClick,
1771
1852
  getActionLabel: props.getActionLabel,
1772
1853
  renderEmpty: props.renderEmpty,
1773
- className: props.className
1854
+ className: props.className,
1855
+ emptyStateImage: props.emptyStateImage
1774
1856
  }
1775
1857
  );
1776
1858
  case "center":
@@ -1803,9 +1885,11 @@ var LegacyNotificationCard = (props) => {
1803
1885
  onMarkAsReadById: props.onMarkAsReadById,
1804
1886
  onDeleteById: props.onDeleteById,
1805
1887
  onNavigateById: props.onNavigateById,
1888
+ onGlobalNotificationClick: props.onGlobalNotificationClick,
1806
1889
  getActionLabel: props.getActionLabel,
1807
1890
  renderEmpty: props.renderEmpty,
1808
- className: props.className
1891
+ className: props.className,
1892
+ emptyStateImage: props.emptyStateImage
1809
1893
  }
1810
1894
  );
1811
1895
  }