next-helios-fe 1.7.6 → 1.7.7

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.
@@ -49,6 +49,8 @@ PERFORMANCE OF THIS SOFTWARE.
49
49
  * https://github.com/wout/svg.filter.js
50
50
  * Copyright (c) 2016 Wout Fierens; Licensed MIT */
51
51
 
52
+ /*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
53
+
52
54
  /**
53
55
  * @license React
54
56
  * react-jsx-runtime.production.min.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,6 @@
29
29
  "react-easy-sort": "^1.6.0",
30
30
  "react-google-recaptcha": "^3.1.0",
31
31
  "react-google-recaptcha-v3": "^1.10.1",
32
- "react-json-to-excel": "^1.0.8",
33
32
  "react-leaflet": "^4.2.1",
34
33
  "react-pin-field": "^3.1.5",
35
34
  "react-syntax-highlighter": "^15.5.0",
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import React, { useState, useEffect, useRef, useMemo } from "react";
3
3
  import { Icon } from "@iconify/react";
4
- import { exportToExcel } from "react-json-to-excel";
4
+ import * as xlsx from "xlsx";
5
5
  import dayjs from "dayjs";
6
6
  import { Form, Button, Dropdown } from "../../components";
7
7
  import { Action, type ActionProps } from "./action";
@@ -141,6 +141,14 @@ export const Table: TableComponentProps = ({
141
141
  });
142
142
  }, [header, data]);
143
143
 
144
+ const handleExportData = (dataTitle: string, data: any[]) => {
145
+ const fileName = `${dataTitle}-${dayjs().format("YYYY-MM-DD_HH-mm-ss")}`;
146
+ const worksheet = xlsx.utils.json_to_sheet(data);
147
+ const workbook = xlsx.utils.book_new();
148
+ xlsx.utils.book_append_sheet(workbook, worksheet, "Data");
149
+ xlsx.writeFile(workbook, fileName + ".xlsx");
150
+ };
151
+
144
152
  const handleOnPreviousClick = () => {
145
153
  if (page - 1 === 1) {
146
154
  paginationRef.current?.scrollTo({
@@ -564,10 +572,27 @@ export const Table: TableComponentProps = ({
564
572
  type="button"
565
573
  options={{ variant: "primary", width: "fit" }}
566
574
  onClick={() => {
567
- exportToExcel(
568
- filteredData,
569
- `${title}-data_${dayjs().format("YYYY-MM-DD_HH-mm-ss")}`
570
- );
575
+ const exportData = filteredData?.map((item) => {
576
+ return header
577
+ ?.filter(
578
+ (headerItem) =>
579
+ !excludedColumn?.includes(headerItem.key)
580
+ )
581
+ ?.reduce((acc, headerItem) => {
582
+ return {
583
+ ...acc,
584
+ "No.": (
585
+ (page - 1) * maxRow +
586
+ filteredData?.indexOf(item) +
587
+ 1
588
+ ).toString(),
589
+ [headerItem.title]:
590
+ item[headerItem.key as keyof typeof item],
591
+ };
592
+ }, {});
593
+ });
594
+
595
+ handleExportData(title || "HMS Data", exportData);
571
596
  }}
572
597
  >
573
598
  Export