tasks
This commit is contained in:
@@ -46,8 +46,10 @@ import 'package:flux/features/operations/ui/operation_list_screen.dart';
|
||||
import 'package:flux/features/settings/settings_screen.dart';
|
||||
import 'package:flux/features/settings/theme_settings_view.dart';
|
||||
import 'package:flux/features/tasks/blocs/task_form_cubit.dart';
|
||||
import 'package:flux/features/tasks/blocs/task_list_cubit.dart';
|
||||
import 'package:flux/features/tasks/models/task_model.dart';
|
||||
import 'package:flux/features/tasks/ui/task_form_screen.dart';
|
||||
import 'package:flux/features/tasks/ui/task_list_screen.dart';
|
||||
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||
import 'package:flux/features/tickets/ui/ticket_form_screen.dart';
|
||||
@@ -238,11 +240,34 @@ class AppRouter {
|
||||
name: Routes.notes,
|
||||
builder: (context, state) => const NotesListScreen(),
|
||||
),
|
||||
/* GoRoute(
|
||||
GoRoute(
|
||||
path: '/tasks',
|
||||
name: Routes.tasks,
|
||||
builder: (context, state) => const TaskListScreen(),
|
||||
), */
|
||||
builder: (context, state) {
|
||||
// 1. Recuperiamo lo stato della sessione per le dipendenze
|
||||
final sessionState = context.read<SessionCubit>().state;
|
||||
|
||||
// Sicurezza: Se per qualche motivo non abbiamo l'azienda,
|
||||
// qui potresti reindirizzare o gestire l'errore
|
||||
final companyId = sessionState.company?.id;
|
||||
if (companyId == null) {
|
||||
return const Scaffold(
|
||||
body: Center(child: Text("Errore: Azienda non trovata")),
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Iniettiamo il Cubit con tutto ciò che gli serve
|
||||
return BlocProvider(
|
||||
create: (context) => TaskListCubit(
|
||||
currentCompanyId: companyId,
|
||||
currentStoreId: sessionState
|
||||
.currentStore
|
||||
?.id, // Opzionale: filtra per negozio se l'utente è "dentro" uno store
|
||||
),
|
||||
child: const TaskListScreen(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user