jam411 3 лет назад
Родитель
Сommit
d041b4a728

+ 1 - 1
packages/app/src/components/Admin/PluginsExtension/PluginsExtensionPageContents.tsx

@@ -1,6 +1,6 @@
 import React from 'react';
 
-import { useSWRxPlugins } from '~/stores/plugin-test';
+import { useSWRxPlugins } from '~/stores/plugin';
 
 import Loading from './Loading';
 import { PluginCard } from './PluginCard';

+ 0 - 68
packages/app/src/stores/plugin-test.tsx

@@ -1,68 +0,0 @@
-import { useCallback } from 'react';
-
-import {
-  HasObjectId,
-  IAttachment, Nullable, SWRResponseWithUtils, withUtils,
-} from '@growi/core';
-import useSWR, { SWRResponse } from 'swr';
-
-import { apiPost } from '~/client/util/apiv1-client';
-import { apiv3Get } from '~/client/util/apiv3-client';
-import { IResAttachmentList } from '~/interfaces/attachment';
-
-import { PluginResult } from '../models/SearchResult';
-
-// TODO: Correct types
-const pluginsFetcher = () => {
-  return async() => {
-    const reqUrl = '/plugins-extension';
-    try {
-      const data = await apiv3Get(reqUrl);
-      return data;
-    }
-    catch (err) {
-      // TODO: Error handling
-      console.log('err', err);
-    }
-  };
-};
-
-export const useSWRxPlugins = (): SWRResponse<any | null, Error> => {
-  return useSWR('/extension', pluginsFetcher());
-};
-
-
-// export const useSWRxPlugins = (): SWRResponseWithUtils<Util, IDataAttachmentList, Error> => {
-//   const shouldFetch = pageId != null && pageNumber != null;
-
-//   const fetcher = useCallback(async(endpoint, pageId, pageNumber) => {
-//     const res = await apiv3Get<IResAttachmentList>(endpoint, { pageId, pageNumber });
-//     const resAttachmentList = res.data;
-//     const { paginateResult } = resAttachmentList;
-//     return {
-//       attachments: paginateResult.docs,
-//       totalAttachments: paginateResult.totalDocs,
-//       limit: paginateResult.limit,
-//     };
-//   }, []);
-
-//   const swrResponse = useSWR(
-//     shouldFetch ? ['/attachment/list', pageId, pageNumber] : null,
-//     fetcher,
-//   );
-
-//   // Utils
-//   const remove = useCallback(async(body: { attachment_id: string }) => {
-//     const { mutate } = swrResponse;
-
-//     try {
-//       await apiPost('/attachments.remove', body);
-//       mutate();
-//     }
-//     catch (err) {
-//       throw err;
-//     }
-//   }, [swrResponse]);
-
-//   return withUtils<Util, IDataAttachmentList, Error>(swrResponse, { remove });
-// };

+ 23 - 0
packages/app/src/stores/plugin.tsx

@@ -0,0 +1,23 @@
+
+import useSWR, { SWRResponse } from 'swr';
+
+import { apiv3Get } from '~/client/util/apiv3-client';
+
+// TODO: Correct types
+const pluginsFetcher = () => {
+  return async() => {
+    const reqUrl = '/plugins-extension';
+    try {
+      const data = await apiv3Get(reqUrl);
+      return data;
+    }
+    catch (err) {
+      // TODO: Error handling
+      console.log('err', err);
+    }
+  };
+};
+
+export const useSWRxPlugins = (): SWRResponse<any | null, Error> => {
+  return useSWR('/pluginsExtension', pluginsFetcher());
+};