feat: Implements stock picking data fetching WIP1
Adds a new API call (`getAllStockPiking`) to retrieve stock picking records from the backend. Refactors stock picking data models: - Renames models for better clarity (e.g., `StockPickingResponse` to `StockPickingResponseModel`). - Makes all model fields nullable to handle varying API responses gracefully. - Introduces specific nested models (`StockPickingCompanyModel`, `StockPickingPartnerModel`, `StockPickingLocationModel`, `StockPickingTypeModel`) for related entities, enhancing type safety and data structure. Integrates the new API call into `ReceptionPageModel` and introduces distinct loading states (`loadingUser`, `loadingReceptions`) for improved UI feedback.
This commit is contained in:
parent
40ef71a28b
commit
61345869e1
@ -1,7 +1,9 @@
|
||||
import 'package:barcode_scanner/backend/schema/auth/auth_model.dart';
|
||||
import 'package:barcode_scanner/backend/schema/stock_picking/stock_picking_model.dart';
|
||||
import 'package:barcode_scanner/provider_container.dart';
|
||||
import 'package:barcode_scanner/services/dio_service.dart';
|
||||
import 'package:barcode_scanner/services/token_provider.dart';
|
||||
import 'package:barcode_scanner/utils/utils.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:multiple_result/multiple_result.dart';
|
||||
@ -67,4 +69,97 @@ class ApiCalls {
|
||||
return Result.error(Error(e));
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Result<StockPickingResponseModel, Error>>
|
||||
getAllStockPiking() async {
|
||||
try {
|
||||
if (!(await checkInternetConnexion())) {
|
||||
// return local data
|
||||
}
|
||||
final response = await dioService.post(
|
||||
path: '/web/dataset/call_kw/stock.picking/web_search_read',
|
||||
data: {
|
||||
"id": 23,
|
||||
"jsonrpc": "2.0",
|
||||
"method": "call",
|
||||
"params": {
|
||||
"model": "stock.picking",
|
||||
"method": "web_search_read",
|
||||
"args": [],
|
||||
"kwargs": {
|
||||
"specification": {
|
||||
"company_id": {"fields": {}},
|
||||
"priority": {},
|
||||
"name": {},
|
||||
"partner_id": {
|
||||
"fields": {"display_name": {}},
|
||||
},
|
||||
"location_dest_id": {
|
||||
"fields": {"complete_name": {}},
|
||||
},
|
||||
"location_id": {
|
||||
"fields": {"complete_name": {}},
|
||||
},
|
||||
"user_id": {
|
||||
"fields": {"display_name": {}},
|
||||
},
|
||||
"scheduled_date": {},
|
||||
"picking_type_code": {},
|
||||
"products_availability_state": {},
|
||||
"products_availability": {},
|
||||
"date_deadline": {},
|
||||
"date_done": {},
|
||||
"origin": {},
|
||||
"backorder_id": {
|
||||
"fields": {"display_name": {}},
|
||||
},
|
||||
"picking_type_id": {
|
||||
"fields": {"display_name": {}},
|
||||
},
|
||||
"state": {},
|
||||
"activity_exception_decoration": {},
|
||||
"activity_exception_icon": {},
|
||||
"json_popover": {},
|
||||
},
|
||||
"offset": 0,
|
||||
"order": "",
|
||||
"limit": 80,
|
||||
"context": {
|
||||
"lang": "en_US",
|
||||
"tz": "Africa/Nairobi",
|
||||
"uid": 2,
|
||||
"allowed_company_ids": [1],
|
||||
"bin_size": true,
|
||||
"active_model": "stock.picking.type",
|
||||
"active_id": 2,
|
||||
"active_ids": [2],
|
||||
"contact_display": "partner_address",
|
||||
"default_picking_type_id": 2,
|
||||
"default_company_id": 1,
|
||||
"current_company_id": 1,
|
||||
},
|
||||
"count_limit": 10001,
|
||||
"domain": [
|
||||
["picking_type_id", "=", 2],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
if (data.containsKey('result')) {
|
||||
return Result.success(StockPickingResponseModel.fromJson(data));
|
||||
} else {
|
||||
return Result.error(Error(data['error']));
|
||||
}
|
||||
} else {
|
||||
debugPrint('Erreur réseau: ${response.statusCode}');
|
||||
return Result.error(Error(response.statusMessage));
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Erreur lors de la requête: $e');
|
||||
return Result.error(Error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,72 +4,99 @@ part 'stock_picking_model.freezed.dart';
|
||||
part 'stock_picking_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class StockPickingResponse with _$StockPickingResponse {
|
||||
const factory StockPickingResponse({
|
||||
required String jsonrpc,
|
||||
required int id,
|
||||
required StockPickingResult result,
|
||||
}) = _StockPickingResponse;
|
||||
abstract class StockPickingResponseModel with _$StockPickingResponseModel {
|
||||
const factory StockPickingResponseModel({
|
||||
String? jsonrpc,
|
||||
int? id,
|
||||
StockPickingResultModel? result,
|
||||
}) = _StockPickingResponseModel;
|
||||
|
||||
factory StockPickingResponse.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingResponseFromJson(json);
|
||||
factory StockPickingResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class StockPickingResult with _$StockPickingResult {
|
||||
const factory StockPickingResult({
|
||||
required int length,
|
||||
required List<StockPickingRecord> records,
|
||||
}) = _StockPickingResult;
|
||||
abstract class StockPickingResultModel with _$StockPickingResultModel {
|
||||
const factory StockPickingResultModel({
|
||||
int? length,
|
||||
List<StockPickingRecordModel>? records,
|
||||
}) = _StockPickingResultModel;
|
||||
|
||||
factory StockPickingResult.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingResultFromJson(json);
|
||||
factory StockPickingResultModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingResultModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class StockPickingRecord with _$StockPickingRecord {
|
||||
const factory StockPickingRecord({
|
||||
required int id,
|
||||
@JsonKey(name: 'company_id') required IdOnly companyId,
|
||||
required String priority,
|
||||
required String name,
|
||||
@JsonKey(name: 'partner_id') required DisplayNameId partnerId,
|
||||
@JsonKey(name: 'user_id') dynamic userId, // peut être false ou null
|
||||
@JsonKey(name: 'scheduled_date') required String scheduledDate,
|
||||
@JsonKey(name: 'picking_type_code') required String pickingTypeCode,
|
||||
abstract class StockPickingRecordModel with _$StockPickingRecordModel {
|
||||
const factory StockPickingRecordModel({
|
||||
int? id,
|
||||
@JsonKey(name: 'company_id') StockPickingCompanyModel? companyId,
|
||||
@JsonKey(name: 'priority') String? priority,
|
||||
@JsonKey(name: 'name') String? name,
|
||||
@JsonKey(name: 'partner_id') StockPickingPartnerModel? partnerId,
|
||||
@JsonKey(name: 'location_dest_id')
|
||||
StockPickingLocationModel? locationDestId,
|
||||
@JsonKey(name: 'location_id') StockPickingLocationModel? locationId,
|
||||
@JsonKey(name: 'user_id') dynamic userId,
|
||||
@JsonKey(name: 'scheduled_date') String? scheduledDate,
|
||||
@JsonKey(name: 'picking_type_code') String? pickingTypeCode,
|
||||
@JsonKey(name: 'products_availability_state')
|
||||
dynamic productsAvailabilityState,
|
||||
@JsonKey(name: 'products_availability') dynamic productsAvailability,
|
||||
@JsonKey(name: 'date_deadline') required String dateDeadline,
|
||||
@JsonKey(name: 'date_deadline') String? dateDeadline,
|
||||
@JsonKey(name: 'date_done') dynamic dateDone,
|
||||
required String origin,
|
||||
@JsonKey(name: 'origin') String? origin,
|
||||
@JsonKey(name: 'backorder_id') dynamic backorderId,
|
||||
@JsonKey(name: 'picking_type_id') required DisplayNameId pickingTypeId,
|
||||
required String state,
|
||||
@JsonKey(name: 'picking_type_id') StockPickingTypeModel? pickingTypeId,
|
||||
@JsonKey(name: 'state') String? state,
|
||||
@JsonKey(name: 'activity_exception_decoration')
|
||||
dynamic activityExceptionDecoration,
|
||||
@JsonKey(name: 'activity_exception_icon') dynamic activityExceptionIcon,
|
||||
@JsonKey(name: 'json_popover') dynamic jsonPopover,
|
||||
}) = _StockPickingRecord;
|
||||
}) = _StockPickingRecordModel;
|
||||
|
||||
factory StockPickingRecord.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingRecordFromJson(json);
|
||||
factory StockPickingRecordModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingRecordModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class IdOnly with _$IdOnly {
|
||||
const factory IdOnly({required int id}) = _IdOnly;
|
||||
abstract class StockPickingCompanyModel with _$StockPickingCompanyModel {
|
||||
const factory StockPickingCompanyModel({@JsonKey(name: 'id') int? id}) =
|
||||
_StockPickingCompanyModel;
|
||||
|
||||
factory IdOnly.fromJson(Map<String, dynamic> json) => _$IdOnlyFromJson(json);
|
||||
factory StockPickingCompanyModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingCompanyModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class DisplayNameId with _$DisplayNameId {
|
||||
const factory DisplayNameId({
|
||||
required int id,
|
||||
@JsonKey(name: 'display_name') required String displayName,
|
||||
}) = _DisplayNameId;
|
||||
abstract class StockPickingPartnerModel with _$StockPickingPartnerModel {
|
||||
const factory StockPickingPartnerModel({
|
||||
int? id,
|
||||
@JsonKey(name: 'display_name') String? displayName,
|
||||
}) = _StockPickingPartnerModel;
|
||||
|
||||
factory DisplayNameId.fromJson(Map<String, dynamic> json) =>
|
||||
_$DisplayNameIdFromJson(json);
|
||||
factory StockPickingPartnerModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingPartnerModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class StockPickingLocationModel with _$StockPickingLocationModel {
|
||||
const factory StockPickingLocationModel({
|
||||
int? id,
|
||||
@JsonKey(name: 'complete_name') String? completeName,
|
||||
}) = _StockPickingLocationModel;
|
||||
|
||||
factory StockPickingLocationModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingLocationModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class StockPickingTypeModel with _$StockPickingTypeModel {
|
||||
const factory StockPickingTypeModel({
|
||||
int? id,
|
||||
@JsonKey(name: 'display_name') String? displayName,
|
||||
}) = _StockPickingTypeModel;
|
||||
|
||||
factory StockPickingTypeModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$StockPickingTypeModelFromJson(json);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,95 +6,151 @@ part of 'stock_picking_model.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_StockPickingResponse _$StockPickingResponseFromJson(
|
||||
_StockPickingResponseModel _$StockPickingResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingResponse(
|
||||
jsonrpc: json['jsonrpc'] as String,
|
||||
id: (json['id'] as num).toInt(),
|
||||
result: StockPickingResult.fromJson(json['result'] as Map<String, dynamic>),
|
||||
) => _StockPickingResponseModel(
|
||||
jsonrpc: json['jsonrpc'] as String?,
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
result: json['result'] == null
|
||||
? null
|
||||
: StockPickingResultModel.fromJson(
|
||||
json['result'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StockPickingResponseToJson(
|
||||
_StockPickingResponse instance,
|
||||
Map<String, dynamic> _$StockPickingResponseModelToJson(
|
||||
_StockPickingResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'jsonrpc': instance.jsonrpc,
|
||||
'id': instance.id,
|
||||
'result': instance.result,
|
||||
};
|
||||
|
||||
_StockPickingResult _$StockPickingResultFromJson(Map<String, dynamic> json) =>
|
||||
_StockPickingResult(
|
||||
length: (json['length'] as num).toInt(),
|
||||
records: (json['records'] as List<dynamic>)
|
||||
.map((e) => StockPickingRecord.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
_StockPickingResultModel _$StockPickingResultModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingResultModel(
|
||||
length: (json['length'] as num?)?.toInt(),
|
||||
records: (json['records'] as List<dynamic>?)
|
||||
?.map((e) => StockPickingRecordModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StockPickingResultToJson(_StockPickingResult instance) =>
|
||||
<String, dynamic>{'length': instance.length, 'records': instance.records};
|
||||
Map<String, dynamic> _$StockPickingResultModelToJson(
|
||||
_StockPickingResultModel instance,
|
||||
) => <String, dynamic>{'length': instance.length, 'records': instance.records};
|
||||
|
||||
_StockPickingRecord _$StockPickingRecordFromJson(Map<String, dynamic> json) =>
|
||||
_StockPickingRecord(
|
||||
id: (json['id'] as num).toInt(),
|
||||
companyId: IdOnly.fromJson(json['company_id'] as Map<String, dynamic>),
|
||||
priority: json['priority'] as String,
|
||||
name: json['name'] as String,
|
||||
partnerId: DisplayNameId.fromJson(
|
||||
json['partner_id'] as Map<String, dynamic>,
|
||||
),
|
||||
userId: json['user_id'],
|
||||
scheduledDate: json['scheduled_date'] as String,
|
||||
pickingTypeCode: json['picking_type_code'] as String,
|
||||
productsAvailabilityState: json['products_availability_state'],
|
||||
productsAvailability: json['products_availability'],
|
||||
dateDeadline: json['date_deadline'] as String,
|
||||
dateDone: json['date_done'],
|
||||
origin: json['origin'] as String,
|
||||
backorderId: json['backorder_id'],
|
||||
pickingTypeId: DisplayNameId.fromJson(
|
||||
json['picking_type_id'] as Map<String, dynamic>,
|
||||
),
|
||||
state: json['state'] as String,
|
||||
activityExceptionDecoration: json['activity_exception_decoration'],
|
||||
activityExceptionIcon: json['activity_exception_icon'],
|
||||
jsonPopover: json['json_popover'],
|
||||
);
|
||||
_StockPickingRecordModel _$StockPickingRecordModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingRecordModel(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
companyId: json['company_id'] == null
|
||||
? null
|
||||
: StockPickingCompanyModel.fromJson(
|
||||
json['company_id'] as Map<String, dynamic>,
|
||||
),
|
||||
priority: json['priority'] as String?,
|
||||
name: json['name'] as String?,
|
||||
partnerId: json['partner_id'] == null
|
||||
? null
|
||||
: StockPickingPartnerModel.fromJson(
|
||||
json['partner_id'] as Map<String, dynamic>,
|
||||
),
|
||||
locationDestId: json['location_dest_id'] == null
|
||||
? null
|
||||
: StockPickingLocationModel.fromJson(
|
||||
json['location_dest_id'] as Map<String, dynamic>,
|
||||
),
|
||||
locationId: json['location_id'] == null
|
||||
? null
|
||||
: StockPickingLocationModel.fromJson(
|
||||
json['location_id'] as Map<String, dynamic>,
|
||||
),
|
||||
userId: json['user_id'],
|
||||
scheduledDate: json['scheduled_date'] as String?,
|
||||
pickingTypeCode: json['picking_type_code'] as String?,
|
||||
productsAvailabilityState: json['products_availability_state'],
|
||||
productsAvailability: json['products_availability'],
|
||||
dateDeadline: json['date_deadline'] as String?,
|
||||
dateDone: json['date_done'],
|
||||
origin: json['origin'] as String?,
|
||||
backorderId: json['backorder_id'],
|
||||
pickingTypeId: json['picking_type_id'] == null
|
||||
? null
|
||||
: StockPickingTypeModel.fromJson(
|
||||
json['picking_type_id'] as Map<String, dynamic>,
|
||||
),
|
||||
state: json['state'] as String?,
|
||||
activityExceptionDecoration: json['activity_exception_decoration'],
|
||||
activityExceptionIcon: json['activity_exception_icon'],
|
||||
jsonPopover: json['json_popover'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StockPickingRecordToJson(_StockPickingRecord instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'company_id': instance.companyId,
|
||||
'priority': instance.priority,
|
||||
'name': instance.name,
|
||||
'partner_id': instance.partnerId,
|
||||
'user_id': instance.userId,
|
||||
'scheduled_date': instance.scheduledDate,
|
||||
'picking_type_code': instance.pickingTypeCode,
|
||||
'products_availability_state': instance.productsAvailabilityState,
|
||||
'products_availability': instance.productsAvailability,
|
||||
'date_deadline': instance.dateDeadline,
|
||||
'date_done': instance.dateDone,
|
||||
'origin': instance.origin,
|
||||
'backorder_id': instance.backorderId,
|
||||
'picking_type_id': instance.pickingTypeId,
|
||||
'state': instance.state,
|
||||
'activity_exception_decoration': instance.activityExceptionDecoration,
|
||||
'activity_exception_icon': instance.activityExceptionIcon,
|
||||
'json_popover': instance.jsonPopover,
|
||||
};
|
||||
|
||||
_IdOnly _$IdOnlyFromJson(Map<String, dynamic> json) =>
|
||||
_IdOnly(id: (json['id'] as num).toInt());
|
||||
|
||||
Map<String, dynamic> _$IdOnlyToJson(_IdOnly instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$StockPickingRecordModelToJson(
|
||||
_StockPickingRecordModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'company_id': instance.companyId,
|
||||
'priority': instance.priority,
|
||||
'name': instance.name,
|
||||
'partner_id': instance.partnerId,
|
||||
'location_dest_id': instance.locationDestId,
|
||||
'location_id': instance.locationId,
|
||||
'user_id': instance.userId,
|
||||
'scheduled_date': instance.scheduledDate,
|
||||
'picking_type_code': instance.pickingTypeCode,
|
||||
'products_availability_state': instance.productsAvailabilityState,
|
||||
'products_availability': instance.productsAvailability,
|
||||
'date_deadline': instance.dateDeadline,
|
||||
'date_done': instance.dateDone,
|
||||
'origin': instance.origin,
|
||||
'backorder_id': instance.backorderId,
|
||||
'picking_type_id': instance.pickingTypeId,
|
||||
'state': instance.state,
|
||||
'activity_exception_decoration': instance.activityExceptionDecoration,
|
||||
'activity_exception_icon': instance.activityExceptionIcon,
|
||||
'json_popover': instance.jsonPopover,
|
||||
};
|
||||
|
||||
_DisplayNameId _$DisplayNameIdFromJson(Map<String, dynamic> json) =>
|
||||
_DisplayNameId(
|
||||
id: (json['id'] as num).toInt(),
|
||||
displayName: json['display_name'] as String,
|
||||
);
|
||||
_StockPickingCompanyModel _$StockPickingCompanyModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingCompanyModel(id: (json['id'] as num?)?.toInt());
|
||||
|
||||
Map<String, dynamic> _$DisplayNameIdToJson(_DisplayNameId instance) =>
|
||||
<String, dynamic>{'id': instance.id, 'display_name': instance.displayName};
|
||||
Map<String, dynamic> _$StockPickingCompanyModelToJson(
|
||||
_StockPickingCompanyModel instance,
|
||||
) => <String, dynamic>{'id': instance.id};
|
||||
|
||||
_StockPickingPartnerModel _$StockPickingPartnerModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingPartnerModel(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
displayName: json['display_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StockPickingPartnerModelToJson(
|
||||
_StockPickingPartnerModel instance,
|
||||
) => <String, dynamic>{'id': instance.id, 'display_name': instance.displayName};
|
||||
|
||||
_StockPickingLocationModel _$StockPickingLocationModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingLocationModel(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
completeName: json['complete_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StockPickingLocationModelToJson(
|
||||
_StockPickingLocationModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'complete_name': instance.completeName,
|
||||
};
|
||||
|
||||
_StockPickingTypeModel _$StockPickingTypeModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _StockPickingTypeModel(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
displayName: json['display_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StockPickingTypeModelToJson(
|
||||
_StockPickingTypeModel instance,
|
||||
) => <String, dynamic>{'id': instance.id, 'display_name': instance.displayName};
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'package:barcode_scanner/backend/api/api_calls.dart';
|
||||
import 'package:barcode_scanner/backend/schema/stock_picking/stock_picking_model.dart';
|
||||
import 'package:barcode_scanner/backend/schema/user/user_struct.dart';
|
||||
import 'package:barcode_scanner/services/secure_storage.dart';
|
||||
import 'package:barcode_scanner/services/token_provider.dart';
|
||||
@ -30,9 +32,18 @@ class ReceptionPageModel extends StateNotifier<ReceptionPageState> {
|
||||
final UserConnectedProvider userConnectedProvider;
|
||||
|
||||
Future getUserConnected() async {
|
||||
state = state.copyWith(loading: true);
|
||||
state = state.copyWith(loadingUser: true);
|
||||
final user = await userConnectedProvider.get();
|
||||
state = state.copyWith(user: user, loading: false);
|
||||
state = state.copyWith(user: user, loadingUser: false);
|
||||
}
|
||||
|
||||
Future getAllReceptions() async {
|
||||
try {
|
||||
state = state.copyWith(loadingReceptions: true);
|
||||
final res = await ApiCalls.getAllStockPiking();
|
||||
} catch (e) {
|
||||
state = state.copyWith(loadingReceptions: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +51,8 @@ class ReceptionPageModel extends StateNotifier<ReceptionPageState> {
|
||||
abstract class ReceptionPageState with _$ReceptionPageState {
|
||||
const factory ReceptionPageState({
|
||||
UserStruct? user,
|
||||
@Default(false) bool loading,
|
||||
StockPickingResponseModel? receptions,
|
||||
@Default(false) bool loadingReceptions,
|
||||
@Default(false) bool loadingUser,
|
||||
}) = _ReceptionPageState;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ReceptionPageState implements DiagnosticableTreeMixin {
|
||||
|
||||
UserStruct? get user; bool get loading;
|
||||
UserStruct? get user; StockPickingResponseModel? get receptions; bool get loadingReceptions; bool get loadingUser;
|
||||
/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@ -27,21 +27,21 @@ $ReceptionPageStateCopyWith<ReceptionPageState> get copyWith => _$ReceptionPageS
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
properties
|
||||
..add(DiagnosticsProperty('type', 'ReceptionPageState'))
|
||||
..add(DiagnosticsProperty('user', user))..add(DiagnosticsProperty('loading', loading));
|
||||
..add(DiagnosticsProperty('user', user))..add(DiagnosticsProperty('receptions', receptions))..add(DiagnosticsProperty('loadingReceptions', loadingReceptions))..add(DiagnosticsProperty('loadingUser', loadingUser));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ReceptionPageState&&(identical(other.user, user) || other.user == user)&&(identical(other.loading, loading) || other.loading == loading));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ReceptionPageState&&(identical(other.user, user) || other.user == user)&&(identical(other.receptions, receptions) || other.receptions == receptions)&&(identical(other.loadingReceptions, loadingReceptions) || other.loadingReceptions == loadingReceptions)&&(identical(other.loadingUser, loadingUser) || other.loadingUser == loadingUser));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,user,loading);
|
||||
int get hashCode => Object.hash(runtimeType,user,receptions,loadingReceptions,loadingUser);
|
||||
|
||||
@override
|
||||
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
|
||||
return 'ReceptionPageState(user: $user, loading: $loading)';
|
||||
return 'ReceptionPageState(user: $user, receptions: $receptions, loadingReceptions: $loadingReceptions, loadingUser: $loadingUser)';
|
||||
}
|
||||
|
||||
|
||||
@ -52,11 +52,11 @@ abstract mixin class $ReceptionPageStateCopyWith<$Res> {
|
||||
factory $ReceptionPageStateCopyWith(ReceptionPageState value, $Res Function(ReceptionPageState) _then) = _$ReceptionPageStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
UserStruct? user, bool loading
|
||||
UserStruct? user, StockPickingResponseModel? receptions, bool loadingReceptions, bool loadingUser
|
||||
});
|
||||
|
||||
|
||||
$UserStructCopyWith<$Res>? get user;
|
||||
$UserStructCopyWith<$Res>? get user;$StockPickingResponseModelCopyWith<$Res>? get receptions;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@ -69,10 +69,12 @@ class _$ReceptionPageStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? user = freezed,Object? loading = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? user = freezed,Object? receptions = freezed,Object? loadingReceptions = null,Object? loadingUser = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as UserStruct?,loading: null == loading ? _self.loading : loading // ignore: cast_nullable_to_non_nullable
|
||||
as UserStruct?,receptions: freezed == receptions ? _self.receptions : receptions // ignore: cast_nullable_to_non_nullable
|
||||
as StockPickingResponseModel?,loadingReceptions: null == loadingReceptions ? _self.loadingReceptions : loadingReceptions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loadingUser: null == loadingUser ? _self.loadingUser : loadingUser // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
@ -88,6 +90,18 @@ $UserStructCopyWith<$Res>? get user {
|
||||
return $UserStructCopyWith<$Res>(_self.user!, (value) {
|
||||
return _then(_self.copyWith(user: value));
|
||||
});
|
||||
}/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$StockPickingResponseModelCopyWith<$Res>? get receptions {
|
||||
if (_self.receptions == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $StockPickingResponseModelCopyWith<$Res>(_self.receptions!, (value) {
|
||||
return _then(_self.copyWith(receptions: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,11 +110,13 @@ $UserStructCopyWith<$Res>? get user {
|
||||
|
||||
|
||||
class _ReceptionPageState with DiagnosticableTreeMixin implements ReceptionPageState {
|
||||
const _ReceptionPageState({this.user, this.loading = false});
|
||||
const _ReceptionPageState({this.user, this.receptions, this.loadingReceptions = false, this.loadingUser = false});
|
||||
|
||||
|
||||
@override final UserStruct? user;
|
||||
@override@JsonKey() final bool loading;
|
||||
@override final StockPickingResponseModel? receptions;
|
||||
@override@JsonKey() final bool loadingReceptions;
|
||||
@override@JsonKey() final bool loadingUser;
|
||||
|
||||
/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@ -113,21 +129,21 @@ _$ReceptionPageStateCopyWith<_ReceptionPageState> get copyWith => __$ReceptionPa
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
properties
|
||||
..add(DiagnosticsProperty('type', 'ReceptionPageState'))
|
||||
..add(DiagnosticsProperty('user', user))..add(DiagnosticsProperty('loading', loading));
|
||||
..add(DiagnosticsProperty('user', user))..add(DiagnosticsProperty('receptions', receptions))..add(DiagnosticsProperty('loadingReceptions', loadingReceptions))..add(DiagnosticsProperty('loadingUser', loadingUser));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ReceptionPageState&&(identical(other.user, user) || other.user == user)&&(identical(other.loading, loading) || other.loading == loading));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ReceptionPageState&&(identical(other.user, user) || other.user == user)&&(identical(other.receptions, receptions) || other.receptions == receptions)&&(identical(other.loadingReceptions, loadingReceptions) || other.loadingReceptions == loadingReceptions)&&(identical(other.loadingUser, loadingUser) || other.loadingUser == loadingUser));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,user,loading);
|
||||
int get hashCode => Object.hash(runtimeType,user,receptions,loadingReceptions,loadingUser);
|
||||
|
||||
@override
|
||||
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) {
|
||||
return 'ReceptionPageState(user: $user, loading: $loading)';
|
||||
return 'ReceptionPageState(user: $user, receptions: $receptions, loadingReceptions: $loadingReceptions, loadingUser: $loadingUser)';
|
||||
}
|
||||
|
||||
|
||||
@ -138,11 +154,11 @@ abstract mixin class _$ReceptionPageStateCopyWith<$Res> implements $ReceptionPag
|
||||
factory _$ReceptionPageStateCopyWith(_ReceptionPageState value, $Res Function(_ReceptionPageState) _then) = __$ReceptionPageStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
UserStruct? user, bool loading
|
||||
UserStruct? user, StockPickingResponseModel? receptions, bool loadingReceptions, bool loadingUser
|
||||
});
|
||||
|
||||
|
||||
@override $UserStructCopyWith<$Res>? get user;
|
||||
@override $UserStructCopyWith<$Res>? get user;@override $StockPickingResponseModelCopyWith<$Res>? get receptions;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@ -155,10 +171,12 @@ class __$ReceptionPageStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? user = freezed,Object? loading = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? user = freezed,Object? receptions = freezed,Object? loadingReceptions = null,Object? loadingUser = null,}) {
|
||||
return _then(_ReceptionPageState(
|
||||
user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as UserStruct?,loading: null == loading ? _self.loading : loading // ignore: cast_nullable_to_non_nullable
|
||||
as UserStruct?,receptions: freezed == receptions ? _self.receptions : receptions // ignore: cast_nullable_to_non_nullable
|
||||
as StockPickingResponseModel?,loadingReceptions: null == loadingReceptions ? _self.loadingReceptions : loadingReceptions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loadingUser: null == loadingUser ? _self.loadingUser : loadingUser // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
@ -175,6 +193,18 @@ $UserStructCopyWith<$Res>? get user {
|
||||
return $UserStructCopyWith<$Res>(_self.user!, (value) {
|
||||
return _then(_self.copyWith(user: value));
|
||||
});
|
||||
}/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$StockPickingResponseModelCopyWith<$Res>? get receptions {
|
||||
if (_self.receptions == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $StockPickingResponseModelCopyWith<$Res>(_self.receptions!, (value) {
|
||||
return _then(_self.copyWith(receptions: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user