This commit is contained in:
efrilm 2025-08-06 13:10:40 +07:00
parent bdb2c0ba52
commit db06f0dd13
2 changed files with 48 additions and 48 deletions

View File

@ -31,17 +31,16 @@ class ReportPage extends StatefulWidget {
}
class _ReportPageState extends State<ReportPage> {
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<ItemSalesReportBloc>().add(
ItemSalesReportEvent.getItemSales(
startDate: fromDate, endDate: toDate),
context.read<SummaryBloc>().add(
SummaryEvent.getSummary(fromDate, toDate),
);
}
@ -112,6 +111,23 @@ class _ReportPageState extends State<ReportPage> {
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<SummaryBloc>().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<ReportPage> {
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<ReportPage> {
'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<ItemSalesReportBloc>().add(
@ -136,7 +152,7 @@ class _ReportPageState extends State<ReportPage> {
startDate: fromDate, endDate: toDate),
);
},
isActive: selectedMenu == 1,
isActive: selectedMenu == 2,
),
ReportMenu(
label: 'Laporan Penjualan Produk',
@ -144,7 +160,7 @@ class _ReportPageState extends State<ReportPage> {
'Laporan penjualan berdasarkan masing-masing produk.',
icon: Icons.bar_chart_outlined,
onPressed: () {
selectedMenu = 2;
selectedMenu = 3;
title = 'Laporan Penjualan Produk';
setState(() {});
context.read<ProductSalesBloc>().add(
@ -154,23 +170,6 @@ class _ReportPageState extends State<ReportPage> {
),
);
},
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<SummaryBloc>().add(
SummaryEvent.getSummary(fromDate, toDate),
);
log("Date ${DateFormatter.formatDateTime(fromDate)}");
},
isActive: selectedMenu == 3,
),
ReportMenu(
@ -203,8 +202,7 @@ class _ReportPageState extends State<ReportPage> {
Expanded(
flex: 4,
child: selectedMenu == 0
? BlocBuilder<TransactionReportBloc,
TransactionReportState>(
? BlocBuilder<SummaryBloc, SummaryState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const Center(
@ -213,20 +211,19 @@ class _ReportPageState extends State<ReportPage> {
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<ItemSalesReportBloc,
ItemSalesReportState>(
? BlocBuilder<TransactionReportBloc,
TransactionReportState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const Center(
@ -235,22 +232,22 @@ class _ReportPageState extends State<ReportPage> {
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<ProductSalesBloc,
ProductSalesState>(
? BlocBuilder<ItemSalesReportBloc,
ItemSalesReportState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const Center(
@ -259,19 +256,22 @@ class _ReportPageState extends State<ReportPage> {
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<SummaryBloc, SummaryState>(
? BlocBuilder<ProductSalesBloc,
ProductSalesState>(
builder: (context, state) {
return state.maybeWhen(
orElse: () => const Center(
@ -281,12 +281,12 @@ class _ReportPageState extends State<ReportPage> {
error: (message) {
return Text(message);
},
success: (data) {
return DashboardAnalyticWidget(
data: data,
success: (products) {
return ProductAnalyticsWidget(
title: title,
searchDateFormatted:
searchDateFormatted,
productData: products,
);
},
);

View File

@ -71,7 +71,7 @@ class DashboardAnalyticWidget extends StatelessWidget {
Text(
title,
style: TextStyle(
fontSize: 28,
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF1F2937),
),