a
This commit is contained in:
@@ -194,6 +194,8 @@ class AppRouter {
|
||||
GetIt.I.get<SessionCubit>().state.currentStore!.id!,
|
||||
);
|
||||
context.read<CustomersCubit>().loadCustomers();
|
||||
context.read<ProductsCubit>().loadModels();
|
||||
context.read<ProductsCubit>().loadBrands();
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
@@ -230,28 +232,15 @@ class AppRouter {
|
||||
);
|
||||
},
|
||||
),
|
||||
/* GoRoute(
|
||||
path: '/customer/:id/upload',
|
||||
builder: (context, state) {
|
||||
final customerId = state.pathParameters['id']!;
|
||||
final customerName = state.uri.queryParameters['name'] ?? 'Cliente';
|
||||
return BlocProvider(
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentType: AttachmentParentType.customer,
|
||||
parentId: customerId,
|
||||
),
|
||||
child: SharedMobileUploadScreen(
|
||||
title: 'Aggiungi allegati al cliente $customerName',
|
||||
),
|
||||
);
|
||||
},
|
||||
), */
|
||||
|
||||
GoRoute(
|
||||
path: '/operation-form',
|
||||
path: '/operations/form/:id',
|
||||
name: 'operation-form',
|
||||
builder: (context, state) {
|
||||
final existingOperation = state.extra as OperationModel?;
|
||||
final operationId = state.uri.queryParameters['operationId'];
|
||||
final String pathId = state.pathParameters['id'] ?? 'new';
|
||||
final OperationModel? operationFromExtra =
|
||||
state.extra as OperationModel?;
|
||||
final String? realOperationId = pathId == 'new' ? null : pathId;
|
||||
final currentStoreId = GetIt.I
|
||||
.get<SessionCubit>()
|
||||
.state
|
||||
@@ -267,7 +256,7 @@ class AppRouter {
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentId: operationId ?? existingOperation?.id,
|
||||
parentId: realOperationId,
|
||||
parentType: AttachmentParentType.operation,
|
||||
),
|
||||
child: OperationFormScreen(
|
||||
@@ -277,35 +266,7 @@ class AppRouter {
|
||||
);
|
||||
},
|
||||
),
|
||||
/* GoRoute(
|
||||
path: '/operation/:id/upload',
|
||||
builder: (context, state) {
|
||||
final operationId = state.pathParameters['id']!;
|
||||
final operationName =
|
||||
state.uri.queryParameters['name'] ?? 'Pratica';
|
||||
final currentStoreId = GetIt.I
|
||||
.get<SessionCubit>()
|
||||
.state
|
||||
.currentStore!
|
||||
.id!;
|
||||
context.read<CustomersCubit>().loadCustomers();
|
||||
context.read<ProvidersCubit>().loadActiveProvidersForStore(
|
||||
currentStoreId,
|
||||
);
|
||||
context.read<ProductsCubit>().loadModels();
|
||||
context.read<ProductsCubit>().loadBrands();
|
||||
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
|
||||
return BlocProvider(
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentId: operationId,
|
||||
parentType: AttachmentParentType.operation,
|
||||
),
|
||||
child: SharedMobileUploadScreen(
|
||||
title: 'Aggiungi allegati alla pratica $operationName',
|
||||
),
|
||||
);
|
||||
},
|
||||
), */
|
||||
|
||||
GoRoute(
|
||||
path: '/upload/:type/:id',
|
||||
builder: (context, state) {
|
||||
|
||||
39
lib/features/operations/blocs/operation_form_state.dart
Normal file
39
lib/features/operations/blocs/operation_form_state.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flux/features/operations/models/operation_model.dart';
|
||||
|
||||
enum OperationFormStatus {
|
||||
initial,
|
||||
ready,
|
||||
loading,
|
||||
saving,
|
||||
success,
|
||||
successAndAddAnother,
|
||||
failure,
|
||||
}
|
||||
|
||||
class OperationFormState extends Equatable {
|
||||
final OperationModel operation;
|
||||
final OperationFormStatus status;
|
||||
final String? errorMessage;
|
||||
|
||||
const OperationFormState({
|
||||
required this.operation,
|
||||
this.status = OperationFormStatus.initial,
|
||||
this.errorMessage,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [operation, status, errorMessage];
|
||||
|
||||
OperationFormState copyWith({
|
||||
OperationModel? operation,
|
||||
OperationFormStatus? status,
|
||||
String? errorMessage,
|
||||
}) {
|
||||
return OperationFormState(
|
||||
operation: operation ?? this.operation,
|
||||
status: status ?? this.status,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user