autoreplace service operation
This commit is contained in:
@@ -29,10 +29,10 @@ class LatestStoreServicesBloc
|
||||
// Questo gira ad ogni "scatto" dello stream di Supabase
|
||||
List<ServiceModel> fullyHydratedServices = [];
|
||||
|
||||
for (ServiceModel service in rawServices) {
|
||||
for (ServiceModel operation in rawServices) {
|
||||
// Peschiamo i dati completi (incluso il cliente)
|
||||
ServiceModel fullService = await _repository.fetchServiceById(
|
||||
service.id!,
|
||||
operation.id!,
|
||||
);
|
||||
fullyHydratedServices.add(fullService);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class LatestStoreServicesBloc
|
||||
onData: (List<ServiceModel> fullyHydratedServices) {
|
||||
// Qui ora è tutto sincrono e bellissimo
|
||||
return state.copyWith(
|
||||
services: fullyHydratedServices,
|
||||
operations: fullyHydratedServices,
|
||||
status: LatestStoreServicesStatus.success,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -5,26 +5,26 @@ enum LatestStoreServicesStatus { initial, loading, success, failure }
|
||||
class LatestStoreServicesState extends Equatable {
|
||||
final LatestStoreServicesStatus status;
|
||||
final String? error;
|
||||
final List<ServiceModel> services;
|
||||
final List<ServiceModel> operations;
|
||||
|
||||
const LatestStoreServicesState({
|
||||
required this.status,
|
||||
this.error,
|
||||
this.services = const [],
|
||||
this.operations = const [],
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [status, error, services];
|
||||
List<Object?> get props => [status, error, operations];
|
||||
|
||||
LatestStoreServicesState copyWith({
|
||||
LatestStoreServicesStatus? status,
|
||||
String? error,
|
||||
List<ServiceModel>? services,
|
||||
List<ServiceModel>? operations,
|
||||
}) {
|
||||
return LatestStoreServicesState(
|
||||
status: status ?? this.status,
|
||||
error: error,
|
||||
services: services ?? this.services,
|
||||
operations: operations ?? this.operations,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () => context.push('/services'),
|
||||
onPressed: () => context.push('/operations'),
|
||||
child: Text(
|
||||
context.l10n.homeLatestServices,
|
||||
style: TextStyle(
|
||||
@@ -105,7 +105,7 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
if (state.services.isEmpty) {
|
||||
if (state.operations.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Nessun servizio recente.",
|
||||
@@ -118,16 +118,16 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
itemCount: state.services.length,
|
||||
itemCount: state.operations.length,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
height: 1,
|
||||
color: theme.dividerColor.withValues(alpha: 0.3),
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final service = state.services[index];
|
||||
final operation = state.operations[index];
|
||||
return InkWell(
|
||||
onTap: () =>
|
||||
context.push('/service-form', extra: service),
|
||||
context.push('/operation-form', extra: operation),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
@@ -136,7 +136,7 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
service.customerDisplayName ??
|
||||
operation.customerDisplayName ??
|
||||
'Cliente sconosciuto',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -147,7 +147,7 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
service.number,
|
||||
operation.number,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: context.primaryText,
|
||||
@@ -157,7 +157,7 @@ class _LatestServicesCardContent extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${service.createdAt?.day}/${service.createdAt?.month}",
|
||||
"${operation.createdAt?.day}/${operation.createdAt?.month}",
|
||||
style: TextStyle(
|
||||
color: context.secondaryText,
|
||||
fontSize: 12,
|
||||
|
||||
@@ -185,7 +185,7 @@ class HomeScreen extends StatelessWidget {
|
||||
color: Colors.blue,
|
||||
onTap: () {
|
||||
// Entriamo nel form! Nessun parametro extra = Nuovo Servizio
|
||||
context.push('/service-form');
|
||||
context.push('/operation-form');
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
||||
Reference in New Issue
Block a user