diff --git a/lib/presentation/report/pages/report_page.dart b/lib/presentation/report/pages/report_page.dart index b28ae7a..63a8813 100644 --- a/lib/presentation/report/pages/report_page.dart +++ b/lib/presentation/report/pages/report_page.dart @@ -31,17 +31,16 @@ class ReportPage extends StatefulWidget { } class _ReportPageState extends State { - int selectedMenu = 1; - String title = 'Laporan Penjualan Item'; + int selectedMenu = 0; + String title = 'Ringkasan Laporan Penjualan'; DateTime fromDate = DateTime.now().subtract(const Duration(days: 30)); DateTime toDate = DateTime.now(); @override void initState() { super.initState(); - context.read().add( - ItemSalesReportEvent.getItemSales( - startDate: fromDate, endDate: toDate), + context.read().add( + SummaryEvent.getSummary(fromDate, toDate), ); } @@ -112,6 +111,23 @@ class _ReportPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + ReportMenu( + label: 'Ringkasan Laporan Penjualan', + subtitle: + 'Ringkasan total penjualan dalam periode tertentu.', + icon: Icons.insert_drive_file_outlined, + onPressed: () { + selectedMenu = 0; + title = 'Ringkasan Laporan Penjualan'; + setState(() {}); + context.read().add( + SummaryEvent.getSummary(fromDate, toDate), + ); + + log("Date ${DateFormatter.formatDateTime(fromDate)}"); + }, + isActive: selectedMenu == 0, + ), ReportMenu( label: 'Laporan Transaksi', subtitle: @@ -120,7 +136,7 @@ class _ReportPageState extends State { onPressed: () { context.push(SalesPage(status: 'completed')); }, - isActive: selectedMenu == 0, + isActive: selectedMenu == 1, ), ReportMenu( label: 'Laporan Penjualan Item', @@ -128,7 +144,7 @@ class _ReportPageState extends State { 'Laporan penjualan berdasarkan masing-masing item atau produk.', icon: Icons.inventory_2_outlined, onPressed: () { - selectedMenu = 1; + selectedMenu = 2; title = 'Laporan Penjualan Item'; setState(() {}); context.read().add( @@ -136,7 +152,7 @@ class _ReportPageState extends State { startDate: fromDate, endDate: toDate), ); }, - isActive: selectedMenu == 1, + isActive: selectedMenu == 2, ), ReportMenu( label: 'Laporan Penjualan Produk', @@ -144,7 +160,7 @@ class _ReportPageState extends State { 'Laporan penjualan berdasarkan masing-masing produk.', icon: Icons.bar_chart_outlined, onPressed: () { - selectedMenu = 2; + selectedMenu = 3; title = 'Laporan Penjualan Produk'; setState(() {}); context.read().add( @@ -154,23 +170,6 @@ class _ReportPageState extends State { ), ); }, - isActive: selectedMenu == 2, - ), - ReportMenu( - label: 'Ringkasan Laporan Penjualan', - subtitle: - 'Ringkasan total penjualan dalam periode tertentu.', - icon: Icons.insert_drive_file_outlined, - onPressed: () { - selectedMenu = 3; - title = 'Ringkasan Laporan Penjualan'; - setState(() {}); - context.read().add( - SummaryEvent.getSummary(fromDate, toDate), - ); - - log("Date ${DateFormatter.formatDateTime(fromDate)}"); - }, isActive: selectedMenu == 3, ), ReportMenu( @@ -203,8 +202,7 @@ class _ReportPageState extends State { Expanded( flex: 4, child: selectedMenu == 0 - ? BlocBuilder( + ? BlocBuilder( builder: (context, state) { return state.maybeWhen( orElse: () => const Center( @@ -213,20 +211,19 @@ class _ReportPageState extends State { error: (message) { return Text(message); }, - loaded: (transactionReport) { - return TransactionReportWidget( - transactionReport: transactionReport, + success: (data) { + return DashboardAnalyticWidget( + data: data, title: title, searchDateFormatted: searchDateFormatted, - headerWidgets: _getTitleReportPageWidget(), ); }, ); }, ) : selectedMenu == 1 - ? BlocBuilder( + ? BlocBuilder( builder: (context, state) { return state.maybeWhen( orElse: () => const Center( @@ -235,22 +232,22 @@ class _ReportPageState extends State { error: (message) { return Text(message); }, - loaded: (itemSales) { - return ItemSalesReportWidget( - sales: itemSales, + loaded: (transactionReport) { + return TransactionReportWidget( + transactionReport: transactionReport, title: title, searchDateFormatted: searchDateFormatted, headerWidgets: - _getItemSalesPageWidget(), + _getTitleReportPageWidget(), ); }, ); }, ) : selectedMenu == 2 - ? BlocBuilder( + ? BlocBuilder( builder: (context, state) { return state.maybeWhen( orElse: () => const Center( @@ -259,19 +256,22 @@ class _ReportPageState extends State { error: (message) { return Text(message); }, - success: (products) { - return ProductAnalyticsWidget( + loaded: (itemSales) { + return ItemSalesReportWidget( + sales: itemSales, title: title, searchDateFormatted: searchDateFormatted, - productData: products, + headerWidgets: + _getItemSalesPageWidget(), ); }, ); }, ) : selectedMenu == 3 - ? BlocBuilder( + ? BlocBuilder( builder: (context, state) { return state.maybeWhen( orElse: () => const Center( @@ -281,12 +281,12 @@ class _ReportPageState extends State { error: (message) { return Text(message); }, - success: (data) { - return DashboardAnalyticWidget( - data: data, + success: (products) { + return ProductAnalyticsWidget( title: title, searchDateFormatted: searchDateFormatted, + productData: products, ); }, ); diff --git a/lib/presentation/report/widgets/dashboard_analytic_widget.dart b/lib/presentation/report/widgets/dashboard_analytic_widget.dart index c583f70..ac1a1f8 100644 --- a/lib/presentation/report/widgets/dashboard_analytic_widget.dart +++ b/lib/presentation/report/widgets/dashboard_analytic_widget.dart @@ -71,7 +71,7 @@ class DashboardAnalyticWidget extends StatelessWidget { Text( title, style: TextStyle( - fontSize: 28, + fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xFF1F2937), ),