@dhiraj0720/report1chart 2.2.6 → 2.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhiraj0720/report1chart",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "main": "src/index.jsx",
5
5
  "scripts": {
6
6
  "test": "echo 'No tests'"
@@ -0,0 +1,22 @@
1
+ import axios from 'axios';
2
+
3
+ export const fetchReport3Table = async (url, token) => {
4
+ const res = await axios.get(url, {
5
+ headers: { Authorization: token },
6
+ });
7
+ return res.data;
8
+ };
9
+
10
+ export const fetchReport3Line = async (url, token) => {
11
+ const res = await axios.get(url, {
12
+ headers: { Authorization: token },
13
+ });
14
+ return res.data;
15
+ };
16
+
17
+ export const fetchReport3Bar = async (url, token) => {
18
+ const res = await axios.get(url, {
19
+ headers: { Authorization: token },
20
+ });
21
+ return res.data;
22
+ };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { View, Text, StyleSheet } from 'react-native';
3
+
4
+ const BarChartReport3 = ({ data }) => {
5
+ return (
6
+ <View style={styles.card}>
7
+ <Text style={styles.title}>{data.title}</Text>
8
+ {data.series.map(s => (
9
+ <Text key={s.name} style={styles.legend}>{s.name}</Text>
10
+ ))}
11
+ </View>
12
+ );
13
+ };
14
+
15
+ const styles = StyleSheet.create({
16
+ card: { padding: 12, backgroundColor: '#fff', borderRadius: 12, marginTop: 12 },
17
+ title: { fontWeight: '700', textAlign: 'center' },
18
+ legend: { textAlign: 'center' },
19
+ });
20
+
21
+ export default BarChartReport3;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { View, Text, ScrollView, StyleSheet } from 'react-native';
3
+
4
+ const FreezeTableReport3 = ({ rows }) => {
5
+ return (
6
+ <View style={styles.container}>
7
+ {/* Frozen column */}
8
+ <View style={styles.left}>
9
+ <Text style={styles.header}>AY</Text>
10
+ {rows.map(r => (
11
+ <Text key={r.sortOrder} style={styles.cell}>{r.monthLabel}</Text>
12
+ ))}
13
+ </View>
14
+
15
+ {/* Scrollable */}
16
+ <ScrollView horizontal>
17
+ <View>
18
+ <View style={styles.row}>
19
+ {[
20
+ '2024 Yük',
21
+ '2025 Yük',
22
+ 'Yük %',
23
+ '2024 Gelir',
24
+ '2025 Gelir',
25
+ 'Gelir %',
26
+ '2025 Bütçe',
27
+ 'Bütçe %'
28
+ ].map(h => (
29
+ <Text key={h} style={styles.header}>{h}</Text>
30
+ ))}
31
+ </View>
32
+
33
+ {rows.map(r => (
34
+ <View key={r.sortOrder} style={styles.row}>
35
+ <Text style={styles.cell}>{r.loadCount2024}</Text>
36
+ <Text style={styles.cell}>{r.loadCount2025}</Text>
37
+ <Text style={styles.percent}>{r.loadCountChangePercent}%</Text>
38
+ <Text style={styles.cell}>{r.revenueTl2024}</Text>
39
+ <Text style={styles.cell}>{r.revenueTl2025}</Text>
40
+ <Text style={styles.percent}>{r.revenueChangePercent}%</Text>
41
+ <Text style={styles.cell}>{r.budgetRevenueTl2025}</Text>
42
+ <Text style={styles.percent}>{r.budgetChangePercent}%</Text>
43
+ </View>
44
+ ))}
45
+ </View>
46
+ </ScrollView>
47
+ </View>
48
+ );
49
+ };
50
+
51
+ const styles = StyleSheet.create({
52
+ container: { flexDirection: 'row' },
53
+ left: { width: 90, backgroundColor: '#fff' },
54
+ header: { fontWeight: '700', padding: 8 },
55
+ cell: { padding: 8 },
56
+ percent: { padding: 8, fontWeight: '600' },
57
+ row: { flexDirection: 'row' },
58
+ });
59
+
60
+ export default FreezeTableReport3;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { View, Text, StyleSheet } from 'react-native';
3
+
4
+ const LineChartReport3 = ({ data }) => {
5
+ return (
6
+ <View style={styles.card}>
7
+ <Text style={styles.title}>{data.title}</Text>
8
+ {/* Simple SVG-less visual representation */}
9
+ {data.series.map(s => (
10
+ <Text key={s.name} style={styles.legend}>{s.name}</Text>
11
+ ))}
12
+ </View>
13
+ );
14
+ };
15
+
16
+ const styles = StyleSheet.create({
17
+ card: { padding: 12, backgroundColor: '#fff', borderRadius: 12, marginTop: 12 },
18
+ title: { fontWeight: '700', textAlign: 'center', marginBottom: 8 },
19
+ legend: { textAlign: 'center' },
20
+ });
21
+
22
+ export default LineChartReport3;
@@ -1,34 +1,45 @@
1
1
  import React from 'react';
2
- import { ScrollView, Text, TouchableOpacity, StyleSheet } from 'react-native';
2
+ import { ScrollView, TouchableOpacity, Text, StyleSheet } from 'react-native';
3
3
 
4
- const MonthSelector = ({ months, selected, onSelect }) => (
5
- <ScrollView horizontal showsHorizontalScrollIndicator={false}>
6
- {months.map(m => (
4
+ const MonthSelector = ({ months, selected, onSelect }) => {
5
+ return (
6
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} style={styles.row}>
7
7
  <TouchableOpacity
8
- key={m}
9
- style={[styles.card, selected === m && styles.active]}
10
- onPress={() => onSelect(m)}
8
+ style={[styles.btn, selected === 'ALL' && styles.active]}
9
+ onPress={() => onSelect('ALL')}
11
10
  >
12
- <Text style={[styles.text, selected === m && styles.activeText]}>
13
- {m}
14
- </Text>
11
+ <Text style={styles.text}>Select all</Text>
15
12
  </TouchableOpacity>
16
- ))}
17
- </ScrollView>
18
- );
19
13
 
20
- export default MonthSelector;
14
+ {months.map(m => (
15
+ <TouchableOpacity
16
+ key={m}
17
+ style={[styles.btn, selected === m && styles.active]}
18
+ onPress={() => onSelect(m)}
19
+ >
20
+ <Text style={styles.text}>{m}</Text>
21
+ </TouchableOpacity>
22
+ ))}
23
+ </ScrollView>
24
+ );
25
+ };
21
26
 
22
27
  const styles = StyleSheet.create({
23
- card: {
28
+ row: { paddingVertical: 10 },
29
+ btn: {
24
30
  paddingHorizontal: 14,
25
31
  paddingVertical: 8,
26
32
  borderRadius: 16,
27
- borderWidth: 1,
28
- borderColor: '#ccc',
33
+ backgroundColor: '#eef2f7',
29
34
  marginRight: 8,
30
35
  },
31
- active: { backgroundColor: '#000' },
32
- text: { fontSize: 13 },
33
- activeText: { color: '#fff', fontWeight: '700' },
36
+ active: {
37
+ backgroundColor: '#0f172a',
38
+ },
39
+ text: {
40
+ color: '#000',
41
+ fontWeight: '600',
42
+ },
34
43
  });
44
+
45
+ export default MonthSelector;
File without changes
package/src/index.jsx CHANGED
@@ -1,22 +1,48 @@
1
1
  import React, { useState } from 'react';
2
- import ReportsHome from './screens/ReportsHome';
2
+
3
+ import ReportListScreen from './screens/ReportListScreen';
3
4
  import Report1Screen from './screens/Report1Screen';
4
5
  import Report2Screen from './screens/Report2Screen';
5
6
  import Report3Screen from './screens/Report3Screen';
6
7
 
7
- const AnalyticsReports = (props) => {
8
- const [active, setActive] = useState(null);
8
+ const AnalyticsReports = ({ config }) => {
9
+ const [activeReport, setActiveReport] = useState(null);
10
+
11
+ if (!activeReport) {
12
+ return <ReportListScreen onSelect={setActiveReport} />;
13
+ }
9
14
 
10
- if (active === 1)
11
- return <Report1Screen {...props} onBack={() => setActive(null)} />;
15
+ if (activeReport === 1) {
16
+ return (
17
+ <Report1Screen
18
+ api={config.report1}
19
+ token={config.token}
20
+ onBack={() => setActiveReport(null)}
21
+ />
22
+ );
23
+ }
12
24
 
13
- if (active === 2)
14
- return <Report2Screen {...props} onBack={() => setActive(null)} />;
25
+ if (activeReport === 2) {
26
+ return (
27
+ <Report2Screen
28
+ api={config.report2}
29
+ token={config.token}
30
+ onBack={() => setActiveReport(null)}
31
+ />
32
+ );
33
+ }
15
34
 
16
- if (active === 3)
17
- return <Report3Screen onBack={() => setActive(null)} />;
35
+ if (activeReport === 3) {
36
+ return (
37
+ <Report3Screen
38
+ api={config.report3}
39
+ token={config.token}
40
+ onBack={() => setActiveReport(null)}
41
+ />
42
+ );
43
+ }
18
44
 
19
- return <ReportsHome onSelect={setActive} />;
45
+ return null;
20
46
  };
21
47
 
22
48
  export default AnalyticsReports;
@@ -1,11 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { ScrollView, Text, ActivityIndicator } from 'react-native';
3
- import {
4
- getDivisions,
5
- getTable,
6
- getLine,
7
- getBar,
8
- } from '../api/report2Fetcher';
3
+ import { getDivisions, getTable, getLine, getBar } from '../api/report2Fetcher';
9
4
  import MonthSelector from '../components/MonthSelector';
10
5
  import DivisionSelector from '../components/DivisionSelector';
11
6
  import FrozenTable from '../components/FrozenTable';
@@ -1,13 +1,44 @@
1
- import React from 'react';
2
- import { View, Text } from 'react-native';
3
-
4
- const Report3Screen = ({ onBack }) => (
5
- <View style={{ padding: 16 }}>
6
- <Text onPress={onBack}>‹ Back</Text>
7
- <Text style={{ marginTop: 20, fontSize: 16 }}>
8
- Report 3 – Coming Soon
9
- </Text>
10
- </View>
11
- );
1
+ import React, { useEffect, useState } from 'react';
2
+ import { ScrollView, ActivityIndicator } from 'react-native';
3
+ import {
4
+ fetchReport3Table,
5
+ fetchReport3Line,
6
+ fetchReport3Bar
7
+ } from '../api/report3Fetcher';
8
+
9
+ import MonthSelector from '../components/MonthSelector';
10
+ import FreezeTableReport3 from '../components/FreezeTableReport3';
11
+ import LineChartReport3 from '../components/LineChartReport3';
12
+ import BarChartReport3 from '../components/BarChartReport3';
13
+
14
+ const Report3Screen = ({ api, token }) => {
15
+ const [table, setTable] = useState(null);
16
+ const [line, setLine] = useState(null);
17
+ const [bar, setBar] = useState(null);
18
+ const [month, setMonth] = useState('ALL');
19
+
20
+ useEffect(() => {
21
+ fetchReport3Table(api.table, token).then(setTable);
22
+ fetchReport3Line(api.line, token).then(setLine);
23
+ fetchReport3Bar(api.bar, token).then(setBar);
24
+ }, []);
25
+
26
+ if (!table || !line || !bar) return <ActivityIndicator />;
27
+
28
+ const months = table.rows.filter(r => r.month !== 99).map(r => r.monthLabel);
29
+ const rows =
30
+ month === 'ALL'
31
+ ? table.rows
32
+ : table.rows.filter(r => r.monthLabel === month);
33
+
34
+ return (
35
+ <ScrollView>
36
+ <MonthSelector months={months} selected={month} onSelect={setMonth} />
37
+ <FreezeTableReport3 rows={rows} />
38
+ <LineChartReport3 data={line} />
39
+ <BarChartReport3 data={bar} />
40
+ </ScrollView>
41
+ );
42
+ };
12
43
 
13
44
  export default Report3Screen;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
3
+
4
+ const ReportListScreen = ({ onSelect }) => {
5
+ const reports = [
6
+ { id: 1, title: 'Report 1' },
7
+ { id: 2, title: 'Report 2' },
8
+ { id: 3, title: 'Report 3' },
9
+ ];
10
+
11
+ return (
12
+ <View style={styles.container}>
13
+ {reports.map(r => (
14
+ <TouchableOpacity
15
+ key={r.id}
16
+ style={styles.card}
17
+ onPress={() => onSelect(r.id)}
18
+ >
19
+ <Text style={styles.text}>{r.title}</Text>
20
+ </TouchableOpacity>
21
+ ))}
22
+ </View>
23
+ );
24
+ };
25
+
26
+ const styles = StyleSheet.create({
27
+ container: { padding: 16 },
28
+ card: {
29
+ backgroundColor: '#fff',
30
+ padding: 20,
31
+ borderRadius: 12,
32
+ marginBottom: 12,
33
+ elevation: 2,
34
+ },
35
+ text: { fontSize: 16, fontWeight: '700' },
36
+ });
37
+
38
+ export default ReportListScreen;
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import ReportCard from '../components/ReportCard';
4
-
5
- const ReportsHome = ({ onSelect }) => (
6
- <View style={styles.container}>
7
- <ReportCard title="Report 1 – Operating Profit" onPress={() => onSelect(1)} />
8
- <ReportCard title="Report 2 – TEU & Profit" onPress={() => onSelect(2)} />
9
- <ReportCard title="Report 3 – Coming Soon" onPress={() => onSelect(3)} />
10
- </View>
11
- );
12
-
13
- export default ReportsHome;
14
-
15
- const styles = StyleSheet.create({
16
- container: { padding: 16 },
17
- });