hkjg
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
import 'package:flux/features/attachments/models/attachment_model.dart';
|
||||
import 'package:flux/features/operations/data/operations_repository.dart';
|
||||
import 'package:flux/features/operations/models/operation_model.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
@@ -27,7 +27,7 @@ class OperationModel extends Equatable {
|
||||
final String? id;
|
||||
final DateTime? createdAt;
|
||||
final String type;
|
||||
final String? subType;
|
||||
final String? subtype;
|
||||
final String? providerId;
|
||||
final String? providerDisplayName;
|
||||
final String? modelId;
|
||||
@@ -56,7 +56,7 @@ class OperationModel extends Equatable {
|
||||
this.id,
|
||||
this.createdAt,
|
||||
this.type = '',
|
||||
this.subType,
|
||||
this.subtype,
|
||||
this.providerId,
|
||||
this.providerDisplayName,
|
||||
this.modelId,
|
||||
@@ -110,7 +110,7 @@ class OperationModel extends Equatable {
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
type: type ?? this.type,
|
||||
subType: subtype ?? this.subType,
|
||||
subtype: subtype ?? this.subtype,
|
||||
providerId: providerId ?? this.providerId,
|
||||
providerDisplayName: providerDisplayName ?? this.providerDisplayName,
|
||||
modelId: modelId ?? this.modelId,
|
||||
@@ -139,7 +139,7 @@ class OperationModel extends Equatable {
|
||||
id,
|
||||
createdAt,
|
||||
type,
|
||||
subType,
|
||||
subtype,
|
||||
providerId,
|
||||
providerDisplayName,
|
||||
modelId,
|
||||
@@ -174,7 +174,7 @@ class OperationModel extends Equatable {
|
||||
? DateTime.parse(map['created_at'])
|
||||
: null,
|
||||
type: map['type'] as String? ?? '',
|
||||
subType: map['sub_type'] as String?,
|
||||
subtype: map['sub_type'] as String?,
|
||||
providerId: map['provider_id'] as String? ?? '',
|
||||
providerDisplayName: "${map['provider']['name']}".myFormat(),
|
||||
modelId: map['model_id'] as String? ?? '',
|
||||
@@ -212,7 +212,7 @@ class OperationModel extends Equatable {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'type': type,
|
||||
'sub_type': subType,
|
||||
'sub_type': subtype,
|
||||
'provider_id': providerId,
|
||||
'model_id': modelId,
|
||||
'description': description,
|
||||
|
||||
@@ -164,41 +164,46 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
Expanded(
|
||||
child: BlocBuilder<CustomersCubit, CustomersState>(
|
||||
builder: (context, state) {
|
||||
/* Decommenta e adatta al tuo CustomersState
|
||||
if (state.status == CustomersStatus.loading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (state.customers.isEmpty) {
|
||||
return const Center(child: Text('Nessun cliente trovato.', style: TextStyle(color: Colors.grey)));
|
||||
return const Center(
|
||||
child: Text(
|
||||
'Nessun cliente trovato.',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
return ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: 10, // Sostituisci con state.customers.length
|
||||
itemCount: state.customers.length,
|
||||
itemBuilder: (context, index) {
|
||||
// final customer = state.customers[index];
|
||||
final customer = state.customers[index];
|
||||
return ListTile(
|
||||
leading: const CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
leading: CircleAvatar(
|
||||
child: Text(
|
||||
customer.name.substring(0, 1).toUpperCase(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
'Cliente $index',
|
||||
customer.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
), // Sostituisci con customer.name
|
||||
subtitle: const Text(
|
||||
'333 1234567',
|
||||
), // Sostituisci con customer.phoneNumber
|
||||
),
|
||||
subtitle: Text(
|
||||
'${customer.phoneNumber} • ${customer.email}',
|
||||
),
|
||||
onTap: () {
|
||||
// Aggiorniamo il form tramite il Cubit delle operazioni
|
||||
context
|
||||
.read<OperationsCubit>()
|
||||
.updateOperationFields(
|
||||
customerId:
|
||||
'id_del_cliente_$index', // customer.id
|
||||
customerId: customer.id, // customer.id
|
||||
customerDisplayName:
|
||||
'Cliente $index', // customer.name
|
||||
customer.name, // customer.name
|
||||
);
|
||||
Navigator.pop(modalContext);
|
||||
},
|
||||
@@ -433,8 +438,8 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
|
||||
// SOTTO-TIPO (Reattivo)
|
||||
if (['Energy', 'Fin', 'Entertainment'].contains(currentType)) ...[
|
||||
DropdownButtonFormField<String>(
|
||||
value:
|
||||
DropdownButtonFormField<String?>(
|
||||
initialValue:
|
||||
null, // Sostituisci con currentOp?.subtype quando lo aggiungi
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Dettaglio (es. Luce, Gas...)',
|
||||
@@ -481,6 +486,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
onTap: () async {
|
||||
final operationsCubit = context.read<OperationsCubit>();
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now().add(const Duration(days: 365)),
|
||||
@@ -488,9 +494,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
lastDate: DateTime.now().add(const Duration(days: 3650)),
|
||||
);
|
||||
if (date != null) {
|
||||
context.read<OperationsCubit>().updateOperationFields(
|
||||
expirationDate: date,
|
||||
);
|
||||
operationsCubit.updateOperationFields(expirationDate: date);
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -505,10 +509,11 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
||||
icon: const Icon(Icons.remove),
|
||||
onPressed: () {
|
||||
final q = currentOp?.quantity ?? 1;
|
||||
if (q > 1)
|
||||
if (q > 1) {
|
||||
context.read<OperationsCubit>().updateOperationFields(
|
||||
quantity: q - 1,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user