@edifice.io/react 2.0.3-develop-b2school.20250116141052 → 2.0.3-develop-b2school.20250129151355

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.
@@ -3,6 +3,7 @@ import { forwardRef } from "react";
3
3
  import clsx from "clsx";
4
4
  import SvgIconRafterUp from "../../modules/icons/components/IconRafterUp.js";
5
5
  import { useDropdownContext } from "./DropdownContext.js";
6
+ import Badge from "../Badge/Badge.js";
6
7
  const DropdownTrigger = /* @__PURE__ */ forwardRef(({
7
8
  label,
8
9
  icon,
@@ -26,7 +27,10 @@ const DropdownTrigger = /* @__PURE__ */ forwardRef(({
26
27
  return /* @__PURE__ */ jsxs("button", { ref: forwardRef2, type: "button", disabled, ...mergedProps, children: [
27
28
  icon,
28
29
  label,
29
- badgeContent ? /* @__PURE__ */ jsx("span", { className: "badge text-bg-secondary rounded-pill", children: badgeContent }) : !hideCarret && /* @__PURE__ */ jsx(SvgIconRafterUp, { width: 16, height: 16, className: "dropdown-toggle-caret" })
30
+ badgeContent ? /* @__PURE__ */ jsx(Badge, { variant: {
31
+ level: "info",
32
+ type: "notification"
33
+ }, children: badgeContent }) : !hideCarret && /* @__PURE__ */ jsx(SvgIconRafterUp, { width: 16, height: 16, className: "dropdown-toggle-caret" })
30
34
  ] });
31
35
  });
32
36
  export {
@@ -1,5 +1,5 @@
1
1
  declare const useConversation: () => {
2
- readonly messages: number;
2
+ readonly messages: any;
3
3
  readonly msgLink: string;
4
4
  readonly zimbraWorkflow: boolean | Record<string, boolean> | undefined;
5
5
  };
@@ -1,23 +1,21 @@
1
1
  import { useState, useEffect } from "react";
2
2
  import { odeServices } from "@edifice.io/client";
3
+ import { useQuery } from "@tanstack/react-query";
3
4
  import useHasWorkflow from "../useHasWorkflow/useHasWorkflow.js";
4
5
  const useConversation = () => {
5
- const zimbraWorkflow = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|view"), zimbraPreauth = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|preauth"), [messages, setMessages] = useState(0), [msgLink, setMsgLink] = useState(""), queryParams = {
6
+ const zimbraWorkflow = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|view"), zimbraPreauth = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|preauth"), [msgLink, setMsgLink] = useState(""), queryParams = {
6
7
  unread: !0,
7
8
  _: (/* @__PURE__ */ new Date()).getTime()
8
- }, refreshMails = async () => {
9
- const url = zimbraWorkflow ? "/zimbra/count/INBOX" : "/conversation/count/INBOX";
10
- try {
11
- const {
12
- count
13
- } = await odeServices.http().get(url, {
14
- queryParams
15
- });
16
- setMessages(count ?? 0);
17
- } catch (error) {
18
- console.error(error), setMessages(0);
19
- }
20
- }, goToMessagerie = async () => {
9
+ }, {
10
+ data: messages
11
+ } = useQuery({
12
+ queryKey: ["conversation-navbar-count"],
13
+ queryFn: async () => await odeServices.http().get(zimbraWorkflow ? "/zimbra/count/INBOX" : "/conversation/count/INBOX", {
14
+ queryParams
15
+ }),
16
+ staleTime: 5 * 60 * 1e3
17
+ // 5 minutes
18
+ }), goToMessagerie = async () => {
21
19
  const defaultLink = "/zimbra/zimbra";
22
20
  try {
23
21
  const {
@@ -29,11 +27,9 @@ const useConversation = () => {
29
27
  }
30
28
  };
31
29
  return useEffect(() => {
32
- refreshMails();
33
- }, []), useEffect(() => {
34
30
  goToMessagerie();
35
31
  }, []), {
36
- messages,
32
+ messages: messages ? messages.count : 0,
37
33
  msgLink,
38
34
  zimbraWorkflow
39
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.0.3-develop-b2school.20250116141052",
3
+ "version": "2.0.3-develop-b2school.20250129151355",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -119,9 +119,9 @@
119
119
  "react-slugify": "^3.0.3",
120
120
  "swiper": "^10.1.0",
121
121
  "ua-parser-js": "^1.0.36",
122
- "@edifice.io/bootstrap": "2.0.3-develop-b2school.20250116141052",
123
- "@edifice.io/utilities": "2.0.3-develop-b2school.20250116141052",
124
- "@edifice.io/tiptap-extensions": "2.0.3-develop-b2school.20250116141052"
122
+ "@edifice.io/bootstrap": "2.0.3-develop-b2school.20250129151355",
123
+ "@edifice.io/tiptap-extensions": "2.0.3-develop-b2school.20250129151355",
124
+ "@edifice.io/utilities": "2.0.3-develop-b2school.20250129151355"
125
125
  },
126
126
  "devDependencies": {
127
127
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -147,7 +147,7 @@
147
147
  "typescript-eslint": "^8.8.1",
148
148
  "vite": "^5.4.11",
149
149
  "vite-plugin-dts": "^4.1.0",
150
- "@edifice.io/client": "2.0.3-develop-b2school.20250116141052"
150
+ "@edifice.io/client": "2.0.3-develop-b2school.20250129151355"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "@react-spring/web": "^9.7.5",