@appcorp/fusion-storybook 0.2.32 → 0.2.33

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.
@@ -6,7 +6,6 @@ import { getCachedWorkspaceSync } from "../workspace/cache";
6
6
  import converter from "json-2-csv";
7
7
  import { Timeline } from "../../components/timeline";
8
8
  import { useTranslations } from "next-intl";
9
- import { CSVS } from "../../constants";
10
9
  import { CLASS_API_ROUTES, pageLimit } from "./constants";
11
10
  import { invalidateClassesCache } from "./cache";
12
11
  import { CLASS_ACTION_TYPES, useClassContext } from "./context";
@@ -14,8 +13,8 @@ import { useRef, useEffect, useCallback } from "react";
14
13
  const workspace = getCachedWorkspaceSync();
15
14
  const POLL_INTERVAL_MS = 2000;
16
15
  const POLL_TIMEOUT_MS = 300000;
17
- const handleGetAllRecords = async (schoolId) => {
18
- const response = await fetch(`${CLASS_API_ROUTES.UNIT}?pageLimit=1000&currentPage=1&schoolId=${schoolId}`);
16
+ const handleGetAllRecords = async (schoolId, pageLimit) => {
17
+ const response = await fetch(`${CLASS_API_ROUTES.UNIT}?pageLimit=${pageLimit}&currentPage=1&schoolId=${schoolId}`);
19
18
  const result = await response.json();
20
19
  const csv = await converter.json2csv(result.items || [], {});
21
20
  const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
@@ -210,7 +209,8 @@ export const ClassMoreActions = () => {
210
209
  id: "1",
211
210
  title: t("downloadEmptyCsvTemplate"),
212
211
  handleOnClick: async () => {
213
- await downloadFromUrl(CSVS.Class, "class-template.csv");
212
+ var _a;
213
+ await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1);
214
214
  },
215
215
  },
216
216
  { id: "2", title: t("addYourDataToTheCsv") },
@@ -225,7 +225,7 @@ export const ClassMoreActions = () => {
225
225
  title: t("downloadPopulatedCsvTemplate"),
226
226
  handleOnClick: async () => {
227
227
  var _a;
228
- await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "");
228
+ await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1000);
229
229
  },
230
230
  },
231
231
  { id: "2", title: t("updateYourDataInTheCsv") },
@@ -6,7 +6,6 @@ import { getCachedWorkspaceSync } from "../workspace/cache";
6
6
  import converter from "json-2-csv";
7
7
  import { Timeline } from "../../components/timeline";
8
8
  import { useTranslations } from "next-intl";
9
- import { CSVS } from "../../constants";
10
9
  import { teacherFormValidation } from "./validate";
11
10
  import { TEACHER_API_ROUTES, pageLimit } from "./constants";
12
11
  import { invalidateTeachersCache } from "./cache";
@@ -15,12 +14,8 @@ import { useRef, useEffect, useCallback } from "react";
15
14
  const workspace = getCachedWorkspaceSync();
16
15
  const POLL_INTERVAL_MS = 2000;
17
16
  const POLL_TIMEOUT_MS = 300000;
18
- const handleGetAllRecords = async (schoolId) => {
19
- const response = await fetch(`${TEACHER_API_ROUTES.UNIT}?pageLimit=1000&currentPage=1&schoolId=${schoolId}`, {
20
- // headers: {
21
- // "x-api-token": process.env.NEXT_PUBLIC_API_KEY!,
22
- // },
23
- });
17
+ const handleGetAllRecords = async (schoolId, pageLimit) => {
18
+ const response = await fetch(`${TEACHER_API_ROUTES.UNIT}?pageLimit=${pageLimit}&currentPage=1&schoolId=${schoolId}`);
24
19
  const result = await response.json();
25
20
  const csv = await converter.json2csv(result.items || [], {});
26
21
  const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
@@ -224,7 +219,8 @@ export const TeacherMoreActions = () => {
224
219
  id: "1",
225
220
  title: t("moreActionsDownloadEmptyCsvTemplate"),
226
221
  handleOnClick: async () => {
227
- await downloadFromUrl(CSVS.Teacher, "teacher-template.csv");
222
+ var _a;
223
+ await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1);
228
224
  },
229
225
  },
230
226
  { id: "2", title: t("moreActionsAddYourDataToTheCsv") },
@@ -239,7 +235,7 @@ export const TeacherMoreActions = () => {
239
235
  title: t("moreActionsDownloadPopulatedCsvTemplate"),
240
236
  handleOnClick: async () => {
241
237
  var _a;
242
- await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "");
238
+ await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1000);
243
239
  },
244
240
  },
245
241
  { id: "2", title: t("moreActionsUpdateYourDataToTheCsv") },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",