fix report
This commit is contained in:
parent
07932d688f
commit
13941d4881
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/analytic/payment_method_analytic_loader/payment_method_analytic_loader_bloc.dart';
|
||||
import '../../../../../../common/data/report_menu.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../domain/analytic/analytic.dart';
|
||||
import '../../../../../components/error/analytic_error_state_widget.dart';
|
||||
import '../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
import '../../../../../components/widgets/report/report_header.dart';
|
||||
@ -29,7 +31,18 @@ class ReportPaymentMethodSection extends StatelessWidget {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return ListView(
|
||||
return state.failureOption.fold(
|
||||
() => RefreshIndicator(
|
||||
onRefresh: () {
|
||||
context.read<PaymentMethodAnalyticLoaderBloc>().add(
|
||||
PaymentMethodAnalyticLoaderEvent.fetched(
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
),
|
||||
);
|
||||
return Future.value();
|
||||
},
|
||||
child: ListView(
|
||||
padding: EdgeInsets.all(16),
|
||||
children: [
|
||||
ReportHeader(menu: menu, endDate: endDate, startDate: startDate),
|
||||
@ -67,6 +80,20 @@ class ReportPaymentMethodSection extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
(f) => AnalyticErrorStateWidget(
|
||||
failure: f,
|
||||
menu: menu,
|
||||
onRefresh: () {
|
||||
context.read<PaymentMethodAnalyticLoaderBloc>().add(
|
||||
PaymentMethodAnalyticLoaderEvent.fetched(
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/analytic/product_analytic_loader/product_analytic_loader_bloc.dart';
|
||||
import '../../../../../../common/data/report_menu.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../domain/analytic/analytic.dart';
|
||||
import '../../../../../components/error/analytic_error_state_widget.dart';
|
||||
import '../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
import '../../../../../components/widgets/report/report_header.dart';
|
||||
@ -29,9 +31,20 @@ class ReportProductSection extends StatelessWidget {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return Column(
|
||||
return state.failureOption.fold(
|
||||
() => Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () {
|
||||
context.read<ProductAnalyticLoaderBloc>().add(
|
||||
ProductAnalyticLoaderEvent.fetched(
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
),
|
||||
);
|
||||
return Future.value();
|
||||
},
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
@ -48,13 +61,15 @@ class ReportProductSection extends StatelessWidget {
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.productAnalytic.categories.length,
|
||||
itemBuilder: (context, index) {
|
||||
final category = state.productAnalytic.categories[index];
|
||||
final category =
|
||||
state.productAnalytic.categories[index];
|
||||
return Container(
|
||||
width: 200,
|
||||
padding: EdgeInsets.only(
|
||||
right:
|
||||
index ==
|
||||
state.productAnalytic.categories.length - 1
|
||||
state.productAnalytic.categories.length -
|
||||
1
|
||||
? 0
|
||||
: 12,
|
||||
),
|
||||
@ -123,7 +138,8 @@ class ReportProductSection extends StatelessWidget {
|
||||
rank: index + 1,
|
||||
product: product,
|
||||
isTopPerformer:
|
||||
product == state.productAnalytic.bestProduct,
|
||||
product ==
|
||||
state.productAnalytic.bestProduct,
|
||||
categoryColor: AppColor.primary,
|
||||
);
|
||||
},
|
||||
@ -135,8 +151,22 @@ class ReportProductSection extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBottomSummary(),
|
||||
],
|
||||
),
|
||||
(f) => AnalyticErrorStateWidget(
|
||||
failure: f,
|
||||
menu: menu,
|
||||
onRefresh: () {
|
||||
context.read<ProductAnalyticLoaderBloc>().add(
|
||||
ProductAnalyticLoaderEvent.fetched(
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/analytic/sales_analytic_loader/sales_analytic_loader_bloc.dart';
|
||||
import '../../../../../../common/data/report_menu.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../components/error/analytic_error_state_widget.dart';
|
||||
import '../../../../../components/loader/loader_with_text.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
import '../../../../../components/widgets/report/report_header.dart';
|
||||
@ -28,7 +30,19 @@ class ReportSalesSection extends StatelessWidget {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
|
||||
return ListView(
|
||||
return state.failureOption.fold(
|
||||
() => RefreshIndicator(
|
||||
onRefresh: () {
|
||||
context.read<SalesAnalyticLoaderBloc>().add(
|
||||
SalesAnalyticLoaderEvent.fetched(
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
),
|
||||
);
|
||||
|
||||
return Future.value();
|
||||
},
|
||||
child: ListView(
|
||||
padding: EdgeInsets.all(16),
|
||||
children: [
|
||||
ReportHeader(menu: menu, endDate: endDate, startDate: startDate),
|
||||
@ -56,13 +70,15 @@ class ReportSalesSection extends StatelessWidget {
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
final dayData = state.salesAnalytic.sortedDailyData[index];
|
||||
final dayData =
|
||||
state.salesAnalytic.sortedDailyData[index];
|
||||
return _buildDailyPerformanceItem(
|
||||
date: dayData.date.toSimpleMonthDate(),
|
||||
sales: dayData.sales.currencyFormatRpV2,
|
||||
orders: dayData.orders,
|
||||
items: dayData.items,
|
||||
isHighest: dayData == state.salesAnalytic.highestRevenueDay,
|
||||
isHighest:
|
||||
dayData == state.salesAnalytic.highestRevenueDay,
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -72,6 +88,20 @@ class ReportSalesSection extends StatelessWidget {
|
||||
SpaceHeight(16),
|
||||
_buildSummaryFooter(),
|
||||
],
|
||||
),
|
||||
),
|
||||
(f) => AnalyticErrorStateWidget(
|
||||
failure: f,
|
||||
menu: menu,
|
||||
onRefresh: () {
|
||||
context.read<SalesAnalyticLoaderBloc>().add(
|
||||
SalesAnalyticLoaderEvent.fetched(
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user