added singleUserMode and removed StaffSection from forms

This commit is contained in:
2026-05-13 15:41:35 +02:00
parent efb82b0d4a
commit c610d68b9c
9 changed files with 138 additions and 84 deletions

View File

@@ -213,12 +213,23 @@ class AppRouter {
builder: (context, state) {
// 1. Leggiamo l'ID dall'URL
final String pathId = state.pathParameters['id'] ?? 'new';
// 2. CAST DA NINJA (Aggiungi i punti interrogativi!)
final record =
state.extra
as ({StaffMemberModel createdBy, TicketModel ticket});
as ({StaffMemberModel? createdBy, TicketModel? ticket})?;
final String? realTicketId = pathId == 'new' ? null : pathId;
// 3. LOGICA SOBRIA
final String? realTicketId;
if (pathId == 'new') {
realTicketId = null;
} else if (record?.ticket?.id != null) {
// <-- Parentesi TONDE per la condizione, GRAFFE per il blocco!
realTicketId = record!.ticket!.id;
} else {
realTicketId = pathId;
}
context.read<CustomersCubit>().loadCustomers();
context.read<ProductsCubit>().loadModels();
context.read<ProductsCubit>().loadBrands();
@@ -231,12 +242,18 @@ class AppRouter {
parentId: realTicketId,
),
),
BlocProvider(create: (context) => TicketFormCubit()),
BlocProvider(
create: (context) => TicketFormCubit(
// Passiamo il creatore e l'eventuale ticket esistente presi dal Record!
createdBy: record?.createdBy,
existingTicket: record?.ticket,
),
),
],
child: TicketFormScreen(
ticketId: realTicketId,
existingTicket: record.ticket,
existingTicket: record?.ticket,
),
);
},
@@ -267,9 +284,21 @@ class AppRouter {
builder: (context, state) {
final String pathId = state.pathParameters['id'] ?? 'new';
final OperationModel? operationFromExtra =
state.extra as OperationModel?;
final String? realOperationId = pathId == 'new' ? null : pathId;
final record =
state.extra
as ({
StaffMemberModel? createdBy,
OperationModel? operation,
})?;
final String? realOperationId;
if (pathId == 'new') {
realOperationId = null;
} else if (record?.operation?.id != null) {
realOperationId = record!.operation!.id;
} else {
realOperationId = pathId;
}
final currentStoreId = GetIt.I
.get<SessionCubit>()
.state
@@ -281,8 +310,6 @@ class AppRouter {
);
context.read<ProductsCubit>().loadModels();
context.read<ProductsCubit>().loadBrands();
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
return MultiBlocProvider(
providers: [
BlocProvider(
@@ -293,14 +320,14 @@ class AppRouter {
),
BlocProvider(
create: (context) => OperationFormCubit(
createdById: createdById,
createdByName: createdByName,
createdBy: record?.createdBy,
existingOperation: record?.operation,
),
),
],
child: OperationFormScreen(
operationId: realOperationId,
existingOperation: operationFromExtra,
existingOperation: record?.operation,
),
);
},