@dhiraj0720/report1chart 2.2.1 → 2.2.3

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.
@@ -1,221 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- ScrollView,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const DefaultTable = ({ data }) => {
10
- const formatCurrency = (value) => {
11
- const num = Number(value);
12
- if (isNaN(num)) return '0';
13
-
14
- if (num >= 1000000) {
15
- return `${(num / 1000000).toFixed(1)}M`;
16
- } else if (num >= 1000) {
17
- return `${(num / 1000).toFixed(1)}K`;
18
- }
19
- return num.toLocaleString();
20
- };
21
-
22
- if (!Array.isArray(data) || data.length === 0) {
23
- return (
24
- <View style={styles.noDataContainer}>
25
- <Text style={styles.noDataText}>No data available</Text>
26
- </View>
27
- );
28
- }
29
-
30
- return (
31
- <ScrollView horizontal showsHorizontalScrollIndicator={true}>
32
- <View style={styles.table}>
33
- <View style={styles.tableHeader}>
34
- <View style={[styles.headerCell, styles.firstColumn]}>
35
- <Text style={styles.headerText}>ACTIVITY PROFIT/LOSS</Text>
36
- </View>
37
- <View style={styles.headerCell}>
38
- <Text style={styles.headerText}>2024 Actual</Text>
39
- </View>
40
- <View style={styles.headerCell}>
41
- <Text style={styles.headerText}>2025 Actual</Text>
42
- </View>
43
- <View style={styles.headerCell}>
44
- <Text style={styles.headerText}>YoY Change %</Text>
45
- </View>
46
- <View style={styles.headerCell}>
47
- <Text style={styles.headerText}>2025 Budget</Text>
48
- </View>
49
- <View style={styles.headerCell}>
50
- <Text style={styles.headerText}>Variance %</Text>
51
- </View>
52
- <View style={styles.headerCell}>
53
- <Text style={styles.headerText}>GROSS MARGIN %</Text>
54
- </View>
55
- </View>
56
-
57
- {data.map((item, index) => (
58
- <View
59
- key={index}
60
- style={[
61
- styles.tableRow,
62
- item.isTotal ? styles.totalRow : (index % 2 === 0 ? styles.evenRow : styles.oddRow)
63
- ]}
64
- >
65
- <View style={[styles.cell, styles.firstColumn]}>
66
- <Text style={item.isTotal ? styles.totalText : styles.cellText}>
67
- {item.name}
68
- </Text>
69
- </View>
70
-
71
- <View style={styles.cell}>
72
- <Text style={styles.numberText}>
73
- {formatCurrency(item.actual2024)}
74
- </Text>
75
- </View>
76
-
77
- <View style={styles.cell}>
78
- <Text style={styles.numberText}>
79
- {formatCurrency(item.actual2025)}
80
- </Text>
81
- </View>
82
-
83
- <View style={styles.cell}>
84
- <Text style={[
85
- styles.percentText,
86
- item.yoYChangePercent >= 0 ? styles.positive : styles.negative
87
- ]}>
88
- {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
89
- </Text>
90
- </View>
91
-
92
- <View style={styles.cell}>
93
- <Text style={styles.numberText}>
94
- {formatCurrency(item.budget2025)}
95
- </Text>
96
- </View>
97
-
98
- <View style={styles.cell}>
99
- <Text style={[
100
- styles.percentText,
101
- item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
102
- ]}>
103
- {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
104
- </Text>
105
- </View>
106
-
107
- <View style={styles.cell}>
108
- <Text style={[
109
- styles.percentText,
110
- styles.grossMargin
111
- ]}>
112
- {item.grossMarginPercent}%
113
- </Text>
114
- </View>
115
- </View>
116
- ))}
117
- </View>
118
- </ScrollView>
119
- );
120
- };
121
-
122
- const styles = StyleSheet.create({
123
- table: {
124
- minWidth: 700,
125
- marginBottom: 20,
126
- },
127
- tableHeader: {
128
- flexDirection: 'row',
129
- backgroundColor: '#2c3e50',
130
- borderBottomWidth: 1,
131
- borderBottomColor: '#ddd',
132
- },
133
- headerCell: {
134
- flex: 1,
135
- padding: 10,
136
- minWidth: 100,
137
- justifyContent: 'center',
138
- alignItems: 'center',
139
- borderRightWidth: 1,
140
- borderRightColor: '#444',
141
- },
142
- firstColumn: {
143
- flex: 1.5,
144
- minWidth: 180,
145
- },
146
- headerText: {
147
- color: '#fff',
148
- fontWeight: '600',
149
- fontSize: 11,
150
- textAlign: 'center',
151
- },
152
- tableRow: {
153
- flexDirection: 'row',
154
- borderBottomWidth: 1,
155
- borderBottomColor: '#eee',
156
- minHeight: 40,
157
- },
158
- evenRow: {
159
- backgroundColor: '#fff',
160
- },
161
- oddRow: {
162
- backgroundColor: '#f9f9f9',
163
- },
164
- totalRow: {
165
- backgroundColor: '#e8f5e9',
166
- borderTopWidth: 2,
167
- borderTopColor: '#4CAF50',
168
- borderBottomWidth: 2,
169
- borderBottomColor: '#4CAF50',
170
- },
171
- cell: {
172
- flex: 1,
173
- padding: 8,
174
- minWidth: 100,
175
- justifyContent: 'center',
176
- alignItems: 'center',
177
- borderRightWidth: 1,
178
- borderRightColor: '#eee',
179
- },
180
- cellText: {
181
- fontSize: 12,
182
- color: '#333',
183
- textAlign: 'center',
184
- },
185
- totalText: {
186
- fontSize: 12,
187
- fontWeight: '700',
188
- color: '#2c3e50',
189
- textAlign: 'center',
190
- },
191
- numberText: {
192
- fontSize: 11,
193
- fontWeight: '500',
194
- color: '#333',
195
- },
196
- percentText: {
197
- fontSize: 12,
198
- fontWeight: '600',
199
- },
200
- positive: {
201
- color: '#27ae60',
202
- },
203
- negative: {
204
- color: '#e74c3c',
205
- },
206
- grossMargin: {
207
- color: '#2c3e50',
208
- fontWeight: '700',
209
- },
210
- noDataContainer: {
211
- padding: 40,
212
- alignItems: 'center',
213
- },
214
- noDataText: {
215
- fontSize: 16,
216
- color: '#999',
217
- textAlign: 'center',
218
- },
219
- });
220
-
221
- export default DefaultTable;
@@ -1,250 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- ScrollView,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const FreezeTable = ({ data }) => {
10
- const formatCurrency = (value) => {
11
- const num = Number(value);
12
- if (isNaN(num)) return '0';
13
-
14
- if (num >= 1000000) {
15
- return `${(num / 1000000).toFixed(1)}M`;
16
- } else if (num >= 1000) {
17
- return `${(num / 1000).toFixed(1)}K`;
18
- }
19
- return num.toLocaleString();
20
- };
21
-
22
- if (!Array.isArray(data) || data.length === 0) {
23
- return (
24
- <View style={styles.noDataContainer}>
25
- <Text style={styles.noDataText}>No data available</Text>
26
- </View>
27
- );
28
- }
29
-
30
- return (
31
- <View style={styles.container}>
32
- <View style={styles.fixedColumn}>
33
- <View style={[styles.fixedHeader, styles.fixedFirstCell]}>
34
- <Text style={styles.fixedHeaderText}>ACTIVITY</Text>
35
- </View>
36
- {data.map((item, index) => (
37
- <View
38
- key={index}
39
- style={[
40
- styles.fixedRow,
41
- item.isTotal && styles.fixedTotalRow,
42
- ]}
43
- >
44
- <Text style={[
45
- styles.fixedCellText,
46
- item.isTotal && styles.fixedTotalText
47
- ]}>
48
- {item.name}
49
- </Text>
50
- </View>
51
- ))}
52
- </View>
53
-
54
- <ScrollView horizontal showsHorizontalScrollIndicator={true}>
55
- <View style={styles.scrollableColumns}>
56
- <View style={styles.scrollableHeaderRow}>
57
- {['2024 Actual', '2025 Actual', 'YoY Change %', '2025 Budget', 'Variance %', 'GROSS MARGIN %'].map((header, idx) => (
58
- <View key={idx} style={styles.scrollableHeader}>
59
- <Text style={styles.scrollableHeaderText}>{header}</Text>
60
- </View>
61
- ))}
62
- </View>
63
-
64
- {data.map((item, rowIndex) => (
65
- <View
66
- key={rowIndex}
67
- style={[
68
- styles.scrollableDataRow,
69
- item.isTotal && styles.scrollableTotalDataRow,
70
- ]}
71
- >
72
- <View style={styles.scrollableDataCell}>
73
- <Text style={styles.scrollableDataText}>
74
- {formatCurrency(item.actual2024)}
75
- </Text>
76
- </View>
77
-
78
- <View style={styles.scrollableDataCell}>
79
- <Text style={styles.scrollableDataText}>
80
- {formatCurrency(item.actual2025)}
81
- </Text>
82
- </View>
83
-
84
- <View style={styles.scrollableDataCell}>
85
- <Text style={[
86
- styles.scrollablePercent,
87
- item.yoYChangePercent >= 0 ? styles.positive : styles.negative
88
- ]}>
89
- {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
90
- </Text>
91
- </View>
92
-
93
- <View style={styles.scrollableDataCell}>
94
- <Text style={styles.scrollableDataText}>
95
- {formatCurrency(item.budget2025)}
96
- </Text>
97
- </View>
98
-
99
- <View style={styles.scrollableDataCell}>
100
- <Text style={[
101
- styles.scrollablePercent,
102
- item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
103
- ]}>
104
- {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
105
- </Text>
106
- </View>
107
-
108
- <View style={styles.scrollableDataCell}>
109
- <Text style={[
110
- styles.scrollablePercent,
111
- styles.grossMargin
112
- ]}>
113
- {item.grossMarginPercent}%
114
- </Text>
115
- </View>
116
- </View>
117
- ))}
118
- </View>
119
- </ScrollView>
120
- </View>
121
- );
122
- };
123
-
124
- const styles = StyleSheet.create({
125
- container: {
126
- flex: 1,
127
- flexDirection: 'row',
128
- },
129
- fixedColumn: {
130
- width: 180,
131
- borderRightWidth: 2,
132
- borderRightColor: '#ddd',
133
- backgroundColor: '#fff',
134
- },
135
- fixedFirstCell: {
136
- backgroundColor: '#2c3e50',
137
- justifyContent: 'center',
138
- alignItems: 'center',
139
- },
140
- fixedHeader: {
141
- height: 50,
142
- justifyContent: 'center',
143
- alignItems: 'center',
144
- backgroundColor: '#2c3e50',
145
- borderBottomWidth: 1,
146
- borderBottomColor: '#444',
147
- borderRightWidth: 1,
148
- borderRightColor: '#444',
149
- minWidth: 120,
150
- },
151
- fixedHeaderText: {
152
- color: '#fff',
153
- fontWeight: '600',
154
- fontSize: 12,
155
- textAlign: 'center',
156
- },
157
- fixedRow: {
158
- height: 45,
159
- justifyContent: 'center',
160
- paddingHorizontal: 10,
161
- borderBottomWidth: 1,
162
- borderBottomColor: '#eee',
163
- },
164
- fixedTotalRow: {
165
- backgroundColor: '#e8f5e9',
166
- borderTopWidth: 2,
167
- borderTopColor: '#4CAF50',
168
- borderBottomWidth: 2,
169
- borderBottomColor: '#4CAF50',
170
- },
171
- fixedCellText: {
172
- fontSize: 12,
173
- color: '#333',
174
- fontWeight: '500',
175
- },
176
- fixedTotalText: {
177
- fontWeight: '700',
178
- color: '#2c3e50',
179
- },
180
- scrollableColumns: {
181
- flex: 1,
182
- },
183
- scrollableHeaderRow: {
184
- flexDirection: 'row',
185
- },
186
- scrollableHeader: {
187
- height: 50,
188
- justifyContent: 'center',
189
- alignItems: 'center',
190
- backgroundColor: '#2c3e50',
191
- borderBottomWidth: 1,
192
- borderBottomColor: '#444',
193
- borderRightWidth: 1,
194
- borderRightColor: '#444',
195
- minWidth: 120,
196
- },
197
- scrollableHeaderText: {
198
- color: '#fff',
199
- fontWeight: '600',
200
- fontSize: 12,
201
- textAlign: 'center',
202
- },
203
- scrollableDataRow: {
204
- flexDirection: 'row',
205
- height: 45,
206
- borderBottomWidth: 1,
207
- borderBottomColor: '#eee',
208
- },
209
- scrollableTotalDataRow: {
210
- backgroundColor: '#e8f5e9',
211
- },
212
- scrollableDataCell: {
213
- minWidth: 120,
214
- justifyContent: 'center',
215
- alignItems: 'center',
216
- borderRightWidth: 1,
217
- borderRightColor: '#eee',
218
- paddingHorizontal: 8,
219
- },
220
- scrollableDataText: {
221
- fontSize: 12,
222
- fontWeight: '500',
223
- color: '#333',
224
- },
225
- scrollablePercent: {
226
- fontSize: 12,
227
- fontWeight: '600',
228
- },
229
- positive: {
230
- color: '#27ae60',
231
- },
232
- negative: {
233
- color: '#e74c3c',
234
- },
235
- grossMargin: {
236
- color: '#2c3e50',
237
- fontWeight: '700',
238
- },
239
- noDataContainer: {
240
- padding: 40,
241
- alignItems: 'center',
242
- },
243
- noDataText: {
244
- fontSize: 16,
245
- color: '#999',
246
- textAlign: 'center',
247
- },
248
- });
249
-
250
- export default FreezeTable;
@@ -1,121 +0,0 @@
1
- import React, { useState } from 'react';
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- TouchableOpacity,
7
- ScrollView,
8
- } from 'react-native';
9
- import ReportDetail from './ReportDetail';
10
- import ReportCard from '../components/common/ReportCard';
11
- import ApiService from '../api/ApiService';
12
-
13
- const ReportDashboard = ({ reports, onReportSelect, onClose }) => {
14
- const [selectedReport, setSelectedReport] = useState(null);
15
- const [loading, setLoading] = useState(false);
16
- const [error, setError] = useState(null);
17
-
18
- const handleReportClick = async (report) => {
19
- setLoading(true);
20
- setError(null);
21
-
22
- try {
23
- const data = await ApiService.fetchReportData(report.apiConfig);
24
-
25
- setSelectedReport({
26
- ...report,
27
- data: data
28
- });
29
-
30
- if (onReportSelect) {
31
- onReportSelect(report.name);
32
- }
33
- } catch (err) {
34
- setError('Failed to fetch data');
35
- console.error(err);
36
- } finally {
37
- setLoading(false);
38
- }
39
- };
40
-
41
- const handleBack = () => {
42
- setSelectedReport(null);
43
- setError(null);
44
- };
45
-
46
- if (selectedReport) {
47
- return (
48
- <ReportDetail
49
- report={selectedReport}
50
- loading={loading}
51
- error={error}
52
- onBack={handleBack}
53
- onClose={onClose}
54
- />
55
- );
56
- }
57
-
58
- return (
59
- <View style={styles.container}>
60
- <View style={styles.header}>
61
- <Text style={styles.headerTitle}>Reports Dashboard</Text>
62
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
63
- <Text style={styles.closeText}>×</Text>
64
- </TouchableOpacity>
65
- </View>
66
-
67
- <ScrollView style={styles.reportsList}>
68
- {reports.map((report) => (
69
- <ReportCard
70
- key={report.id}
71
- report={report}
72
- onPress={() => handleReportClick(report)}
73
- />
74
- ))}
75
- </ScrollView>
76
- </View>
77
- );
78
- };
79
-
80
- const styles = StyleSheet.create({
81
- container: {
82
- flex: 1,
83
- backgroundColor: '#f8f9fa',
84
- },
85
- header: {
86
- flexDirection: 'row',
87
- alignItems: 'center',
88
- justifyContent: 'space-between',
89
- backgroundColor: '#fff',
90
- paddingHorizontal: 16,
91
- paddingVertical: 12,
92
- borderBottomWidth: 1,
93
- borderBottomColor: '#e0e0e0',
94
- },
95
- headerTitle: {
96
- fontSize: 18,
97
- fontWeight: '700',
98
- color: '#000',
99
- flex: 1,
100
- textAlign: 'center',
101
- },
102
- closeButton: {
103
- width: 32,
104
- height: 32,
105
- borderRadius: 16,
106
- backgroundColor: '#f0f0f0',
107
- justifyContent: 'center',
108
- alignItems: 'center',
109
- },
110
- closeText: {
111
- fontSize: 20,
112
- color: '#666',
113
- fontWeight: '300',
114
- },
115
- reportsList: {
116
- flex: 1,
117
- padding: 16,
118
- },
119
- });
120
-
121
- export default ReportDashboard;