{props.icon}
-
+
{props.title}
+
+ {!!props.count &&
+ {props.count > 100 ? '+100' : props.count}
+
}
+
diff --git a/src/shared/hooks/useShareData.ts b/src/shared/hooks/useShareData.ts
new file mode 100644
index 0000000..fa240cd
--- /dev/null
+++ b/src/shared/hooks/useShareData.ts
@@ -0,0 +1,10 @@
+import { getMailboxCount } from "../service/Service";
+import { useQuery } from "@tanstack/react-query";
+
+export const useMailboxCount = () => {
+ return useQuery({
+ queryKey: ["mailbox-count"],
+ queryFn: getMailboxCount,
+ staleTime: 0,
+ });
+};
diff --git a/src/shared/service/Service.ts b/src/shared/service/Service.ts
new file mode 100644
index 0000000..a77d05d
--- /dev/null
+++ b/src/shared/service/Service.ts
@@ -0,0 +1,6 @@
+import axios from "@/config/axios";
+
+export const getMailboxCount = async () => {
+ const { data } = await axios.get("/mailbox/counts");
+ return data;
+};
diff --git a/src/shared/types/SharedTypes.ts b/src/shared/types/SharedTypes.ts
index 866eaf8..67dd1fd 100644
--- a/src/shared/types/SharedTypes.ts
+++ b/src/shared/types/SharedTypes.ts
@@ -10,3 +10,10 @@ export type SharedStoreType = {
editingDraftId: number | null;
setEditingDraftId: (id: number | null) => void;
};
+
+export type MailboxCount = {
+ id: string;
+ name: string;
+ unseen: number;
+ total: number;
+};