ticket form funzionante! devo ancora provare a salvare però
This commit is contained in:
@@ -6,7 +6,7 @@ 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/shared_mobile_upload_screen.dart';
|
||||
import 'package:flux/core/widgets/shared_forms/mobile_upload_screen.dart';
|
||||
import 'package:flux/features/auth/ui/auth_screen.dart';
|
||||
import 'package:flux/features/customers/blocs/customers_cubit.dart';
|
||||
import 'package:flux/features/customers/models/customer_model.dart';
|
||||
@@ -27,7 +27,10 @@ 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/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';
|
||||
@@ -157,6 +160,32 @@ class AppRouter {
|
||||
),
|
||||
|
||||
// --- DETTAGLI E OPERATIVITÀ (FUORI DALLA SHELL - TUTTO SCHERMO) ---
|
||||
GoRoute(
|
||||
// Il path sarà es. /tickets/form/123 oppure /tickets/form/new
|
||||
path: '/tickets/form/:id',
|
||||
builder: (context, state) {
|
||||
// 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 BlocProvider(
|
||||
create: (context) => TicketFormCubit(),
|
||||
child: TicketFormScreen(
|
||||
ticketId: realTicketId,
|
||||
existingTicket: ticketFromExtra,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/customer/:id',
|
||||
builder: (context, state) {
|
||||
|
||||
@@ -22,6 +22,7 @@ class StaffSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
// Se staffId è nullo, proviamo a preselezionare l'utente loggato
|
||||
final selectedStaffId =
|
||||
staffId ?? GetIt.I.get<SessionCubit>().state.currentStaffMember?.id;
|
||||
|
||||
@@ -31,7 +32,8 @@ class StaffSection extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: Text(
|
||||
'Operatore',
|
||||
label ??
|
||||
'Operatore', // <-- FIX: Ora usa l'etichetta passata dal form!
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -39,8 +41,28 @@ class StaffSection extends StatelessWidget {
|
||||
),
|
||||
BlocBuilder<StaffCubit, StaffState>(
|
||||
builder: (context, state) {
|
||||
// Dati finti per farti vedere la UI, piallali quando attacchi il BlocBuilder!
|
||||
// FIX: Aggiunto un controllo se sta caricando
|
||||
if (state.status == StaffStatus.loading) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final staffMembers = state.storeStaff;
|
||||
|
||||
// FIX: Feedback visivo se la lista è vuota
|
||||
if (staffMembers.isEmpty) {
|
||||
return const Text(
|
||||
'Nessun operatore caricato. Controlla il Cubit!',
|
||||
style: TextStyle(color: Colors.red),
|
||||
);
|
||||
}
|
||||
|
||||
final currentLoggedStaffMember = GetIt.I
|
||||
.get<SessionCubit>()
|
||||
.state
|
||||
@@ -55,11 +77,6 @@ class StaffSection extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
onStaffSelected(staff);
|
||||
|
||||
/* context.read<OperationsCubit>().updateOperationFields(
|
||||
staffId: staff.id,
|
||||
staffDisplayName: staff.name,
|
||||
); */
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
Reference in New Issue
Block a user