Dashboard...
This commit is contained in:
parent
00043e21f2
commit
ade297b354
|
|
@ -36,7 +36,7 @@ class DashboardEntity extends Object with _$DashboardEntitySerializerMixin {
|
|||
|
||||
double paidToDate;
|
||||
|
||||
DashboardEntity(this.paidToDate);
|
||||
DashboardEntity([this.paidToDate]);
|
||||
|
||||
factory DashboardEntity.fromJson(Map<String, dynamic> json) => _$DashboardEntityFromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja/redux/app/loading_reducer.dart';
|
||||
import 'package:invoiceninja/redux/product/product_reducer.dart';
|
||||
import 'package:invoiceninja/redux/auth/auth_reducer.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_reducer.dart';
|
||||
import 'package:invoiceninja/redux/product/product_reducer.dart';
|
||||
|
||||
// We create the State reducer by combining many smaller reducers into one!
|
||||
AppState appReducer(AppState state, action) {
|
||||
|
|
@ -18,7 +19,8 @@ AppState appReducer(AppState state, action) {
|
|||
|
||||
return AppState(
|
||||
isLoading: loadingReducer(state.isLoading, action),
|
||||
products: productsReducer(state.products, action),
|
||||
auth: authReducer(state.auth, action),
|
||||
dashboard: dashboardReducer(state.dashboard, action),
|
||||
products: productsReducer(state.products, action),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,15 @@ import 'package:invoiceninja/redux/auth/auth_state.dart';
|
|||
class AppState {
|
||||
final bool isLoading;
|
||||
final AuthState auth;
|
||||
final DashboardEntity dashboard;
|
||||
final List<ProductEntity> products;
|
||||
|
||||
AppState(
|
||||
{this.isLoading = false,
|
||||
this.products = const [],
|
||||
AuthState auth}):
|
||||
DashboardEntity dashboard,
|
||||
AuthState auth}) :
|
||||
dashboard = dashboard ?? new DashboardEntity(),
|
||||
auth = auth ?? new AuthState();
|
||||
|
||||
|
||||
|
|
@ -31,17 +34,20 @@ class AppState {
|
|||
bool isLoading,
|
||||
AuthState auth,
|
||||
List<ProductEntity> products,
|
||||
DashboardEntity dashboard,
|
||||
}) {
|
||||
return AppState(
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
auth: auth ?? this.auth,
|
||||
products: products ?? this.products,
|
||||
dashboard: dashboard ?? this.dashboard,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
products.hashCode ^
|
||||
dashboard.hashCode ^
|
||||
auth.hashCode ^
|
||||
isLoading.hashCode;
|
||||
|
||||
|
|
@ -50,6 +56,7 @@ class AppState {
|
|||
identical(this, other) ||
|
||||
other is AppState &&
|
||||
runtimeType == other.runtimeType &&
|
||||
dashboard == other.dashboard &&
|
||||
products == other.products &&
|
||||
auth == other.auth &&
|
||||
isLoading == other.isLoading;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
|
||||
final dashboardReducer = combineReducers<DashboardEntity>([
|
||||
TypedReducer<DashboardEntity, DashboardLoadedAction>(_setLoadedDashboards),
|
||||
TypedReducer<DashboardEntity, DashboardNotLoadedAction>(_setNoDashboards),
|
||||
]);
|
||||
|
||||
DashboardEntity _setLoadedDashboards(DashboardEntity data, DashboardLoadedAction action) {
|
||||
return action.data;
|
||||
}
|
||||
|
||||
DashboardEntity _setNoDashboards(DashboardEntity data, DashboardNotLoadedAction action) {
|
||||
return null;
|
||||
}
|
||||
Loading…
Reference in New Issue