Shun Miyazawa 4 лет назад
Родитель
Сommit
d2e0dd5fda

+ 7 - 0
packages/app/src/components/Admin/AuditLog.tsx

@@ -1,6 +1,13 @@
 import React, { FC } from 'react';
 
+import { useSWRxActivityList } from '~/stores/activity';
+
 const AuditLog: FC = () => {
+  const { data: activityListData } = useSWRxActivityList(5, 0);
+
+  // eslint-disable-next-line @typescript-eslint/no-unused-vars
+  const activityList = activityListData != null ? activityListData : null;
+
   return (
     <>Hello, AuditLog</>
   );

+ 13 - 0
packages/app/src/stores/activity.ts

@@ -0,0 +1,13 @@
+import { SWRResponse } from 'swr';
+import useSWRImmutable from 'swr/immutable';
+
+import { apiv3Get } from '../client/util/apiv3-client';
+import { IActivity } from '../interfaces/activity';
+import { PaginateResult } from '../interfaces/mongoose-utils';
+
+export const useSWRxActivityList = (limit?: number, offset?: number): SWRResponse<PaginateResult<IActivity>, Error> => {
+  return useSWRImmutable(
+    ['/activity/list', limit, offset],
+    (endpoint, limit, offset) => apiv3Get(endpoint, { limit, offset }).then(result => result.data.paginatedActivity),
+  );
+};