@dhiraj0720/report1chart 2.2.1 → 2.2.2

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,12 +1,12 @@
1
1
  {
2
2
  "name": "@dhiraj0720/report1chart",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "main": "src/index.jsx",
5
5
  "scripts": {
6
6
  "test": "echo 'No tests'"
7
7
  },
8
8
  "dependencies": {
9
- "axios": "^1.6.0"
9
+ "axios": "^1.13.2"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "react": ">=16.8.0",
@@ -21,5 +21,10 @@
21
21
  ],
22
22
  "author": "Dhiraj",
23
23
  "license": "MIT",
24
- "description": "A simple report chart and table package for React Native"
25
- }
24
+ "description": "A simple report chart and table package for React Native",
25
+ "devDependencies": {
26
+ "@babel/core": "^7.28.5",
27
+ "@babel/preset-env": "^7.28.5",
28
+ "@babel/preset-react": "^7.28.5"
29
+ }
30
+ }
@@ -43,10 +43,7 @@ class ApiService {
43
43
  return this.transformRevenueByMode(data);
44
44
  } else if (url.includes('shipment-by-direction')) {
45
45
  return this.transformShipmentByDirection(data);
46
- } else if (url.includes('revenue-trend')) {
47
- return this.transformRevenueTrend(data);
48
46
  }
49
-
50
47
  return data;
51
48
  }
52
49
 
@@ -95,17 +92,6 @@ class ApiService {
95
92
  return this.getShipmentFallbackData();
96
93
  }
97
94
 
98
- transformRevenueTrend(data) {
99
- if (data.labels && data.values) {
100
- return {
101
- labels: data.labels,
102
- values: data.values
103
- };
104
- }
105
-
106
- return this.getRevenueTrendFallbackData();
107
- }
108
-
109
95
  calculatePercentageChange(oldValue, newValue) {
110
96
  if (!oldValue || oldValue === 0) return 0;
111
97
  return Number(((newValue - oldValue) / Math.abs(oldValue)) * 100).toFixed(1);
@@ -118,10 +104,7 @@ class ApiService {
118
104
  return this.getRevenueByModeFallbackData();
119
105
  } else if (url.includes('shipment-by-direction')) {
120
106
  return this.getShipmentFallbackData();
121
- } else if (url.includes('revenue-trend')) {
122
- return this.getRevenueTrendFallbackData();
123
107
  }
124
-
125
108
  return [];
126
109
  }
127
110
 
@@ -150,13 +133,6 @@ class ApiService {
150
133
  { direction: "Import", shipments: 546 }
151
134
  ];
152
135
  }
153
-
154
- getRevenueTrendFallbackData() {
155
- return {
156
- labels: ["01-2025", "02-2025", "03-2025", "04-2025", "05-2025", "06-2025"],
157
- values: [16011213, 13368072, 17004674, 19065790, 19978378, 20766951]
158
- };
159
- }
160
136
  }
161
137
 
162
138
  export default new ApiService();
@@ -32,7 +32,7 @@ const DefaultTable = ({ data }) => {
32
32
  <View style={styles.table}>
33
33
  <View style={styles.tableHeader}>
34
34
  <View style={[styles.headerCell, styles.firstColumn]}>
35
- <Text style={styles.headerText}>ACTIVITY PROFIT/LOSS</Text>
35
+ <Text style={styles.headerText}>ACTIVITY</Text>
36
36
  </View>
37
37
  <View style={styles.headerCell}>
38
38
  <Text style={styles.headerText}>2024 Actual</Text>
@@ -30,7 +30,7 @@ const ReportDetail = ({ report, loading, error, onBack, onClose }) => {
30
30
  if (!report.data || (Array.isArray(report.data) && report.data.length === 0)) {
31
31
  return (
32
32
  <View style={styles.noDataContainer}>
33
- <Text style={styles.noDataText}>No data available for this report</Text>
33
+ <Text style={styles.noDataText}>No data available</Text>
34
34
  </View>
35
35
  );
36
36
  }
@@ -1,38 +0,0 @@
1
- export const COLORS = {
2
- primary: '#4CAF50',
3
- primaryDark: '#388E3C',
4
- primaryLight: '#C8E6C9',
5
- secondary: '#2196F3',
6
- accent: '#FF9800',
7
- success: '#27ae60',
8
- warning: '#f39c12',
9
- danger: '#e74c3c',
10
- info: '#3498db',
11
- dark: '#2c3e50',
12
- light: '#ecf0f1',
13
- white: '#ffffff',
14
- black: '#000000',
15
- gray: '#95a5a6',
16
- grayDark: '#7f8c8d',
17
- grayLight: '#bdc3c7'
18
- };
19
-
20
- export const API_STATUS = {
21
- IDLE: 'idle',
22
- LOADING: 'loading',
23
- SUCCESS: 'success',
24
- ERROR: 'error'
25
- };
26
-
27
- export const CHART_TYPES = {
28
- BAR: 'bar',
29
- LINE: 'line',
30
- PIE: 'pie',
31
- TABLE: 'table'
32
- };
33
-
34
- export const TABLE_VIEW_TYPES = {
35
- DEFAULT: 'default',
36
- COMPACT: 'compact',
37
- FREEZE: 'freeze'
38
- };
@@ -1,24 +0,0 @@
1
- export const formatCurrency = (value) => {
2
- const num = Number(value);
3
- if (isNaN(num)) return '0';
4
-
5
- if (num >= 1000000) {
6
- return `${(num / 1000000).toFixed(1)}M`;
7
- } else if (num >= 1000) {
8
- return `${(num / 1000).toFixed(1)}K`;
9
- }
10
- return num.toLocaleString();
11
- };
12
-
13
- export const formatNumber = (num) => {
14
- return num.toLocaleString();
15
- };
16
-
17
- export const formatPercentage = (value, decimals = 1) => {
18
- return `${value >= 0 ? '+' : ''}${value.toFixed(decimals)}%`;
19
- };
20
-
21
- export const getColor = (index) => {
22
- const colors = ['#4CAF50', '#2196F3', '#FF9800', '#E91E63', '#9C27B0', '#00BCD4'];
23
- return colors[index % colors.length];
24
- };
@@ -1,60 +0,0 @@
1
- export const isValidUrl = (url) => {
2
- try {
3
- new URL(url);
4
- return true;
5
- } catch (error) {
6
- return false;
7
- }
8
- };
9
-
10
- export const isValidApiResponse = (data) => {
11
- if (!data) return false;
12
-
13
- // Check if data is array or has data property
14
- if (Array.isArray(data)) {
15
- return data.length > 0;
16
- }
17
-
18
- if (data.data && Array.isArray(data.data)) {
19
- return data.data.length > 0;
20
- }
21
-
22
- if (data.values && Array.isArray(data.values)) {
23
- return data.values.length > 0;
24
- }
25
-
26
- return false;
27
- };
28
-
29
- export const validateApiConfig = (apiConfig) => {
30
- const errors = [];
31
-
32
- if (!apiConfig || typeof apiConfig !== 'object') {
33
- errors.push('API configuration is required');
34
- return errors;
35
- }
36
-
37
- if (!apiConfig.url || typeof apiConfig.url !== 'string') {
38
- errors.push('API URL is required and must be a string');
39
- } else if (!isValidUrl(apiConfig.url)) {
40
- errors.push('Invalid API URL format');
41
- }
42
-
43
- if (apiConfig.method && typeof apiConfig.method !== 'string') {
44
- errors.push('API method must be a string');
45
- }
46
-
47
- if (apiConfig.token && typeof apiConfig.token !== 'string') {
48
- errors.push('API token must be a string');
49
- }
50
-
51
- return errors;
52
- };
53
-
54
- export const formatErrorMessage = (error) => {
55
- if (typeof error === 'string') return error;
56
- if (error.message) return error.message;
57
- if (error.response?.data?.message) return error.response.data.message;
58
- if (error.response?.statusText) return `${error.response.status}: ${error.response.statusText}`;
59
- return 'An unknown error occurred';
60
- };