hkjg
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flux/core/blocs/session/session_cubit.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/data/operations_repository.dart';
|
||||||
import 'package:flux/features/operations/models/operation_model.dart';
|
import 'package:flux/features/operations/models/operation_model.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class OperationModel extends Equatable {
|
|||||||
final String? id;
|
final String? id;
|
||||||
final DateTime? createdAt;
|
final DateTime? createdAt;
|
||||||
final String type;
|
final String type;
|
||||||
final String? subType;
|
final String? subtype;
|
||||||
final String? providerId;
|
final String? providerId;
|
||||||
final String? providerDisplayName;
|
final String? providerDisplayName;
|
||||||
final String? modelId;
|
final String? modelId;
|
||||||
@@ -56,7 +56,7 @@ class OperationModel extends Equatable {
|
|||||||
this.id,
|
this.id,
|
||||||
this.createdAt,
|
this.createdAt,
|
||||||
this.type = '',
|
this.type = '',
|
||||||
this.subType,
|
this.subtype,
|
||||||
this.providerId,
|
this.providerId,
|
||||||
this.providerDisplayName,
|
this.providerDisplayName,
|
||||||
this.modelId,
|
this.modelId,
|
||||||
@@ -110,7 +110,7 @@ class OperationModel extends Equatable {
|
|||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAt: createdAt ?? this.createdAt,
|
||||||
type: type ?? this.type,
|
type: type ?? this.type,
|
||||||
subType: subtype ?? this.subType,
|
subtype: subtype ?? this.subtype,
|
||||||
providerId: providerId ?? this.providerId,
|
providerId: providerId ?? this.providerId,
|
||||||
providerDisplayName: providerDisplayName ?? this.providerDisplayName,
|
providerDisplayName: providerDisplayName ?? this.providerDisplayName,
|
||||||
modelId: modelId ?? this.modelId,
|
modelId: modelId ?? this.modelId,
|
||||||
@@ -139,7 +139,7 @@ class OperationModel extends Equatable {
|
|||||||
id,
|
id,
|
||||||
createdAt,
|
createdAt,
|
||||||
type,
|
type,
|
||||||
subType,
|
subtype,
|
||||||
providerId,
|
providerId,
|
||||||
providerDisplayName,
|
providerDisplayName,
|
||||||
modelId,
|
modelId,
|
||||||
@@ -174,7 +174,7 @@ class OperationModel extends Equatable {
|
|||||||
? DateTime.parse(map['created_at'])
|
? DateTime.parse(map['created_at'])
|
||||||
: null,
|
: null,
|
||||||
type: map['type'] as String? ?? '',
|
type: map['type'] as String? ?? '',
|
||||||
subType: map['sub_type'] as String?,
|
subtype: map['sub_type'] as String?,
|
||||||
providerId: map['provider_id'] as String? ?? '',
|
providerId: map['provider_id'] as String? ?? '',
|
||||||
providerDisplayName: "${map['provider']['name']}".myFormat(),
|
providerDisplayName: "${map['provider']['name']}".myFormat(),
|
||||||
modelId: map['model_id'] as String? ?? '',
|
modelId: map['model_id'] as String? ?? '',
|
||||||
@@ -212,7 +212,7 @@ class OperationModel extends Equatable {
|
|||||||
return {
|
return {
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
'type': type,
|
'type': type,
|
||||||
'sub_type': subType,
|
'sub_type': subtype,
|
||||||
'provider_id': providerId,
|
'provider_id': providerId,
|
||||||
'model_id': modelId,
|
'model_id': modelId,
|
||||||
'description': description,
|
'description': description,
|
||||||
|
|||||||
@@ -164,41 +164,46 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: BlocBuilder<CustomersCubit, CustomersState>(
|
child: BlocBuilder<CustomersCubit, CustomersState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
/* Decommenta e adatta al tuo CustomersState
|
|
||||||
if (state.status == CustomersStatus.loading) {
|
if (state.status == CustomersStatus.loading) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
if (state.customers.isEmpty) {
|
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(
|
return ListView.builder(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
itemCount: 10, // Sostituisci con state.customers.length
|
itemCount: state.customers.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
// final customer = state.customers[index];
|
final customer = state.customers[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: const CircleAvatar(
|
leading: CircleAvatar(
|
||||||
child: Icon(Icons.person),
|
child: Text(
|
||||||
|
customer.name.substring(0, 1).toUpperCase(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
'Cliente $index',
|
customer.name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
), // Sostituisci con customer.name
|
),
|
||||||
subtitle: const Text(
|
subtitle: Text(
|
||||||
'333 1234567',
|
'${customer.phoneNumber} • ${customer.email}',
|
||||||
), // Sostituisci con customer.phoneNumber
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Aggiorniamo il form tramite il Cubit delle operazioni
|
// Aggiorniamo il form tramite il Cubit delle operazioni
|
||||||
context
|
context
|
||||||
.read<OperationsCubit>()
|
.read<OperationsCubit>()
|
||||||
.updateOperationFields(
|
.updateOperationFields(
|
||||||
customerId:
|
customerId: customer.id, // customer.id
|
||||||
'id_del_cliente_$index', // customer.id
|
|
||||||
customerDisplayName:
|
customerDisplayName:
|
||||||
'Cliente $index', // customer.name
|
customer.name, // customer.name
|
||||||
);
|
);
|
||||||
Navigator.pop(modalContext);
|
Navigator.pop(modalContext);
|
||||||
},
|
},
|
||||||
@@ -433,8 +438,8 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
|||||||
|
|
||||||
// SOTTO-TIPO (Reattivo)
|
// SOTTO-TIPO (Reattivo)
|
||||||
if (['Energy', 'Fin', 'Entertainment'].contains(currentType)) ...[
|
if (['Energy', 'Fin', 'Entertainment'].contains(currentType)) ...[
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String?>(
|
||||||
value:
|
initialValue:
|
||||||
null, // Sostituisci con currentOp?.subtype quando lo aggiungi
|
null, // Sostituisci con currentOp?.subtype quando lo aggiungi
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Dettaglio (es. Luce, Gas...)',
|
labelText: 'Dettaglio (es. Luce, Gas...)',
|
||||||
@@ -481,6 +486,7 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
final operationsCubit = context.read<OperationsCubit>();
|
||||||
final date = await showDatePicker(
|
final date = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: DateTime.now().add(const Duration(days: 365)),
|
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)),
|
lastDate: DateTime.now().add(const Duration(days: 3650)),
|
||||||
);
|
);
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
context.read<OperationsCubit>().updateOperationFields(
|
operationsCubit.updateOperationFields(expirationDate: date);
|
||||||
expirationDate: date,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -505,10 +509,11 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
|||||||
icon: const Icon(Icons.remove),
|
icon: const Icon(Icons.remove),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final q = currentOp?.quantity ?? 1;
|
final q = currentOp?.quantity ?? 1;
|
||||||
if (q > 1)
|
if (q > 1) {
|
||||||
context.read<OperationsCubit>().updateOperationFields(
|
context.read<OperationsCubit>().updateOperationFields(
|
||||||
quantity: q - 1,
|
quantity: q - 1,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -50,13 +50,13 @@
|
|||||||
"commonNewPassword": "Nuova Password",
|
"commonNewPassword": "Nuova Password",
|
||||||
"commonNote": "Nota",
|
"commonNote": "Nota",
|
||||||
"commonSave": "Salva",
|
"commonSave": "Salva",
|
||||||
"commonOperation": "Servizio",
|
"commonOperation": "Operazione",
|
||||||
"commonSettings": "Impostazioni",
|
"commonSettings": "Impostazioni",
|
||||||
"commonStickyNotes": "Sticky Notes",
|
"commonStickyNotes": "Sticky Notes",
|
||||||
"commonTask": "Attività",
|
"commonTask": "Attività",
|
||||||
"homeExpiringContracts": "Contratti in scadenza",
|
"homeExpiringContracts": "Contratti in scadenza",
|
||||||
"homeLatestOperationTickets": "Ultime assistenze",
|
"homeLatestOperationTickets": "Ultime assistenze",
|
||||||
"homeLatestOperations": "Ultimi Servizi",
|
"homeLatestOperations": "Ultime Operazioni",
|
||||||
"homeMyTasks": "Mie Attività",
|
"homeMyTasks": "Mie Attività",
|
||||||
"homeNewOperationTicket": "Nuova assistenza",
|
"homeNewOperationTicket": "Nuova assistenza",
|
||||||
"homeNoStoreFound": "Nessun negozio trovato",
|
"homeNoStoreFound": "Nessun negozio trovato",
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ abstract class AppLocalizations {
|
|||||||
/// No description provided for @commonOperation.
|
/// No description provided for @commonOperation.
|
||||||
///
|
///
|
||||||
/// In it, this message translates to:
|
/// In it, this message translates to:
|
||||||
/// **'Servizio'**
|
/// **'Operazione'**
|
||||||
String get commonOperation;
|
String get commonOperation;
|
||||||
|
|
||||||
/// No description provided for @commonSettings.
|
/// No description provided for @commonSettings.
|
||||||
@@ -259,7 +259,7 @@ abstract class AppLocalizations {
|
|||||||
/// No description provided for @homeLatestOperations.
|
/// No description provided for @homeLatestOperations.
|
||||||
///
|
///
|
||||||
/// In it, this message translates to:
|
/// In it, this message translates to:
|
||||||
/// **'Ultimi Servizi'**
|
/// **'Ultime Operazioni'**
|
||||||
String get homeLatestOperations;
|
String get homeLatestOperations;
|
||||||
|
|
||||||
/// No description provided for @homeMyTasks.
|
/// No description provided for @homeMyTasks.
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class AppLocalizationsIt extends AppLocalizations {
|
|||||||
String get commonSave => 'Salva';
|
String get commonSave => 'Salva';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get commonOperation => 'Servizio';
|
String get commonOperation => 'Operazione';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get commonSettings => 'Impostazioni';
|
String get commonSettings => 'Impostazioni';
|
||||||
@@ -99,7 +99,7 @@ class AppLocalizationsIt extends AppLocalizations {
|
|||||||
String get homeLatestOperationTickets => 'Ultime assistenze';
|
String get homeLatestOperationTickets => 'Ultime assistenze';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get homeLatestOperations => 'Ultimi Servizi';
|
String get homeLatestOperations => 'Ultime Operazioni';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get homeMyTasks => 'Mie Attività';
|
String get homeMyTasks => 'Mie Attività';
|
||||||
|
|||||||
Reference in New Issue
Block a user