@pushwoosh/smart-components-kit 2.7.0 → 2.7.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.
@@ -7,6 +7,7 @@ import { DangerTriangleIcon, DownloadIcon } from '@pushwoosh/kit-icons';
7
7
  import { Text } from '@pushwoosh/kit-typography';
8
8
  import { useLang } from '../polyglot';
9
9
  import { useExportService } from '../useExportService';
10
+ import { exportFileName } from './exportFileName';
10
11
  import { useExportVisibility } from './hooks/useExportVisibility';
11
12
  export const ExportCsvBanner = ({
12
13
  exportTask,
@@ -44,9 +45,12 @@ export const ExportCsvBanner = ({
44
45
  }, [clearExport, exportTask, getStatus, show]);
45
46
  useEffect(() => {
46
47
  if (taskResult) {
47
- updateExportTask({
48
+ const filename = exportFileName(taskResult);
49
+ updateExportTask(filename ? {
48
50
  status: 'STATUS_SUCCESS',
49
- filename: taskResult.data.file
51
+ filename
52
+ } : {
53
+ status: 'STATUS_FAILED'
50
54
  });
51
55
  }
52
56
  }, [taskResult, updateExportTask]);
@@ -67,13 +71,14 @@ export const ExportCsvBanner = ({
67
71
  status,
68
72
  args
69
73
  } = res[0];
70
- const {
71
- data
72
- } = result;
74
+ const filename = exportFileName(result);
75
+ if (status === 'STATUS_SUCCESS' && !filename) {
76
+ return;
77
+ }
73
78
  updateExportTask({
74
79
  id,
75
80
  status,
76
- filename: data.file,
81
+ filename,
77
82
  args,
78
83
  progressTitle: lang({
79
84
  message: 'SMART.EXPORT_CSV.PROGRESS_TITLE'
@@ -0,0 +1,3 @@
1
+ import { type ResultResponse_result, type TaskInfo_result } from '@pushwoosh/rpc-v2-http-api-data/pushwoosh_export_messages_v2';
2
+ /** File of a finished export task; a running task has no `data` in its result yet. */
3
+ export declare const exportFileName: (result: ResultResponse_result | TaskInfo_result | undefined) => string | undefined;
@@ -0,0 +1,5 @@
1
+ /** File of a finished export task; a running task has no `data` in its result yet. */
2
+ export const exportFileName = result => {
3
+ const data = result?.data;
4
+ return data && 'file' in data && data.file ? data.file : undefined;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/smart-components-kit",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "Stateful, data-connected React components shared by Pushwoosh micro-frontends",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,13 +31,13 @@
31
31
  "@pushwoosh/kit-helpers": "^4.18.0",
32
32
  "@pushwoosh/kit-icons": "^3.0.2",
33
33
  "@pushwoosh/kit-typography": "^2.2.0",
34
- "@pushwoosh/rpc-v2-http-api-data": "^0.2.556",
34
+ "@pushwoosh/rpc-v2-http-api-data": "^0.2.564",
35
35
  "jwt-decode": "^4.0.0",
36
36
  "react-hook-form": "^7.91.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@pushwoosh/frontend-builder-engine": "^5.6.0",
40
- "@pushwoosh/spa-context": "^3.10.0",
40
+ "@pushwoosh/spa-context": "^3.13.1",
41
41
  "@svgr/webpack": "^8.1.0",
42
42
  "@testing-library/dom": "^10.4.2",
43
43
  "@testing-library/react": "^16.3.3",