kaori 4 лет назад
Родитель
Сommit
dcb068e2f9
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      packages/app/src/stores/in-app-notification.ts

+ 16 - 0
packages/app/src/stores/in-app-notification.ts

@@ -0,0 +1,16 @@
+import useSWR, { SWRResponse } from 'swr';
+
+import { apiv3Get } from '../client/util/apiv3-client';
+import { IInAppNotification } from '../interfaces/in-app-notification';
+
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export const useSWRxInAppNotifications = <Data, Error>(
+  limit: number,
+): SWRResponse<IInAppNotification[], Error> => {
+  const limitNum = limit;
+  return useSWR(
+    '/in-app-notification/list',
+    endpoint => apiv3Get<{ notifications: IInAppNotification[], limitNum: number }>(endpoint).then(response => response.data?.notifications),
+  );
+};