dce-reactkit 3.9.3 → 3.9.4-beta-logreviewer.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.9.3",
3
+ "version": "3.9.4-beta-logreviewer.1",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -959,10 +959,23 @@ const LogReviewer: React.FC<Props> = (props) => {
959
959
  const { year, month } = toLoad[i];
960
960
 
961
961
  // Load
962
- const logs = await visitServerEndpoint({
963
- path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
964
- method: 'GET',
965
- });
962
+ let logs: Log[] = [];
963
+ let pageNumber = 1;
964
+ let hasAnotherPage = true;
965
+
966
+ while (hasAnotherPage) {
967
+ const response = await visitServerEndpoint({
968
+ path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
969
+ method: 'GET',
970
+ params: {
971
+ pageNumber,
972
+ },
973
+ });
974
+
975
+ logs = logs.concat(response.items);
976
+ hasAnotherPage = response.hasAnotherPage;
977
+ pageNumber += 1;
978
+ }
966
979
 
967
980
  // Add to map
968
981
  if (!logMap[year]) {
@@ -246,12 +246,14 @@ const initServer = (
246
246
  paramTypes: {
247
247
  year: ParamType.Int,
248
248
  month: ParamType.Int,
249
+ pageNumber: ParamType.Int,
249
250
  },
250
251
  handler: async ({ params }) => {
251
252
  // Get user info
252
253
  const {
253
254
  year,
254
255
  month,
256
+ pageNumber,
255
257
  userId,
256
258
  isAdmin,
257
259
  } = params;
@@ -266,13 +268,17 @@ const initServer = (
266
268
  }
267
269
 
268
270
  // Query for logs
269
- const logs: Log[] = await _logCollection.find({
270
- year,
271
- month,
271
+ const response = await _logCollection.findPaged({
272
+ query: {
273
+ year,
274
+ month,
275
+ },
276
+ perPage: 1000,
277
+ pageNumber,
272
278
  });
273
279
 
274
- // Return logs
275
- return logs;
280
+ // Return response
281
+ return response;
276
282
  },
277
283
  }),
278
284
  );