feat-tickets (#14)
Some checks failed
Deploy to Cloudflare Pages / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy to Cloudflare Pages / build-and-deploy (push) Has been cancelled
Reviewed-on: #14 Co-authored-by: mark-cachy <marco@catelli.it> Co-committed-by: mark-cachy <marco@catelli.it>
This commit is contained in:
@@ -6,12 +6,12 @@ import 'package:flux/core/data/core_repository.dart';
|
||||
import 'package:flux/core/layout/app_shell.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/core/widgets/set_password_screen.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/mobile_upload_screen.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/upload_success_screen.dart';
|
||||
import 'package:flux/features/auth/ui/auth_screen.dart';
|
||||
import 'package:flux/features/customers/blocs/customer_files_bloc.dart';
|
||||
import 'package:flux/features/customers/blocs/customers_cubit.dart';
|
||||
import 'package:flux/features/customers/models/customer_model.dart';
|
||||
import 'package:flux/features/customers/ui/customer_detail_screen.dart';
|
||||
import 'package:flux/features/customers/ui/customer_mobile_upload_screen.dart';
|
||||
import 'package:flux/features/customers/ui/customers_content.dart';
|
||||
import 'package:flux/features/home/ui/home_screen.dart';
|
||||
import 'package:flux/features/master_data/master_data_hub_content.dart';
|
||||
@@ -24,11 +24,15 @@ import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
|
||||
import 'package:flux/features/master_data/store/ui/stores_screen.dart';
|
||||
import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
||||
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
|
||||
import 'package:flux/features/operations/blocs/operation_files_bloc.dart';
|
||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||
import 'package:flux/features/operations/models/operation_model.dart';
|
||||
import 'package:flux/features/operations/ui/operation_form_screen.dart';
|
||||
import 'package:flux/features/operations/ui/operation_mobile_upload_screen.dart';
|
||||
import 'package:flux/features/operations/ui/operations_screen.dart';
|
||||
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||
import 'package:flux/features/tickets/ui/ticket_form_screen.dart';
|
||||
import 'package:flux/features/tickets/ui/ticket_list_screen.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
@@ -146,34 +150,85 @@ class AppRouter {
|
||||
builder: (context, state) =>
|
||||
const CustomersContent(), // O come si chiama il tuo widget della lista!
|
||||
),
|
||||
GoRoute(
|
||||
path: '/tickets',
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (context) => TicketListCubit(),
|
||||
child: const TicketListScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// --- DETTAGLI E OPERATIVITÀ (FUORI DALLA SHELL - TUTTO SCHERMO) ---
|
||||
GoRoute(
|
||||
path: '/customer/:id',
|
||||
// Il path sarà es. /tickets/form/123 oppure /tickets/form/new
|
||||
path: '/tickets/form/:id',
|
||||
builder: (context, state) {
|
||||
final customer = state.extra as CustomerModel;
|
||||
return BlocProvider(
|
||||
create: (context) => CustomerFilesBloc(customer.id!),
|
||||
child: CustomerDetailScreen(customer: customer),
|
||||
// 1. Leggiamo l'ID dall'URL
|
||||
final String pathId = state.pathParameters['id'] ?? 'new';
|
||||
|
||||
// 2. Leggiamo l'oggetto dalla RAM (se arriviamo da un tap interno all'app)
|
||||
final TicketModel? ticketFromExtra = state.extra as TicketModel?;
|
||||
|
||||
// 3. Capiamo se è un nuovo ticket o una modifica
|
||||
final String? realTicketId = pathId == 'new' ? null : pathId;
|
||||
context.read<StaffCubit>().loadStaffForStore(
|
||||
GetIt.I.get<SessionCubit>().state.currentStore!.id!,
|
||||
);
|
||||
context.read<CustomersCubit>().loadCustomers();
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentType: AttachmentParentType.ticket,
|
||||
parentId: realTicketId,
|
||||
),
|
||||
),
|
||||
BlocProvider(create: (context) => TicketFormCubit()),
|
||||
],
|
||||
|
||||
child: TicketFormScreen(
|
||||
ticketId: realTicketId,
|
||||
existingTicket: ticketFromExtra,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/upload-success',
|
||||
builder: (context, state) => const UploadSuccessScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/customer/:id',
|
||||
builder: (context, state) {
|
||||
final customer = state.extra as CustomerModel;
|
||||
return BlocProvider(
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentType: AttachmentParentType.customer,
|
||||
parentId: customer.id,
|
||||
),
|
||||
child: CustomerDetailScreen(customer: customer),
|
||||
);
|
||||
},
|
||||
),
|
||||
/* GoRoute(
|
||||
path: '/customer/:id/upload',
|
||||
builder: (context, state) {
|
||||
final customerId = state.pathParameters['id']!;
|
||||
final customerName = state.uri.queryParameters['name'] ?? 'Cliente';
|
||||
return BlocProvider(
|
||||
create: (context) => CustomerFilesBloc(customerId),
|
||||
child: CustomerMobileUploadScreen(
|
||||
customerId: customerId,
|
||||
customerName: customerName,
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentType: AttachmentParentType.customer,
|
||||
parentId: customerId,
|
||||
),
|
||||
child: SharedMobileUploadScreen(
|
||||
title: 'Aggiungi allegati al cliente $customerName',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
), */
|
||||
GoRoute(
|
||||
path: '/operation-form',
|
||||
name: 'operation-form',
|
||||
@@ -194,8 +249,9 @@ class AppRouter {
|
||||
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => OperationFilesBloc(
|
||||
operationId: operationId ?? existingOperation?.id,
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentId: operationId ?? existingOperation?.id,
|
||||
parentType: AttachmentParentType.operation,
|
||||
),
|
||||
child: OperationFormScreen(
|
||||
operationId: operationId ?? existingOperation?.id,
|
||||
@@ -204,7 +260,7 @@ class AppRouter {
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
/* GoRoute(
|
||||
path: '/operation/:id/upload',
|
||||
builder: (context, state) {
|
||||
final operationId = state.pathParameters['id']!;
|
||||
@@ -223,10 +279,35 @@ class AppRouter {
|
||||
context.read<ProductsCubit>().loadBrands();
|
||||
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
|
||||
return BlocProvider(
|
||||
create: (context) => OperationFilesBloc(operationId: operationId),
|
||||
child: OperationMobileUploadScreen(
|
||||
operationId: operationId,
|
||||
operationName: operationName,
|
||||
create: (context) => AttachmentsBloc(
|
||||
parentId: operationId,
|
||||
parentType: AttachmentParentType.operation,
|
||||
),
|
||||
child: SharedMobileUploadScreen(
|
||||
title: 'Aggiungi allegati alla pratica $operationName',
|
||||
),
|
||||
);
|
||||
},
|
||||
), */
|
||||
GoRoute(
|
||||
path: '/upload/:type/:id',
|
||||
builder: (context, state) {
|
||||
final typeString = state.pathParameters['type']!;
|
||||
final id = state.pathParameters['id']!;
|
||||
|
||||
// Trasformiamo la stringa dell'URL nel nostro amato Enum!
|
||||
final parentType = AttachmentParentType.values.firstWhere(
|
||||
(e) => e.name == typeString,
|
||||
orElse: () =>
|
||||
AttachmentParentType.ticket, // Fallback di sicurezza
|
||||
);
|
||||
|
||||
// Creiamo il BLoC "al volo" solo per questa schermata
|
||||
return BlocProvider(
|
||||
create: (context) =>
|
||||
AttachmentsBloc(parentId: id, parentType: parentType),
|
||||
child: const SharedMobileUploadScreen(
|
||||
title: 'Caricamento Rapido',
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user