added singleUserMode and removed StaffSection from forms
This commit is contained in:
@@ -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,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -79,7 +79,10 @@ class StaffSelectorModal extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStaffGrid(BuildContext context, List<dynamic> staffList) {
|
||||
Widget _buildStaffGrid(
|
||||
BuildContext context,
|
||||
List<StaffMemberModel> staffList,
|
||||
) {
|
||||
return Wrap(
|
||||
spacing: 16,
|
||||
runSpacing: 16,
|
||||
@@ -98,7 +101,7 @@ class StaffSelectorModal extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHighest.withOpacity(0.3),
|
||||
).colorScheme.surfaceContainerHighest.withValues(alpha: 0.3),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Theme.of(context).dividerColor),
|
||||
),
|
||||
@@ -109,7 +112,7 @@ class StaffSelectorModal extends StatelessWidget {
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
child: Text(
|
||||
staff['name'].substring(0, 1).toUpperCase(),
|
||||
staff.name.substring(0, 1).toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -118,7 +121,7 @@ class StaffSelectorModal extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
staff['name'],
|
||||
staff.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user