@dhiraj0720/report1chart 2.2.2 → 2.2.4

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,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;
@@ -1,222 +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 DefaultTable from '../components/tables/DefaultTable';
10
- import CompactTable from '../components/tables/CompactTable';
11
- import FreezeTable from '../components/tables/FreezeTable';
12
- import BarChart from '../components/charts/BarChart';
13
- import PieChart from '../components/charts/PieChart';
14
- import LineChart from '../components/charts/LineChart';
15
- import LoadingSpinner from '../components/common/LoadingSpinner';
16
- import ErrorDisplay from '../components/common/ErrorDisplay';
17
-
18
- const ReportDetail = ({ report, loading, error, onBack, onClose }) => {
19
- const [viewType, setViewType] = useState(report.subType || 'default');
20
-
21
- const renderContent = () => {
22
- if (loading) {
23
- return <LoadingSpinner message="Loading report data..." />;
24
- }
25
-
26
- if (error) {
27
- return <ErrorDisplay error={error} onRetry={() => onBack()} />;
28
- }
29
-
30
- if (!report.data || (Array.isArray(report.data) && report.data.length === 0)) {
31
- return (
32
- <View style={styles.noDataContainer}>
33
- <Text style={styles.noDataText}>No data available</Text>
34
- </View>
35
- );
36
- }
37
-
38
- switch (report.type) {
39
- case 'table':
40
- return renderTable();
41
- case 'bar':
42
- return <BarChart data={report.data} title={report.title} />;
43
- case 'pie':
44
- return <PieChart data={report.data} title={report.title} />;
45
- case 'line':
46
- return <LineChart data={report.data} title={report.title} />;
47
- default:
48
- return <BarChart data={report.data} title={report.title} />;
49
- }
50
- };
51
-
52
- const renderTable = () => {
53
- switch (viewType) {
54
- case 'compact':
55
- return <CompactTable data={report.data} />;
56
- case 'freeze':
57
- return <FreezeTable data={report.data} />;
58
- default:
59
- return <DefaultTable data={report.data} />;
60
- }
61
- };
62
-
63
- return (
64
- <View style={styles.container}>
65
- <View style={styles.header}>
66
- <TouchableOpacity
67
- style={styles.backButton}
68
- onPress={onBack}
69
- >
70
- <Text style={styles.backText}>‹</Text>
71
- <Text style={styles.backButtonText}>Back</Text>
72
- </TouchableOpacity>
73
- <Text style={styles.headerTitle} numberOfLines={1}>
74
- {report.title || report.name}
75
- </Text>
76
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
77
- <Text style={styles.closeText}>×</Text>
78
- </TouchableOpacity>
79
- </View>
80
-
81
- {report.type === 'table' && (
82
- <View style={styles.viewTypeSelector}>
83
- <TouchableOpacity
84
- style={[
85
- styles.viewTypeButton,
86
- viewType === 'default' && styles.activeViewType
87
- ]}
88
- onPress={() => setViewType('default')}
89
- >
90
- <Text style={[
91
- styles.viewTypeText,
92
- viewType === 'default' && styles.activeViewTypeText
93
- ]}>Default</Text>
94
- </TouchableOpacity>
95
-
96
- <TouchableOpacity
97
- style={[
98
- styles.viewTypeButton,
99
- viewType === 'compact' && styles.activeViewType
100
- ]}
101
- onPress={() => setViewType('compact')}
102
- >
103
- <Text style={[
104
- styles.viewTypeText,
105
- viewType === 'compact' && styles.activeViewTypeText
106
- ]}>Compact</Text>
107
- </TouchableOpacity>
108
-
109
- <TouchableOpacity
110
- style={[
111
- styles.viewTypeButton,
112
- viewType === 'freeze' && styles.activeViewType
113
- ]}
114
- onPress={() => setViewType('freeze')}
115
- >
116
- <Text style={[
117
- styles.viewTypeText,
118
- viewType === 'freeze' && styles.activeViewTypeText
119
- ]}>Freeze</Text>
120
- </TouchableOpacity>
121
- </View>
122
- )}
123
-
124
- <ScrollView style={styles.content}>
125
- {renderContent()}
126
- </ScrollView>
127
- </View>
128
- );
129
- };
130
-
131
- const styles = StyleSheet.create({
132
- container: {
133
- flex: 1,
134
- backgroundColor: '#f8f9fa',
135
- },
136
- header: {
137
- flexDirection: 'row',
138
- alignItems: 'center',
139
- justifyContent: 'space-between',
140
- backgroundColor: '#fff',
141
- paddingHorizontal: 16,
142
- paddingVertical: 12,
143
- borderBottomWidth: 1,
144
- borderBottomColor: '#e0e0e0',
145
- },
146
- headerTitle: {
147
- fontSize: 18,
148
- fontWeight: '700',
149
- color: '#000',
150
- flex: 1,
151
- textAlign: 'center',
152
- },
153
- backButton: {
154
- flexDirection: 'row',
155
- alignItems: 'center',
156
- padding: 8,
157
- },
158
- backText: {
159
- fontSize: 24,
160
- color: '#4CAF50',
161
- marginRight: 4,
162
- },
163
- backButtonText: {
164
- fontSize: 16,
165
- color: '#4CAF50',
166
- fontWeight: '600',
167
- },
168
- closeButton: {
169
- width: 32,
170
- height: 32,
171
- borderRadius: 16,
172
- backgroundColor: '#f0f0f0',
173
- justifyContent: 'center',
174
- alignItems: 'center',
175
- },
176
- closeText: {
177
- fontSize: 20,
178
- color: '#666',
179
- fontWeight: '300',
180
- },
181
- content: {
182
- flex: 1,
183
- padding: 16,
184
- },
185
- viewTypeSelector: {
186
- flexDirection: 'row',
187
- backgroundColor: '#f0f0f0',
188
- borderRadius: 8,
189
- padding: 4,
190
- margin: 16,
191
- alignSelf: 'center',
192
- },
193
- viewTypeButton: {
194
- paddingHorizontal: 16,
195
- paddingVertical: 8,
196
- borderRadius: 6,
197
- marginHorizontal: 2,
198
- },
199
- activeViewType: {
200
- backgroundColor: '#fff',
201
- },
202
- viewTypeText: {
203
- fontSize: 13,
204
- fontWeight: '500',
205
- color: '#666',
206
- },
207
- activeViewTypeText: {
208
- color: '#4CAF50',
209
- fontWeight: '600',
210
- },
211
- noDataContainer: {
212
- padding: 40,
213
- alignItems: 'center',
214
- },
215
- noDataText: {
216
- fontSize: 16,
217
- color: '#999',
218
- textAlign: 'center',
219
- },
220
- });
221
-
222
- export default ReportDetail;