@edifice.io/react 2.6.2-develop-b2school.20260820173935 → 2.6.2-develop-integration-crna.20260823185851

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 (32) hide show
  1. package/dist/components/Layout/Layout.js +5 -3
  2. package/dist/modules/homepage/components/Favorites/Favorites.js +6 -3
  3. package/dist/modules/homepage/components/Header/Header.js +4 -11
  4. package/dist/modules/homepage/components/Notifications/NotificationItem.js +5 -4
  5. package/dist/modules/homepage/components/Notifications/NotificationList.d.ts +7 -1
  6. package/dist/modules/homepage/components/Notifications/NotificationList.js +8 -1
  7. package/dist/modules/homepage/components/Notifications/NotificationListContainer.js +4 -1
  8. package/dist/modules/homepage/components/Notifications/components/CommonNotificationItem.d.ts +2 -1
  9. package/dist/modules/homepage/components/Notifications/components/CommonNotificationItem.js +14 -10
  10. package/dist/modules/homepage/components/Notifications/components/NotificationFilterMenu.d.ts +16 -0
  11. package/dist/modules/homepage/components/Notifications/components/NotificationFilterMenu.js +29 -0
  12. package/dist/modules/homepage/components/Notifications/components/NotificationFilterModal.d.ts +18 -0
  13. package/dist/modules/homepage/components/Notifications/components/NotificationFilterModal.js +67 -0
  14. package/dist/modules/homepage/components/Notifications/components/NotificationOptionsMenu.d.ts +12 -0
  15. package/dist/modules/homepage/components/Notifications/components/NotificationOptionsMenu.js +42 -0
  16. package/dist/modules/homepage/components/Notifications/components/ReportNotificationModal.d.ts +13 -0
  17. package/dist/modules/homepage/components/Notifications/components/ReportNotificationModal.js +31 -0
  18. package/dist/modules/homepage/components/Notifications/components/SystemNotificationItem.d.ts +3 -1
  19. package/dist/modules/homepage/components/Notifications/components/SystemNotificationItem.js +3 -2
  20. package/dist/modules/homepage/components/Notifications/components/UserNotificationItem.d.ts +3 -1
  21. package/dist/modules/homepage/components/Notifications/components/UserNotificationItem.js +3 -2
  22. package/dist/modules/homepage/components/Notifications/components/notificationAdapter.d.ts +1 -0
  23. package/dist/modules/homepage/components/Notifications/components/notificationAdapter.js +1 -0
  24. package/dist/modules/homepage/components/Notifications/hooks/useNotificationList.d.ts +5 -1
  25. package/dist/modules/homepage/components/Notifications/hooks/useNotificationList.js +22 -2
  26. package/dist/modules/homepage/components/Notifications/services/api/index.d.ts +2 -0
  27. package/dist/modules/homepage/components/Notifications/services/api/notificationService.d.ts +8 -0
  28. package/dist/modules/homepage/components/Notifications/services/api/notificationService.js +12 -0
  29. package/dist/modules/homepage/components/Notifications/services/queries/notification.d.ts +13 -1
  30. package/dist/modules/homepage/components/Notifications/services/queries/notification.js +41 -4
  31. package/dist/modules/homepage/components/UserSpace/hooks/useProfileLinks.js +8 -18
  32. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Suspense, lazy } from "react";
3
3
  import clsx from "clsx";
4
4
  import { Toaster } from "react-hot-toast";
@@ -22,7 +22,7 @@ const HeaderV2 = /* @__PURE__ */ lazy(() => import("../../modules/homepage/compo
22
22
  }) => {
23
23
  const {
24
24
  theme
25
- } = useEdificeTheme(), override = useUiOverride("layout.header"), isHeaderV2 = (override == null ? void 0 : override.variant) === "v2", {
25
+ } = useEdificeTheme(), override = useUiOverride("layout.header"), isHeaderV2 = (override == null ? void 0 : override.variant) === "v2", backgroundOverride = useUiOverride("layout.background"), hasBackgroundImage = (backgroundOverride == null ? void 0 : backgroundOverride.variant) === "image", {
26
26
  toggleOverlay
27
27
  } = useOverlay(), {
28
28
  t
@@ -40,7 +40,9 @@ const HeaderV2 = /* @__PURE__ */ lazy(() => import("../../modules/homepage/compo
40
40
  }, className), renderHeader = headless ? null : isHeaderV2 ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(HeaderV2, { src: theme == null ? void 0 : theme.basePath, dataProduct: override == null ? void 0 : override.theme, onNotificationsClick: toggleOverlay }) }) : /* @__PURE__ */ jsx(Header, { is1d: theme == null ? void 0 : theme.is1d, src: theme == null ? void 0 : theme.basePath }), renderNotificationsOverlay = !headless && isHeaderV2 && /* @__PURE__ */ jsx(HeaderNotificationsOverlay, {}), renderCookies = showCookiesConsent && /* @__PURE__ */ jsx(Alert, { type: "info", className: "m-12 rgpd", isConfirm: !0, position: "bottom-right", button: /* @__PURE__ */ jsx(Button, { color: "tertiary", variant: "ghost", onClick: handleConsultCookies, children: t("rgpd.cookies.banner.button.consult") }), onClose: handleCloseCookiesConsent, children: t("rgpd.cookies.banner.text1") }), renderToaster = /* @__PURE__ */ jsx(Toaster, { containerClassName: "toaster-container", toastOptions: {
41
41
  position: "top-right"
42
42
  } });
43
- return /* @__PURE__ */ jsxs(Fragment, { children: [
43
+ return /* @__PURE__ */ jsxs("div", { className: clsx("layout", {
44
+ "layout-has-background-image": hasBackgroundImage
45
+ }), "data-product": hasBackgroundImage ? backgroundOverride == null ? void 0 : backgroundOverride.theme : void 0, children: [
44
46
  renderHeader,
45
47
  renderNotificationsOverlay,
46
48
  /* @__PURE__ */ jsx("main", { className: classes, ...restProps, children }),
@@ -1,4 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
2
3
  import { useTranslation } from "react-i18next";
3
4
  import illuEmptyFavorite from "@edifice.io/bootstrap/dist/images/homepage/illu-empty-favorite.svg";
4
5
  import SvgIconArrowRight from "../../../icons/components/IconArrowRight.js";
@@ -11,13 +12,15 @@ function Favorites({
11
12
  }) {
12
13
  const {
13
14
  t
14
- } = useTranslation(), getAppName = (app) => app.prefix && app.prefix.length > 1 ? t(app.prefix.substring(1)) : t(app.displayName) || "";
15
+ } = useTranslation(), getAppName = (app) => app.prefix && app.prefix.length > 1 ? t(app.prefix.substring(1)) : t(app.displayName) || "", visibleApps = useMemo(() => apps.filter((app) => app.display !== !1).sort((a, b) => getAppName(a).localeCompare(getAppName(b), void 0, {
16
+ sensitivity: "base"
17
+ })), [apps, t]);
15
18
  return /* @__PURE__ */ jsxs(HomeCard, { variant: "secondary", children: [
16
19
  /* @__PURE__ */ jsx(HomeCard.Header, { title: t("homepage.favorites.title", "Favoris"), actionLabel: t("homepage.favorites.all", "Mes applis"), onActionClick: onSeeAllClick, actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}) }),
17
- /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx("div", { className: "favorites-content", children: apps.length === 0 ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "12", children: [
20
+ /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx("div", { className: "favorites-content", children: visibleApps.length === 0 ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "12", children: [
18
21
  /* @__PURE__ */ jsx("img", { src: illuEmptyFavorite, alt: "", width: 50, height: 50 }),
19
22
  /* @__PURE__ */ jsx("span", { className: "favorites-empty-text", children: t("homepage.favorites.empty", "Ajouter des applications à vos favoris pour les retrouver ici et y accéder rapidement !") })
20
- ] }) : /* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "8 16", children: apps.map((app) => {
23
+ ] }) : /* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "8 16", children: visibleApps.map((app) => {
21
24
  const appName = getAppName(app), opensInNewTab = app.isExternal || app.target === "_blank";
22
25
  return /* @__PURE__ */ jsx("a", { href: app.address, "aria-label": appName, title: appName, target: opensInNewTab ? "_blank" : void 0, rel: opensInNewTab ? "noopener noreferrer" : void 0, children: /* @__PURE__ */ jsx(AppIcon, { app, size: "40", variant: "square" }) }, app.name);
23
26
  }) }) }) })
@@ -6,7 +6,6 @@ import { Navbar } from "../../../../components/Layout/components/Navbar.js";
6
6
  import { NavItem } from "../../../../components/Layout/components/NavItem.js";
7
7
  import { NavLink } from "../../../../components/Layout/components/NavLink.js";
8
8
  import useHeader from "../../../../components/Layout/hooks/useHeader.js";
9
- import SvgIconSetBackground from "../../../icons/components/IconSetBackground.js";
10
9
  import SvgIconCommunitiesBeta from "../../../icons/components/nav/IconCommunitiesBeta.js";
11
10
  import SvgIconDisconnect from "../../../icons/components/nav/IconDisconnect.js";
12
11
  import SvgIconHomeBeta from "../../../icons/components/nav/IconHomeBeta.js";
@@ -69,16 +68,10 @@ const Header = ({
69
68
  /* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsx(ButtonBeta, { leftIcon: /* @__PURE__ */ jsx(SvgIconNotificationBeta, {}), variant: "ghost", onClick: handleNotificationsClick }) }),
70
69
  /* @__PURE__ */ jsxs(NavItem, { className: "position-relative", ref: userRef, id: popoverUserId, "aria-haspopup": "true", "aria-expanded": isUserHovered, "data-testid": "header-user-menu-button", children: [
71
70
  /* @__PURE__ */ jsx(NavLink, { link: "/userbook/mon-compte", translate: t("navbar.myaccount"), "data-testid": "header-user-profile-button", children: /* @__PURE__ */ jsx(Avatar, { alt: userName, size: "sm", src: userAvatar, variant: "circle", className: "bg-white", width: "32", height: "32" }) }),
72
- /* @__PURE__ */ jsx(Popover, { align: "end", className: "widget", id: popoverUserId, isVisible: isUserHovered, children: /* @__PURE__ */ jsxs(PopoverBody, { children: [
73
- /* @__PURE__ */ jsxs("a", { href: "/timeline/customize", className: "nav-link customize d-flex align-items-center gap-8", "data-testid": "header-customize-button", children: [
74
- /* @__PURE__ */ jsx(SvgIconSetBackground, { className: "icon" }),
75
- /* @__PURE__ */ jsx("span", { id: "cutomize-label", className: "nav-text", children: t("navbar.customize") })
76
- ] }),
77
- /* @__PURE__ */ jsxs("a", { href: "/auth/logout?callback=" + ((theme == null ? void 0 : theme.logoutCallback) ?? ""), className: "nav-link logout d-flex align-items-center gap-8", "data-testid": "header-logout-button", children: [
78
- /* @__PURE__ */ jsx(SvgIconDisconnect, { className: "icon logout" }),
79
- /* @__PURE__ */ jsx("span", { id: "logout-label", className: "nav-text", children: t("navbar.disconnect") })
80
- ] })
81
- ] }) })
71
+ /* @__PURE__ */ jsx(Popover, { align: "end", className: "widget", id: popoverUserId, isVisible: isUserHovered, children: /* @__PURE__ */ jsx(PopoverBody, { children: /* @__PURE__ */ jsxs("a", { href: "/auth/logout?callback=" + ((theme == null ? void 0 : theme.logoutCallback) ?? ""), className: "nav-link logout d-flex align-items-center gap-8", "data-testid": "header-logout-button", children: [
72
+ /* @__PURE__ */ jsx(SvgIconDisconnect, { className: "icon logout" }),
73
+ /* @__PURE__ */ jsx("span", { id: "logout-label", className: "nav-text", children: t("navbar.disconnect") })
74
+ ] }) }) })
82
75
  ] })
83
76
  ] })
84
77
  ] }) });
@@ -1,14 +1,15 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import NotificationOptionsMenu from "./components/NotificationOptionsMenu.js";
2
3
  import SystemNotificationItem from "./components/SystemNotificationItem.js";
3
4
  import UserNotificationItem from "./components/UserNotificationItem.js";
4
5
  import { notificationAdapter } from "./components/notificationAdapter.js";
5
6
  const NotificationItem = ({
6
7
  notification
7
8
  }) => {
8
- const notif = notificationAdapter(notification);
9
+ const notif = notificationAdapter(notification), menu = /* @__PURE__ */ jsx(NotificationOptionsMenu, { notificationId: notification._id });
9
10
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10
- notif.type === "user" && /* @__PURE__ */ jsx(UserNotificationItem, { notification: notif }),
11
- notif.type === "system" && /* @__PURE__ */ jsx(SystemNotificationItem, { notification: notif })
11
+ notif.type === "user" && /* @__PURE__ */ jsx(UserNotificationItem, { notification: notif, menu }),
12
+ notif.type === "system" && /* @__PURE__ */ jsx(SystemNotificationItem, { notification: notif, menu })
12
13
  ] });
13
14
  };
14
15
  export {
@@ -2,6 +2,12 @@ import { NotificationModel } from '@edifice.io/client';
2
2
  export type NotificationListProps = {
3
3
  /** List of notifications to display */
4
4
  notifications?: NotificationModel[];
5
+ /** All notification types available to filter on */
6
+ notificationTypes?: string[];
7
+ /** Notification types currently applied as filter */
8
+ selectedTypes?: string[];
9
+ /** Callback when the user validates a new filter selection */
10
+ onFilterChange?: (types: string[]) => void;
5
11
  /** Callback when the notifications list is closed */
6
12
  onCloseNotifications?: () => void;
7
13
  /** Callback to load the next page of notifications, used for infinite scrolling */
@@ -12,7 +18,7 @@ export type NotificationListProps = {
12
18
  isLoading?: boolean;
13
19
  };
14
20
  declare const NotificationList: {
15
- ({ notifications, onCloseNotifications, onLoadNextPage, hasNextPage, isLoading, }: NotificationListProps): import("react/jsx-runtime").JSX.Element;
21
+ ({ notifications, notificationTypes, selectedTypes, onFilterChange, onCloseNotifications, onLoadNextPage, hasNextPage, isLoading, }: NotificationListProps): import("react/jsx-runtime").JSX.Element;
16
22
  displayName: string;
17
23
  };
18
24
  export default NotificationList;
@@ -2,6 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import illuEmptyNotification from "@edifice.io/bootstrap/dist/images/homepage/illu-empty-notifications.png";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import SvgIconClose from "../../../icons/components/IconClose.js";
5
+ import NotificationFilterMenu from "./components/NotificationFilterMenu.js";
5
6
  import NotificationItem from "./NotificationItem.js";
6
7
  import NotificationListSkeleton from "./NotificationListSkeleton.js";
7
8
  import NotificationSkeleton from "./NotificationSkeleton.js";
@@ -12,6 +13,9 @@ import EmptyScreen from "../../../../components/EmptyScreen/EmptyScreen.js";
12
13
  import Divider from "../../../../components/Divider/Divider.js";
13
14
  const NotificationList = ({
14
15
  notifications,
16
+ notificationTypes,
17
+ selectedTypes,
18
+ onFilterChange,
15
19
  onCloseNotifications,
16
20
  onLoadNextPage,
17
21
  hasNextPage,
@@ -26,7 +30,10 @@ const NotificationList = ({
26
30
  };
27
31
  return /* @__PURE__ */ jsx("section", { role: "region", className: "notification-list", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
28
32
  /* @__PURE__ */ jsxs(Flex, { justify: "between", align: "center", wrap: "nowrap", className: "py-16 ps-24 pe-8", children: [
29
- /* @__PURE__ */ jsx("h4", { className: "text-truncate", children: t("homepage.notifications-list.title") }),
33
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "8", className: "notification-list-title", children: [
34
+ /* @__PURE__ */ jsx("h4", { className: "text-truncate", children: t("homepage.notifications-list.title") }),
35
+ notificationTypes && notificationTypes.length > 0 && /* @__PURE__ */ jsx(NotificationFilterMenu, { notificationTypes, selectedTypes: selectedTypes ?? notificationTypes, onFilterChange: (types) => onFilterChange == null ? void 0 : onFilterChange(types) })
36
+ ] }),
30
37
  onCloseNotifications && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", variant: "ghost", rightIcon: /* @__PURE__ */ jsx(SvgIconClose, {}), onClick: handleCloseClick, "aria-label": t("homepage.notifications-list.close"), title: t("homepage.notifications-list.close"), "data-testid": "notification-list-close-button" })
31
38
  ] }),
32
39
  (notifications == null ? void 0 : notifications.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "mx-24", children: /* @__PURE__ */ jsx(EmptyScreen, { size: 135, imageSrc: illuEmptyNotification, imageAlt: t("homepage.notifications-list.empty.description"), text: t("homepage.notifications-list.empty.description") }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -6,11 +6,14 @@ const NotificationListContainer = ({
6
6
  }) => {
7
7
  const {
8
8
  notifications,
9
+ notificationTypes,
10
+ selectedTypes,
11
+ setSelectedTypes,
9
12
  hasNextPage,
10
13
  loadNextPage,
11
14
  isLoading
12
15
  } = useNotificationListContainer();
13
- return /* @__PURE__ */ jsx(NotificationList, { notifications, onCloseNotifications, onLoadNextPage: () => {
16
+ return /* @__PURE__ */ jsx(NotificationList, { notifications, notificationTypes, selectedTypes, onFilterChange: setSelectedTypes, onCloseNotifications, onLoadNextPage: () => {
14
17
  hasNextPage && !isLoading && loadNextPage();
15
18
  }, hasNextPage, isLoading });
16
19
  };
@@ -5,6 +5,7 @@ export type NotificationItemProps = {
5
5
  date: Date;
6
6
  uri?: string;
7
7
  children?: ReactNode;
8
+ menu?: ReactNode;
8
9
  };
9
10
  /**
10
11
  * Base layout for a single notification row.
@@ -18,7 +19,7 @@ export type NotificationItemProps = {
18
19
  * `SystemNotification` instead of consuming this directly.
19
20
  */
20
21
  declare const CommonNotificationItem: {
21
- ({ picture, message, date, uri, children, }: NotificationItemProps): import("react/jsx-runtime").JSX.Element;
22
+ ({ picture, message, date, uri, children, menu, }: NotificationItemProps): import("react/jsx-runtime").JSX.Element;
22
23
  displayName: string;
23
24
  };
24
25
  export default CommonNotificationItem;
@@ -6,21 +6,25 @@ const CommonNotificationItem = ({
6
6
  message,
7
7
  date,
8
8
  uri,
9
- children
9
+ children,
10
+ menu
10
11
  }) => {
11
12
  const {
12
13
  formatTimeAgo,
13
14
  formatDate
14
15
  } = useDate();
15
- return /* @__PURE__ */ jsx(Flex, { direction: "column", className: "notification-item", gap: "8", children: /* @__PURE__ */ jsxs(Flex, { direction: "row", gap: "8", children: [
16
- /* @__PURE__ */ jsx("div", { className: "notification-item-picture", children: picture }),
17
- /* @__PURE__ */ jsx("a", { href: uri, "data-testid": "notification-item-content", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "8", children: [
18
- /* @__PURE__ */ jsx("div", { className: "notification-item-message", dangerouslySetInnerHTML: {
19
- __html: message
20
- } }),
21
- children,
22
- /* @__PURE__ */ jsx("p", { className: "notification-item-date", title: formatDate(date, "LLL"), children: formatTimeAgo(date) })
23
- ] }) })
16
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", className: "notification-item", gap: "8", children: /* @__PURE__ */ jsxs(Flex, { direction: "row", justify: "between", wrap: "nowrap", gap: "8", children: [
17
+ /* @__PURE__ */ jsxs(Flex, { direction: "row", align: "start", gap: "8", className: "notification-item-content-wrapper", children: [
18
+ /* @__PURE__ */ jsx("div", { className: "notification-item-picture", children: picture }),
19
+ /* @__PURE__ */ jsx("a", { href: uri, className: "notification-item-link", "data-testid": "notification-item-content", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "8", children: [
20
+ /* @__PURE__ */ jsx("div", { className: "notification-item-message", dangerouslySetInnerHTML: {
21
+ __html: message
22
+ } }),
23
+ children,
24
+ /* @__PURE__ */ jsx("p", { className: "notification-item-date", title: formatDate(date, "LLL"), children: formatTimeAgo(date) })
25
+ ] }) })
26
+ ] }),
27
+ menu && /* @__PURE__ */ jsx("div", { className: "notification-item-menu", children: menu })
24
28
  ] }) });
25
29
  };
26
30
  export {
@@ -0,0 +1,16 @@
1
+ export type NotificationFilterMenuProps = {
2
+ /** All notification types available */
3
+ notificationTypes: string[];
4
+ /** Notification types currently applied as filter */
5
+ selectedTypes: string[];
6
+ /** Callback when the user validates a new filter selection */
7
+ onFilterChange: (types: string[]) => void;
8
+ };
9
+ /**
10
+ * Trigger button opening the notification types filter modal.
11
+ */
12
+ declare const NotificationFilterMenu: {
13
+ ({ notificationTypes, selectedTypes, onFilterChange, }: NotificationFilterMenuProps): import("react/jsx-runtime").JSX.Element;
14
+ displayName: string;
15
+ };
16
+ export default NotificationFilterMenu;
@@ -0,0 +1,29 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useTranslation } from "react-i18next";
4
+ import SvgIconFilter from "../../../../icons/components/IconFilter.js";
5
+ import SvgIconRafterDown from "../../../../icons/components/IconRafterDown.js";
6
+ import NotificationFilterModal from "./NotificationFilterModal.js";
7
+ import ButtonBeta from "../../../../../components/ButtonBeta/ButtonBeta.js";
8
+ const NotificationFilterMenu = ({
9
+ notificationTypes,
10
+ selectedTypes,
11
+ onFilterChange
12
+ }) => {
13
+ const {
14
+ t
15
+ } = useTranslation(), [isOpen, setIsOpen] = useState(!1), handleApply = (types) => {
16
+ onFilterChange(types), setIsOpen(!1);
17
+ };
18
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ /* @__PURE__ */ jsx(ButtonBeta, { type: "button", color: "secondary", variant: "outline", size: "md", leftIcon: /* @__PURE__ */ jsx(SvgIconFilter, {}), rightIcon: /* @__PURE__ */ jsx(SvgIconRafterDown, {}), "aria-label": t("homepage.notifications.filter-modal.trigger", {
20
+ defaultValue: "Filtrer les notifications"
21
+ }), title: t("homepage.notifications.filter-modal.trigger", {
22
+ defaultValue: "Filtrer les notifications"
23
+ }), onClick: () => setIsOpen(!0), "data-testid": "notification-filter-button" }),
24
+ isOpen && /* @__PURE__ */ jsx(NotificationFilterModal, { isOpen, allTypes: notificationTypes, appliedTypes: selectedTypes, onCancel: () => setIsOpen(!1), onApply: handleApply })
25
+ ] });
26
+ };
27
+ export {
28
+ NotificationFilterMenu as default
29
+ };
@@ -0,0 +1,18 @@
1
+ export type NotificationFilterModalProps = {
2
+ isOpen: boolean;
3
+ /** All notification types available */
4
+ allTypes: string[];
5
+ /** Notification types currently applied as filter */
6
+ appliedTypes: string[];
7
+ onCancel: () => void;
8
+ onApply: (types: string[]) => void;
9
+ };
10
+ /**
11
+ * Modal letting the user choose which notification types to display in the
12
+ * homepage notifications list.
13
+ */
14
+ declare const NotificationFilterModal: {
15
+ ({ isOpen, allTypes, appliedTypes, onCancel, onApply, }: NotificationFilterModalProps): import("react/jsx-runtime").JSX.Element;
16
+ displayName: string;
17
+ };
18
+ export default NotificationFilterModal;
@@ -0,0 +1,67 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { useState } from "react";
4
+ import { useTranslation } from "react-i18next";
5
+ import SvgIconCheck from "../../../../icons/components/IconCheck.js";
6
+ import { getAppCodeAndI18nKey } from "./notificationAdapter.js";
7
+ import Modal from "../../../../../components/Modal/Modal.js";
8
+ import Flex from "../../../../../components/Flex/Flex.js";
9
+ import Checkbox from "../../../../../components/Checkbox/Checkbox.js";
10
+ import AppIcon from "../../../../../components/AppIcon/AppIcon.js";
11
+ import ButtonBeta from "../../../../../components/ButtonBeta/ButtonBeta.js";
12
+ const NotificationFilterModal = ({
13
+ isOpen,
14
+ allTypes,
15
+ appliedTypes,
16
+ onCancel,
17
+ onApply
18
+ }) => {
19
+ const {
20
+ t
21
+ } = useTranslation(), [selected, setSelected] = useState(appliedTypes), toggleType = (type) => {
22
+ setSelected((current) => current.includes(type) ? current.filter((value) => value !== type) : [...current, type]);
23
+ }, toggleAll = () => {
24
+ setSelected(selected.length === allTypes.length ? [] : allTypes);
25
+ };
26
+ return /* @__PURE__ */ jsxs(Modal, { id: "notification-filter-modal", size: "lg", scrollable: !0, isOpen, onModalClose: onCancel, children: [
27
+ /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t("homepage.notifications.filter-modal.title", {
28
+ defaultValue: "Filtrer les notifications"
29
+ }) }),
30
+ /* @__PURE__ */ jsx(Modal.Subtitle, { children: t("homepage.notifications.filter-modal.subtitle", {
31
+ defaultValue: "Sélectionnez seulement les notifications importantes pour vous"
32
+ }) }),
33
+ /* @__PURE__ */ jsxs(Modal.Body, { children: [
34
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "8", className: "mb-16", children: [
35
+ /* @__PURE__ */ jsx("div", { className: "notification-filter-select-all", children: /* @__PURE__ */ jsx(Checkbox, { label: t("homepage.notifications.filter-modal.select-all", {
36
+ defaultValue: "Tout sélectionner"
37
+ }), checked: selected.length === allTypes.length, indeterminate: selected.length > 0 && selected.length < allTypes.length, onChange: toggleAll }) }),
38
+ /* @__PURE__ */ jsx("span", { className: "notification-filter-count", children: t("homepage.notifications.filter-modal.count", {
39
+ selected: selected.length,
40
+ total: allTypes.length,
41
+ defaultValue: "[[selected]] / [[total]] sélectionnées"
42
+ }) })
43
+ ] }),
44
+ /* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "8", className: "notification-filter-options", children: allTypes.map((type) => {
45
+ const [appCode, appI18nKey] = getAppCodeAndI18nKey(type), checked = selected.includes(type);
46
+ return /* @__PURE__ */ jsxs("label", { className: clsx("notification-filter-chip", {
47
+ "is-checked": checked
48
+ }), children: [
49
+ /* @__PURE__ */ jsx(AppIcon, { app: appCode, size: "24", iconFit: "contain" }),
50
+ /* @__PURE__ */ jsx("span", { children: t(appI18nKey, {
51
+ defaultValue: appCode
52
+ }) }),
53
+ /* @__PURE__ */ jsx("input", { type: "checkbox", className: "form-check-input", checked, onChange: () => toggleType(type) })
54
+ ] }, type);
55
+ }) })
56
+ ] }),
57
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
58
+ /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("cancel") }),
59
+ /* @__PURE__ */ jsx(ButtonBeta, { color: "default", onClick: () => onApply(selected), type: "button", variant: "filled", rightIcon: /* @__PURE__ */ jsx(SvgIconCheck, {}), children: t("homepage.notifications.filter-modal.confirm", {
60
+ defaultValue: "Enregistrer"
61
+ }) })
62
+ ] })
63
+ ] });
64
+ };
65
+ export {
66
+ NotificationFilterModal as default
67
+ };
@@ -0,0 +1,12 @@
1
+ export type NotificationOptionsMenuProps = {
2
+ notificationId: string;
3
+ };
4
+ /**
5
+ * Options menu for a single notification row, allowing the user to report
6
+ * or delete it.
7
+ */
8
+ declare const NotificationOptionsMenu: {
9
+ ({ notificationId, }: NotificationOptionsMenuProps): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
12
+ export default NotificationOptionsMenu;
@@ -0,0 +1,42 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useTranslation } from "react-i18next";
4
+ import SvgIconAlertTriangle from "../../../../icons/components/IconAlertTriangle.js";
5
+ import SvgIconDelete from "../../../../icons/components/IconDelete.js";
6
+ import SvgIconOptions from "../../../../icons/components/IconOptions.js";
7
+ import { useReportNotification, useDeleteNotification } from "../services/queries/notification.js";
8
+ import ReportNotificationModal from "./ReportNotificationModal.js";
9
+ import Dropdown from "../../../../../components/Dropdown/Dropdown.js";
10
+ import IconButton from "../../../../../components/Button/IconButton.js";
11
+ const NotificationOptionsMenu = ({
12
+ notificationId
13
+ }) => {
14
+ const {
15
+ t
16
+ } = useTranslation(), {
17
+ mutate: reportNotification
18
+ } = useReportNotification(), {
19
+ mutate: deleteNotification
20
+ } = useDeleteNotification(), [isReportModalOpen, setIsReportModalOpen] = useState(!1);
21
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ /* @__PURE__ */ jsx(Dropdown, { overflow: !1, children: (triggerProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
23
+ /* @__PURE__ */ jsx(IconButton, { ...triggerProps, type: "button", "aria-label": t("homepage.notifications.options.label", {
24
+ defaultValue: "Options de la notification"
25
+ }), color: "tertiary", variant: "ghost", icon: /* @__PURE__ */ jsx(SvgIconOptions, {}), "data-testid": "notification-item-options-button" }),
26
+ /* @__PURE__ */ jsxs(Dropdown.Menu, { children: [
27
+ /* @__PURE__ */ jsx(Dropdown.Item, { icon: /* @__PURE__ */ jsx(SvgIconAlertTriangle, {}), onClick: () => setIsReportModalOpen(!0), children: t("homepage.notifications.options.report", {
28
+ defaultValue: "Signaler"
29
+ }) }),
30
+ /* @__PURE__ */ jsx(Dropdown.Item, { icon: /* @__PURE__ */ jsx(SvgIconDelete, {}), onClick: () => deleteNotification(notificationId), children: t("homepage.notifications.options.delete", {
31
+ defaultValue: "Supprimer"
32
+ }) })
33
+ ] })
34
+ ] }) }),
35
+ isReportModalOpen && /* @__PURE__ */ jsx(ReportNotificationModal, { isOpen: isReportModalOpen, onCancel: () => setIsReportModalOpen(!1), onConfirm: () => {
36
+ reportNotification(notificationId), setIsReportModalOpen(!1);
37
+ } })
38
+ ] });
39
+ };
40
+ export {
41
+ NotificationOptionsMenu as default
42
+ };
@@ -0,0 +1,13 @@
1
+ export type ReportNotificationModalProps = {
2
+ isOpen: boolean;
3
+ onCancel: () => void;
4
+ onConfirm: () => void;
5
+ };
6
+ /**
7
+ * Confirmation modal shown before reporting a notification as inappropriate.
8
+ */
9
+ declare const ReportNotificationModal: {
10
+ ({ isOpen, onCancel, onConfirm, }: ReportNotificationModalProps): import("react/jsx-runtime").JSX.Element;
11
+ displayName: string;
12
+ };
13
+ export default ReportNotificationModal;
@@ -0,0 +1,31 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useTranslation } from "react-i18next";
3
+ import SvgIconAlertTriangle from "../../../../icons/components/IconAlertTriangle.js";
4
+ import Modal from "../../../../../components/Modal/Modal.js";
5
+ import ButtonBeta from "../../../../../components/ButtonBeta/ButtonBeta.js";
6
+ const ReportNotificationModal = ({
7
+ isOpen,
8
+ onCancel,
9
+ onConfirm
10
+ }) => {
11
+ const {
12
+ t
13
+ } = useTranslation();
14
+ return /* @__PURE__ */ jsxs(Modal, { id: "report-notification-modal", size: "lg", isOpen, onModalClose: onCancel, children: [
15
+ /* @__PURE__ */ jsx(Modal.Header, { onModalClose: onCancel, children: t("homepage.notifications.report-modal.title", {
16
+ defaultValue: "Signaler une notification"
17
+ }) }),
18
+ /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx("p", { children: t("homepage.notifications.report-modal.body", {
19
+ defaultValue: "Attention ! Vous souhaitez signaler une notification inappropriée ou qui ne respecte pas les conditions d'utilisation de ONE. L'heure et l'origine de ce signalement seront enregistrées et transmises à un administrateur pour traitement."
20
+ }) }) }),
21
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
22
+ /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", onClick: onCancel, type: "button", variant: "ghost", children: t("cancel") }),
23
+ /* @__PURE__ */ jsx(ButtonBeta, { color: "default", onClick: onConfirm, type: "button", variant: "filled", leftIcon: /* @__PURE__ */ jsx(SvgIconAlertTriangle, {}), children: t("homepage.notifications.report-modal.confirm", {
24
+ defaultValue: "Signaler la notification"
25
+ }) })
26
+ ] })
27
+ ] });
28
+ };
29
+ export {
30
+ ReportNotificationModal as default
31
+ };
@@ -1,6 +1,8 @@
1
+ import { ReactNode } from 'react';
1
2
  import { SystemWebNotification } from './notificationAdapter';
2
3
  export type SystemNotificationItemProps = {
3
4
  notification: SystemWebNotification;
5
+ menu?: ReactNode;
4
6
  };
5
7
  /**
6
8
  * Renders a system notification (no sender) using an app icon as the picture.
@@ -9,7 +11,7 @@ export type SystemNotificationItemProps = {
9
11
  * rather than this component directly.
10
12
  */
11
13
  declare const SystemNotificationItem: {
12
- ({ notification, }: SystemNotificationItemProps): import("react/jsx-runtime").JSX.Element;
14
+ ({ notification, menu, }: SystemNotificationItemProps): import("react/jsx-runtime").JSX.Element;
13
15
  displayName: string;
14
16
  };
15
17
  export default SystemNotificationItem;
@@ -3,7 +3,8 @@ import { useTranslation } from "react-i18next";
3
3
  import CommonNotificationItem from "./CommonNotificationItem.js";
4
4
  import AppIcon from "../../../../../components/AppIcon/AppIcon.js";
5
5
  const SystemNotificationItem = ({
6
- notification
6
+ notification,
7
+ menu
7
8
  }) => {
8
9
  const {
9
10
  params,
@@ -13,7 +14,7 @@ const SystemNotificationItem = ({
13
14
  } = notification, {
14
15
  t
15
16
  } = useTranslation(), appName = t(params.appCode);
16
- return /* @__PURE__ */ jsx(CommonNotificationItem, { uri, message, date, picture: /* @__PURE__ */ jsx("a", { href: uri, title: appName, "data-testid": "notification-item-app-icon", "aria-label": t("homepage.notifications.app-icon.placeholder"), children: /* @__PURE__ */ jsx(AppIcon, { app: params.appCode, size: "24", variant: "square", className: "notification-item-app-icon" }) }) });
17
+ return /* @__PURE__ */ jsx(CommonNotificationItem, { uri, message, date, menu, picture: /* @__PURE__ */ jsx("a", { href: uri, title: appName, "data-testid": "notification-item-app-icon", "aria-label": t("homepage.notifications.app-icon.placeholder"), children: /* @__PURE__ */ jsx(AppIcon, { app: params.appCode, size: "24", variant: "square", className: "notification-item-app-icon" }) }) });
17
18
  };
18
19
  export {
19
20
  SystemNotificationItem as default
@@ -1,6 +1,8 @@
1
+ import { ReactNode } from 'react';
1
2
  import { UserWebNotification } from './notificationAdapter';
2
3
  export type UserNotificationItemProps = {
3
4
  notification: UserWebNotification;
5
+ menu?: ReactNode;
4
6
  };
5
7
  /**
6
8
  * Renders a user-triggered notification using the sender's avatar as the picture.
@@ -9,7 +11,7 @@ export type UserNotificationItemProps = {
9
11
  * — prefer using `Notification` at the top level rather than this component directly.
10
12
  */
11
13
  declare const UserNotificationItem: {
12
- ({ notification }: UserNotificationItemProps): import("react/jsx-runtime").JSX.Element;
14
+ ({ notification, menu, }: UserNotificationItemProps): import("react/jsx-runtime").JSX.Element;
13
15
  displayName: string;
14
16
  };
15
17
  export default UserNotificationItem;
@@ -5,7 +5,8 @@ import NotificationItemResource from "./NotificationItemResource.js";
5
5
  import useDirectory from "../../../../../hooks/useDirectory/useDirectory.js";
6
6
  import Avatar from "../../../../../components/Avatar/Avatar.js";
7
7
  const UserNotificationItem = ({
8
- notification
8
+ notification,
9
+ menu
9
10
  }) => {
10
11
  const {
11
12
  getAvatarURL,
@@ -18,7 +19,7 @@ const UserNotificationItem = ({
18
19
  } = notification, {
19
20
  t
20
21
  } = useTranslation(), userName = t(params.username);
21
- return /* @__PURE__ */ jsx(CommonNotificationItem, { uri, message, date, picture: /* @__PURE__ */ jsx("a", { href: getUserbookURL(params.userId, "user"), title: userName, "data-testid": "notification-item-avatar", children: /* @__PURE__ */ jsx(Avatar, { "aria-label": t("homepage.notifications.avatar.placeholder"), src: getAvatarURL(params.userId, "user"), alt: userName, variant: "circle", className: "notification-item-avatar" }) }), children: /* @__PURE__ */ jsx(NotificationItemResource, { appCode: params.appCode, appI18nKey: params.appI18nKey }) });
22
+ return /* @__PURE__ */ jsx(CommonNotificationItem, { uri, message, date, menu, picture: /* @__PURE__ */ jsx("a", { href: getUserbookURL(params.userId, "user"), title: userName, "data-testid": "notification-item-avatar", children: /* @__PURE__ */ jsx(Avatar, { "aria-label": t("homepage.notifications.avatar.placeholder"), src: getAvatarURL(params.userId, "user"), alt: userName, variant: "circle", className: "notification-item-avatar" }) }), children: /* @__PURE__ */ jsx(NotificationItemResource, { appCode: params.appCode, appI18nKey: params.appI18nKey }) });
22
23
  };
23
24
  export {
24
25
  UserNotificationItem as default
@@ -26,6 +26,7 @@ export type SystemWebNotification = WebNotificationBase & {
26
26
  };
27
27
  /** Discriminated union — narrow on `type` to get the specific variant. */
28
28
  export type WebNotification = UserWebNotification | SystemWebNotification;
29
+ export declare const getAppCodeAndI18nKey: (appCode: string) => [string, string];
29
30
  /**
30
31
  * Transforms a raw `NotificationModel` (API shape) into a `WebNotification`
31
32
  * ready for rendering.
@@ -62,5 +62,6 @@ const resolveNotificationResourceUri = (params, type, appCode, eventType) => {
62
62
  };
63
63
  };
64
64
  export {
65
+ getAppCodeAndI18nKey,
65
66
  notificationAdapter
66
67
  };
@@ -2,8 +2,12 @@ import { NotificationModel } from '@edifice.io/client';
2
2
  export interface UseNotificationListContainerReturn {
3
3
  /** Array of notifications */
4
4
  notifications: NotificationModel[] | undefined;
5
- /** Array of notification types */
5
+ /** Array of all notification types available */
6
6
  notificationTypes: string[] | undefined;
7
+ /** Array of notification types currently selected as filter */
8
+ selectedTypes: string[] | undefined;
9
+ /** Callback to change the selected notification types filter */
10
+ setSelectedTypes: (types: string[]) => void;
7
11
  /** Indicates if there are more notifications to load */
8
12
  hasNextPage: boolean | undefined;
9
13
  /** Callback to load the next page of notifications */
@@ -1,4 +1,5 @@
1
- import { useNotificationTypes, useNotifications } from "../services/queries/notification.js";
1
+ import { useState, useEffect } from "react";
2
+ import { useNotificationTypes, useTimelinePreference, useSaveTimelinePreference, useNotifications } from "../services/queries/notification.js";
2
3
  const useNotificationListContainer = () => {
3
4
  const {
4
5
  data: notificationTypes,
@@ -6,15 +7,34 @@ const useNotificationListContainer = () => {
6
7
  isFetched: isFetchedTypes,
7
8
  error: errorTypes
8
9
  } = useNotificationTypes(), {
10
+ data: preference,
11
+ isFetched: isFetchedPreference
12
+ } = useTimelinePreference(), {
13
+ mutate: saveTimelinePreference
14
+ } = useSaveTimelinePreference(), [selectedTypes, setSelectedTypesState] = useState();
15
+ useEffect(() => {
16
+ if (selectedTypes === void 0 && isFetchedTypes && isFetchedPreference) {
17
+ const preferredTypes = preference == null ? void 0 : preference.type;
18
+ setSelectedTypesState(preferredTypes && preferredTypes.length > 0 ? preferredTypes : notificationTypes ?? []);
19
+ }
20
+ }, [selectedTypes, isFetchedTypes, isFetchedPreference, preference, notificationTypes]);
21
+ const setSelectedTypes = (types) => {
22
+ setSelectedTypesState(types), saveTimelinePreference({
23
+ ...preference,
24
+ type: types
25
+ });
26
+ }, {
9
27
  data: notifications,
10
28
  hasNextPage,
11
29
  isLoading: isLoadingNotifications,
12
30
  error: errorNotifications,
13
31
  fetchNextPage
14
- } = useNotifications(notificationTypes ?? [], isFetchedTypes && !!notificationTypes);
32
+ } = useNotifications(selectedTypes ?? [], isFetchedTypes && !!selectedTypes);
15
33
  return {
16
34
  notifications,
17
35
  notificationTypes,
36
+ selectedTypes,
37
+ setSelectedTypes,
18
38
  hasNextPage,
19
39
  loadNextPage: () => fetchNextPage(),
20
40
  isLoading: isLoadingTypes || isLoadingNotifications,
@@ -1,4 +1,6 @@
1
1
  export declare const notificationService: {
2
2
  getNotifications(types: string[], page: number): Promise<import('@edifice.io/client').NotificationModel[]>;
3
3
  getNotificationTypes(): Promise<string[]>;
4
+ reportNotification(id: string): Promise<any>;
5
+ deleteNotification(id: string): Promise<any>;
4
6
  };
@@ -12,4 +12,12 @@ export declare const createNotificationService: (baseURL: string) => {
12
12
  */
13
13
  getNotifications(types: string[], page: number): Promise<NotificationModel[]>;
14
14
  getNotificationTypes(): Promise<string[]>;
15
+ /**
16
+ * Report a notification as inappropriate.
17
+ */
18
+ reportNotification(id: string): Promise<any>;
19
+ /**
20
+ * Delete a notification.
21
+ */
22
+ deleteNotification(id: string): Promise<any>;
15
23
  };
@@ -14,6 +14,18 @@ const createNotificationService = (baseURL) => ({
14
14
  },
15
15
  getNotificationTypes() {
16
16
  return odeServices.http().get(`${baseURL}/timeline/types`);
17
+ },
18
+ /**
19
+ * Report a notification as inappropriate.
20
+ */
21
+ reportNotification(id) {
22
+ return odeServices.http().put(`${baseURL}/timeline/${id}/report`);
23
+ },
24
+ /**
25
+ * Delete a notification.
26
+ */
27
+ deleteNotification(id) {
28
+ return odeServices.http().put(`${baseURL}/timeline/${id}`);
17
29
  }
18
30
  });
19
31
  export {
@@ -1,14 +1,22 @@
1
1
  import { NotificationModel } from '@edifice.io/client';
2
+ import { InfiniteData } from '@tanstack/react-query';
3
+ /** Shape of the `timeline` userbook preference (only `type` is read/written here). */
4
+ export interface TimelinePreference {
5
+ page?: number;
6
+ type: string[];
7
+ config?: Record<string, unknown>;
8
+ }
2
9
  export declare const notificationQueryKeys: {
3
10
  all: () => readonly ["notifications"];
4
11
  notifications: (types?: string[]) => readonly ["notifications", "list", string[]];
5
12
  types: () => readonly ["notifications", "types"];
13
+ preference: () => readonly ["notifications", "preference"];
6
14
  };
7
15
  export declare const notificationQueryOptions: {
8
16
  getNotifications(types: string[], enabled: boolean): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseInfiniteQueryOptions<NotificationModel[], Error, NotificationModel[], NotificationModel[], readonly ["notifications", "list", string[]], number>, "queryFn"> & {
9
17
  queryFn?: import('@tanstack/react-query').QueryFunction<NotificationModel[], readonly ["notifications", "list", string[]], number> | undefined;
10
18
  } & {
11
- queryKey: import('@tanstack/react-query').DataTag<readonly ["notifications", "list", string[]], import('@tanstack/react-query').InfiniteData<NotificationModel[], unknown>>;
19
+ queryKey: import('@tanstack/react-query').DataTag<readonly ["notifications", "list", string[]], InfiniteData<NotificationModel[], unknown>>;
12
20
  };
13
21
  getNotificationTypes(): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<string[], Error, string[], import('@tanstack/react-query').QueryKey>, "queryFn"> & {
14
22
  queryFn?: import('@tanstack/react-query').QueryFunction<string[], import('@tanstack/react-query').QueryKey, never> | undefined;
@@ -18,3 +26,7 @@ export declare const notificationQueryOptions: {
18
26
  };
19
27
  export declare const useNotifications: (types?: string[], enabled?: boolean) => import('@tanstack/react-query').UseInfiniteQueryResult<NotificationModel[], Error>;
20
28
  export declare const useNotificationTypes: () => import('@tanstack/react-query').UseQueryResult<string[], Error>;
29
+ export declare const useTimelinePreference: () => import('@tanstack/react-query').UseQueryResult<TimelinePreference, Error>;
30
+ export declare const useSaveTimelinePreference: () => import('@tanstack/react-query').UseMutationResult<void, Error, TimelinePreference, unknown>;
31
+ export declare const useReportNotification: () => import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
32
+ export declare const useDeleteNotification: () => import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
@@ -1,9 +1,11 @@
1
- import { useQuery, useInfiniteQuery, queryOptions, infiniteQueryOptions } from "@tanstack/react-query";
1
+ import { odeServices } from "@edifice.io/client";
2
+ import { useMutation, useQueryClient, useQuery, useInfiniteQuery, queryOptions, infiniteQueryOptions } from "@tanstack/react-query";
2
3
  import { notificationService } from "../api/index.js";
3
4
  const notificationQueryKeys = {
4
5
  all: () => ["notifications"],
5
6
  notifications: (types = []) => [...notificationQueryKeys.all(), "list", types],
6
- types: () => [...notificationQueryKeys.all(), "types"]
7
+ types: () => [...notificationQueryKeys.all(), "types"],
8
+ preference: () => [...notificationQueryKeys.all(), "preference"]
7
9
  }, notificationQueryOptions = {
8
10
  getNotifications(types, enabled) {
9
11
  return infiniteQueryOptions({
@@ -31,10 +33,45 @@ const notificationQueryKeys = {
31
33
  queryFn: async () => notificationService.getNotificationTypes()
32
34
  });
33
35
  }
34
- }, useNotifications = (types = [], enabled = !0) => useInfiniteQuery(notificationQueryOptions.getNotifications(types, enabled)), useNotificationTypes = () => useQuery(notificationQueryOptions.getNotificationTypes());
36
+ }, useNotifications = (types = [], enabled = !0) => useInfiniteQuery(notificationQueryOptions.getNotifications(types, enabled)), useNotificationTypes = () => useQuery(notificationQueryOptions.getNotificationTypes()), useTimelinePreference = () => useQuery({
37
+ queryKey: notificationQueryKeys.preference(),
38
+ queryFn: () => odeServices.conf().getPreference("timeline")
39
+ }), useSaveTimelinePreference = () => {
40
+ const queryClient = useQueryClient();
41
+ return useMutation({
42
+ mutationFn: (preference) => odeServices.conf().savePreference("timeline", preference),
43
+ onSuccess: (_data, preference) => {
44
+ queryClient.setQueryData(notificationQueryKeys.preference(), preference);
45
+ },
46
+ onError: () => {
47
+ queryClient.invalidateQueries({
48
+ queryKey: notificationQueryKeys.preference()
49
+ });
50
+ }
51
+ });
52
+ }, useReportNotification = () => useMutation({
53
+ mutationFn: (id) => notificationService.reportNotification(id)
54
+ }), useDeleteNotification = () => {
55
+ const queryClient = useQueryClient();
56
+ return useMutation({
57
+ mutationFn: (id) => notificationService.deleteNotification(id),
58
+ onSuccess: (_data, id) => {
59
+ queryClient.setQueriesData({
60
+ queryKey: [...notificationQueryKeys.all(), "list"]
61
+ }, (data) => data && {
62
+ ...data,
63
+ pages: data.pages.map((page) => page.filter((notification) => notification._id !== id))
64
+ });
65
+ }
66
+ });
67
+ };
35
68
  export {
36
69
  notificationQueryKeys,
37
70
  notificationQueryOptions,
71
+ useDeleteNotification,
38
72
  useNotificationTypes,
39
- useNotifications
73
+ useNotifications,
74
+ useReportNotification,
75
+ useSaveTimelinePreference,
76
+ useTimelinePreference
40
77
  };
@@ -17,20 +17,18 @@ function useProfileLinks(profile) {
17
17
  structure: structureId
18
18
  });
19
19
  return `${baseUrl}?${params.toString()}`;
20
- }, buildClassesUrl = (parameters, classIds = []) => {
21
- const params = new URLSearchParams(parameters);
20
+ }, buildClassesUrl = (classIds = []) => {
21
+ const params = new URLSearchParams({
22
+ filters: "groups",
23
+ structure: structureId
24
+ });
22
25
  return classIds.forEach((c) => params.append("class", String(c))), `${baseUrl}?${params.toString()}`;
23
26
  };
24
27
  switch (profile) {
25
28
  case "Teacher":
26
29
  return [{
27
30
  text: t("homepage.userspace.teacher.link.classes"),
28
- url: buildClassesUrl(
29
- {
30
- filters: "groups"
31
- }
32
- /* Do not explicitely add classes ids, because none <=> see all*/
33
- )
31
+ url: buildClassesUrl(user.classes)
34
32
  }];
35
33
  case "Student":
36
34
  return [{
@@ -38,12 +36,7 @@ function useProfileLinks(profile) {
38
36
  url: "/userbook/annuaire#/search?filters=groups&profile=Teacher"
39
37
  }, {
40
38
  text: t("homepage.userspace.student.link.classes"),
41
- url: buildClassesUrl(
42
- {
43
- filters: "groups"
44
- }
45
- /* Do not explicitely add classes ids, because none <=> see all*/
46
- )
39
+ url: buildClassesUrl(user.classes)
47
40
  }];
48
41
  case "Relative":
49
42
  return children != null && children.length ? children.map((child) => {
@@ -52,10 +45,7 @@ function useProfileLinks(profile) {
52
45
  text: t("homepage.userspace.relative.link.classes", {
53
46
  childName: child.firstName
54
47
  }),
55
- url: buildClassesUrl({
56
- filters: "groups",
57
- structure: structureId
58
- }, (_a2 = child.classes) == null ? void 0 : _a2.map(({
48
+ url: buildClassesUrl((_a2 = child.classes) == null ? void 0 : _a2.map(({
59
49
  id
60
50
  }) => id))
61
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.6.2-develop-b2school.20260820173935",
3
+ "version": "2.6.2-develop-integration-crna.20260823185851",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -140,9 +140,9 @@
140
140
  "swiper": "10.1.0",
141
141
  "ua-parser-js": "1.0.36",
142
142
  "zustand": "4.5.7",
143
- "@edifice.io/bootstrap": "2.6.2-develop-b2school.20260820173935",
144
- "@edifice.io/tiptap-extensions": "2.6.2-develop-b2school.20260820173935",
145
- "@edifice.io/utilities": "2.6.2-develop-b2school.20260820173935"
143
+ "@edifice.io/bootstrap": "2.6.2-develop-integration-crna.20260823185851",
144
+ "@edifice.io/tiptap-extensions": "2.6.2-develop-integration-crna.20260823185851",
145
+ "@edifice.io/utilities": "2.6.2-develop-integration-crna.20260823185851"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@babel/plugin-transform-react-pure-annotations": "7.27.1",
@@ -173,8 +173,8 @@
173
173
  "vite": "5.4.14",
174
174
  "vite-plugin-dts": "4.5.4",
175
175
  "vite-tsconfig-paths": "5.1.4",
176
- "@edifice.io/config": "2.6.2-develop-b2school.20260820173935",
177
- "@edifice.io/client": "2.6.2-develop-b2school.20260820173935"
176
+ "@edifice.io/client": "2.6.2-develop-integration-crna.20260823185851",
177
+ "@edifice.io/config": "2.6.2-develop-integration-crna.20260823185851"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "@react-spring/web": "9.7.5",