| @@ -1 +1 @@ | |||
| dab672e712362fdbbfa98386624f95d6 | |||
| 440505e9ea1eee7043d2cbfeb318f6bc | |||
| @@ -26,11 +26,11 @@ class HttpLogInterceptor extends InterceptorsWrapper { | |||
| var token = await pref.getString(DATA_CONST.TOKEN_KEY); | |||
| options.headers["Authorization"] = "Bearer $token"; | |||
| options.receiveTimeout = 20000; | |||
| // log("onRequest: ${options.uri}\n" | |||
| // "data=${options.data}\n" | |||
| // "method=${options.method}\n" | |||
| // "headers=${options.headers}\n" | |||
| // "queryParameters=${options.queryParameters}"); | |||
| log("onRequest: ${options.uri}\n" | |||
| "data=${options.data}\n" | |||
| "method=${options.method}\n" | |||
| "headers=${options.headers}\n" | |||
| "queryParameters=${options.queryParameters}"); | |||
| return options; | |||
| } | |||
| @@ -39,8 +39,8 @@ abstract class RestClient { | |||
| @PUT("/api/update-my-profile") | |||
| Future<Account> updateProfile(@Body() Account account); | |||
| @GET("/api/list-supplies-in-warehouses/ALL?q={query}") | |||
| Future<List<Supply>> getSupplies( | |||
| @GET("/api/list-supplies-in-warehouses/{type}?q={query}") | |||
| Future<List<Supply>> getSupplies(@Path() String type, | |||
| {@DioOptions() Options options, @Path() String query = ""}); | |||
| //Common | |||
| @@ -128,7 +128,8 @@ class _RestClient implements RestClient { | |||
| } | |||
| @override | |||
| getSupplies({options, query = ""}) async { | |||
| getSupplies(type, {options, query = ""}) async { | |||
| ArgumentError.checkNotNull(type, 'type'); | |||
| const _extra = <String, dynamic>{}; | |||
| final queryParameters = <String, dynamic>{}; | |||
| queryParameters.removeWhere((k, v) => v == null); | |||
| @@ -137,7 +138,7 @@ class _RestClient implements RestClient { | |||
| newOptions.extra.addAll(_extra); | |||
| newOptions.headers.addAll(<String, dynamic>{}); | |||
| final Response<List<dynamic>> _result = await _dio.request( | |||
| '/api/list-supplies-in-warehouses/ALL?q=$query', | |||
| '/api/list-supplies-in-warehouses/$type?q=$query', | |||
| queryParameters: queryParameters, | |||
| options: newOptions.merge(method: 'GET', baseUrl: baseUrl), | |||
| data: _data); | |||
| @@ -82,11 +82,11 @@ class Repository { | |||
| return value; | |||
| } | |||
| Future<List<Supply>> getSupplies({String query = ""}) async { | |||
| Future<List<Supply>> getSupplies(String type, {String query = ""}) async { | |||
| final client = RestClient(dio); | |||
| var op = buildConfigurableCacheOptions( | |||
| forceRefresh: true, maxAge: Duration(days: ConstCommon.kMaxAgeCache)); | |||
| return client.getSupplies(query: query, options: op); | |||
| return client.getSupplies(type, query: query, options: op); | |||
| } | |||
| Future<List<Device>> getDeviceForActivity() async { | |||
| @@ -411,7 +411,7 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| child: Text( | |||
| plot_action_harvest_process, | |||
| style: TextStyle( | |||
| color: Colors.white, fontSize: 16), | |||
| color: Colors.white, fontSize: 14), | |||
| ), | |||
| ), | |||
| ), | |||
| @@ -437,7 +437,7 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| child: Text( | |||
| plot_action_packing, | |||
| style: TextStyle( | |||
| color: Colors.white, fontSize: 16), | |||
| color: Colors.white, fontSize: 14), | |||
| ), | |||
| ), | |||
| ) | |||
| @@ -471,7 +471,7 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> { | |||
| child: Text( | |||
| plot_action_sell, | |||
| style: TextStyle( | |||
| color: Colors.white, fontSize: 16), | |||
| color: Colors.white, fontSize: 14), | |||
| ), | |||
| ), | |||
| ) | |||
| @@ -19,7 +19,7 @@ class SupplyBloc extends Bloc<SupplyEvent, SupplyState> { | |||
| ) async* { | |||
| if (event is DataFetched) { | |||
| try { | |||
| final response = await repository.getSupplies(query: event.type); | |||
| final response = await repository.getSupplies(event.type); | |||
| List<Supply> supplies = response.map((supply) { | |||
| if (supply.id == event.selectedId) { | |||
| supply.isSelected = true; | |||
| @@ -32,7 +32,7 @@ class SupplyBloc extends Bloc<SupplyEvent, SupplyState> { | |||
| } | |||
| } else if (event is OnRefresh) { | |||
| try { | |||
| final response = await repository.getSupplies(query: event.type); | |||
| final response = await repository.getSupplies(event.type); | |||
| List<Supply> supplies = response.map((supply) { | |||
| if (supply.id == event.selectedId) { | |||
| supply.isSelected = true; | |||
| @@ -45,14 +45,9 @@ class SupplyBloc extends Bloc<SupplyEvent, SupplyState> { | |||
| } | |||
| } else if (event is OnSearch) { | |||
| try { | |||
| final response = await repository.getSupplies(query: event.type); | |||
| bool query(Supply supply) => | |||
| event.searchString.isEmpty || | |||
| supply.tbSuppliesName | |||
| .toLowerCase() | |||
| .contains(event.searchString.toLowerCase()); | |||
| final result = response.where(query).toList(); | |||
| List<Supply> supplies = result.map((supply) { | |||
| final response = | |||
| await repository.getSupplies(event.type, query: event.searchString); | |||
| List<Supply> supplies = response.map((supply) { | |||
| if (supply.id == event.selectedId) { | |||
| supply.isSelected = true; | |||
| } | |||
| @@ -81,7 +81,7 @@ class ConstCommon { | |||
| static const String supplyTypeDung = "PHANBON"; | |||
| static const String supplyTypeSubStrate = "GIATHE"; | |||
| static const String supplyTypeProtectPlant = "THUOCBVTV"; | |||
| static const String supplyTypeAll = ""; | |||
| static const String supplyTypeAll = "ALL"; | |||
| } | |||
| enum CRUDStatus { unknown, add, edit, delete } | |||