فهرست منبع

create useSWRxPageRevisions

yuken 3 سال پیش
والد
کامیت
2838ff3942
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      packages/app/src/stores/page.tsx

+ 15 - 0
packages/app/src/stores/page.tsx

@@ -9,6 +9,7 @@ import {
 } from '~/interfaces/page';
 } from '~/interfaces/page';
 import { IRecordApplicableGrant, IResIsGrantNormalized } from '~/interfaces/page-grant';
 import { IRecordApplicableGrant, IResIsGrantNormalized } from '~/interfaces/page-grant';
 import { IPagingResult } from '~/interfaces/paging-result';
 import { IPagingResult } from '~/interfaces/paging-result';
+import { IRevision } from '~/interfaces/revision';
 
 
 import { apiGet } from '../client/util/apiv1-client';
 import { apiGet } from '../client/util/apiv1-client';
 import { IPageTagsInfo } from '../interfaces/pageTagsInfo';
 import { IPageTagsInfo } from '../interfaces/pageTagsInfo';
@@ -148,6 +149,20 @@ export const useSWRxPageInfoForList = (
   };
   };
 };
 };
 
 
+export const useSWRxPageRevisions = (
+    pageId: string,
+    page: number, // page number of pagination
+    limit: number, // max number of pages in one paginate
+): SWRResponse<IRevision, Error> => {
+
+  return useSWRImmutable<IRevision, Error>(
+    ['/revisions/list', pageId, page, limit],
+    (endpoint, pageId, page, limit) => {
+      return apiv3Get(endpoint, { pageId, page, limit }).then(response => response.data.docs);
+    },
+  );
+};
+
 /*
 /*
  * Grant normalization fetching hooks
  * Grant normalization fetching hooks
  */
  */