@@ -51,7 +51,7 @@ class ProviderRepository {
|
||||
)
|
||||
''')
|
||||
.eq('company_id', companyId)
|
||||
.order('nome');
|
||||
.order('name');
|
||||
|
||||
return (response as List).map((m) => ProviderModel.fromMap(m)).toList();
|
||||
} catch (e) {
|
||||
|
||||
@@ -3,30 +3,30 @@ import 'package:flux/features/master_data/store/models/store_model.dart';
|
||||
|
||||
class ProviderModel extends Equatable {
|
||||
final String? id;
|
||||
final String nome;
|
||||
final bool telefoniaFissa;
|
||||
final bool telefoniaMobile;
|
||||
final bool energia;
|
||||
final bool assicurazioni;
|
||||
final bool intrattenimento;
|
||||
final bool finanziamenti;
|
||||
final String name;
|
||||
final bool landline;
|
||||
final bool mobile;
|
||||
final bool energy;
|
||||
final bool insurance;
|
||||
final bool entertainment;
|
||||
final bool financing;
|
||||
final bool telepass;
|
||||
final bool altro;
|
||||
final bool other;
|
||||
final bool isActive;
|
||||
final String companyId;
|
||||
final List<StoreModel> associatedStores;
|
||||
|
||||
const ProviderModel({
|
||||
this.id,
|
||||
required this.nome,
|
||||
required this.telefoniaFissa,
|
||||
required this.telefoniaMobile,
|
||||
required this.energia,
|
||||
required this.assicurazioni,
|
||||
required this.intrattenimento,
|
||||
required this.finanziamenti,
|
||||
required this.name,
|
||||
required this.landline,
|
||||
required this.mobile,
|
||||
required this.energy,
|
||||
required this.insurance,
|
||||
required this.entertainment,
|
||||
required this.financing,
|
||||
required this.telepass,
|
||||
required this.altro,
|
||||
required this.other,
|
||||
required this.isActive,
|
||||
required this.companyId,
|
||||
this.associatedStores = const [],
|
||||
@@ -46,15 +46,15 @@ class ProviderModel extends Equatable {
|
||||
}
|
||||
return ProviderModel(
|
||||
id: map['id'],
|
||||
nome: map['nome'],
|
||||
telefoniaFissa: map['telefonia_fissa'] ?? false,
|
||||
telefoniaMobile: map['telefonia_mobile'] ?? false,
|
||||
energia: map['energia'] ?? false,
|
||||
assicurazioni: map['assicurazioni'] ?? false,
|
||||
intrattenimento: map['intrattenimento'] ?? false,
|
||||
finanziamenti: map['finanziamenti'] ?? false,
|
||||
name: map['name'],
|
||||
landline: map['landline'] ?? false,
|
||||
mobile: map['mobile'] ?? false,
|
||||
energy: map['energy'] ?? false,
|
||||
insurance: map['insurance'] ?? false,
|
||||
entertainment: map['entertainment'] ?? false,
|
||||
financing: map['financing'] ?? false,
|
||||
telepass: map['telepass'] ?? false,
|
||||
altro: map['altro'] ?? false,
|
||||
other: map['other'] ?? false,
|
||||
isActive: map['is_active'] ?? true,
|
||||
companyId: map['company_id'],
|
||||
associatedStores: stores,
|
||||
@@ -63,15 +63,15 @@ class ProviderModel extends Equatable {
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final map = {
|
||||
'nome': nome,
|
||||
'telefonia_fissa': telefoniaFissa,
|
||||
'telefonia_mobile': telefoniaMobile,
|
||||
'energia': energia,
|
||||
'assicurazioni': assicurazioni,
|
||||
'intrattenimento': intrattenimento,
|
||||
'finanziamenti': finanziamenti,
|
||||
'name': name,
|
||||
'landline': landline,
|
||||
'mobile': mobile,
|
||||
'energy': energy,
|
||||
'insurance': insurance,
|
||||
'entertainment': entertainment,
|
||||
'financing': financing,
|
||||
'telepass': telepass,
|
||||
'altro': altro,
|
||||
'other': other,
|
||||
'is_active': isActive,
|
||||
'company_id': companyId,
|
||||
};
|
||||
@@ -86,15 +86,15 @@ class ProviderModel extends Equatable {
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
nome,
|
||||
telefoniaFissa,
|
||||
telefoniaMobile,
|
||||
energia,
|
||||
assicurazioni,
|
||||
intrattenimento,
|
||||
finanziamenti,
|
||||
name,
|
||||
landline,
|
||||
mobile,
|
||||
energy,
|
||||
insurance,
|
||||
entertainment,
|
||||
financing,
|
||||
telepass,
|
||||
altro,
|
||||
other,
|
||||
isActive,
|
||||
companyId,
|
||||
associatedStores,
|
||||
@@ -102,30 +102,30 @@ class ProviderModel extends Equatable {
|
||||
|
||||
ProviderModel copyWith({
|
||||
String? id,
|
||||
String? nome,
|
||||
bool? telefoniaFissa,
|
||||
bool? telefoniaMobile,
|
||||
bool? energia,
|
||||
bool? assicurazioni,
|
||||
bool? intrattenimento,
|
||||
bool? finanziamenti,
|
||||
String? name,
|
||||
bool? landline,
|
||||
bool? mobile,
|
||||
bool? energy,
|
||||
bool? insurance,
|
||||
bool? entertainment,
|
||||
bool? financing,
|
||||
bool? telepass,
|
||||
bool? altro,
|
||||
bool? other,
|
||||
bool? isActive,
|
||||
String? companyId,
|
||||
List<StoreModel>? associatedStores,
|
||||
}) {
|
||||
return ProviderModel(
|
||||
id: id ?? this.id,
|
||||
nome: nome ?? this.nome,
|
||||
telefoniaFissa: telefoniaFissa ?? this.telefoniaFissa,
|
||||
telefoniaMobile: telefoniaMobile ?? this.telefoniaMobile,
|
||||
energia: energia ?? this.energia,
|
||||
assicurazioni: assicurazioni ?? this.assicurazioni,
|
||||
intrattenimento: intrattenimento ?? this.intrattenimento,
|
||||
finanziamenti: finanziamenti ?? this.finanziamenti,
|
||||
name: name ?? this.name,
|
||||
landline: landline ?? this.landline,
|
||||
mobile: mobile ?? this.mobile,
|
||||
energy: energy ?? this.energy,
|
||||
insurance: insurance ?? this.insurance,
|
||||
entertainment: entertainment ?? this.entertainment,
|
||||
financing: financing ?? this.financing,
|
||||
telepass: telepass ?? this.telepass,
|
||||
altro: altro ?? this.altro,
|
||||
other: other ?? this.other,
|
||||
isActive: isActive ?? this.isActive,
|
||||
companyId: companyId ?? this.companyId,
|
||||
associatedStores: associatedStores ?? this.associatedStores,
|
||||
|
||||
@@ -15,14 +15,14 @@ class ProviderFormSheet extends StatefulWidget {
|
||||
|
||||
class _ProviderFormSheetState extends State<ProviderFormSheet> {
|
||||
late TextEditingController _nameController;
|
||||
late bool _telefoniaFissa;
|
||||
late bool _telefoniaMobile;
|
||||
late bool _energia;
|
||||
late bool _assicurazioni;
|
||||
late bool _intrattenimento;
|
||||
late bool _finanziamenti;
|
||||
late bool _landline;
|
||||
late bool _mobile;
|
||||
late bool _energy;
|
||||
late bool _insurance;
|
||||
late bool _entertainment;
|
||||
late bool _financing;
|
||||
late bool _telepass;
|
||||
late bool _altro;
|
||||
late bool _other;
|
||||
late bool _isActive;
|
||||
final List<String> _tempSelectedStoreIds =
|
||||
[]; // Per gestire la selezione temporanea dei negozi
|
||||
@@ -34,15 +34,15 @@ class _ProviderFormSheetState extends State<ProviderFormSheet> {
|
||||
for (final store in p?.associatedStores ?? []) {
|
||||
_tempSelectedStoreIds.add(store.id!);
|
||||
}
|
||||
_nameController = TextEditingController(text: p?.nome ?? '');
|
||||
_telefoniaFissa = p?.telefoniaFissa ?? false;
|
||||
_telefoniaMobile = p?.telefoniaMobile ?? false;
|
||||
_energia = p?.energia ?? false;
|
||||
_assicurazioni = p?.assicurazioni ?? false;
|
||||
_intrattenimento = p?.intrattenimento ?? false;
|
||||
_finanziamenti = p?.finanziamenti ?? false;
|
||||
_nameController = TextEditingController(text: p?.name ?? '');
|
||||
_landline = p?.landline ?? false;
|
||||
_mobile = p?.mobile ?? false;
|
||||
_energy = p?.energy ?? false;
|
||||
_insurance = p?.insurance ?? false;
|
||||
_entertainment = p?.entertainment ?? false;
|
||||
_financing = p?.financing ?? false;
|
||||
_telepass = p?.telepass ?? false;
|
||||
_altro = p?.altro ?? false;
|
||||
_other = p?.other ?? false;
|
||||
_isActive = p?.isActive ?? true;
|
||||
}
|
||||
|
||||
@@ -59,15 +59,15 @@ class _ProviderFormSheetState extends State<ProviderFormSheet> {
|
||||
final cubit = context.read<ProvidersCubit>();
|
||||
final provider = ProviderModel(
|
||||
id: widget.initialProvider?.id, // Se nullo, Supabase farà insert
|
||||
nome: _nameController.text.trim(),
|
||||
telefoniaFissa: _telefoniaFissa,
|
||||
telefoniaMobile: _telefoniaMobile,
|
||||
energia: _energia,
|
||||
assicurazioni: _assicurazioni,
|
||||
intrattenimento: _intrattenimento,
|
||||
finanziamenti: _finanziamenti,
|
||||
name: _nameController.text.trim(),
|
||||
landline: _landline,
|
||||
mobile: _mobile,
|
||||
energy: _energy,
|
||||
insurance: _insurance,
|
||||
entertainment: _entertainment,
|
||||
financing: _financing,
|
||||
telepass: _telepass,
|
||||
altro: _altro,
|
||||
other: _other,
|
||||
isActive: _isActive,
|
||||
companyId:
|
||||
'', // Verrà ignorato dal toMap e gestito dal Cubit/SessionBloc se hai messo la logica lì
|
||||
@@ -113,33 +113,33 @@ class _ProviderFormSheetState extends State<ProviderFormSheet> {
|
||||
),
|
||||
_buildSwitch(
|
||||
"Energia (Luce/Gas)",
|
||||
_energia,
|
||||
(v) => setState(() => _energia = v),
|
||||
_energy,
|
||||
(v) => setState(() => _energy = v),
|
||||
),
|
||||
_buildSwitch(
|
||||
"Telefonia Fissa",
|
||||
_telefoniaFissa,
|
||||
(v) => setState(() => _telefoniaFissa = v),
|
||||
_landline,
|
||||
(v) => setState(() => _landline = v),
|
||||
),
|
||||
_buildSwitch(
|
||||
"Telefonia Mobile",
|
||||
_telefoniaMobile,
|
||||
(v) => setState(() => _telefoniaMobile = v),
|
||||
_mobile,
|
||||
(v) => setState(() => _mobile = v),
|
||||
),
|
||||
_buildSwitch(
|
||||
"Assicurazioni",
|
||||
_assicurazioni,
|
||||
(v) => setState(() => _assicurazioni = v),
|
||||
_insurance,
|
||||
(v) => setState(() => _insurance = v),
|
||||
),
|
||||
_buildSwitch(
|
||||
"Intrattenimento",
|
||||
_intrattenimento,
|
||||
(v) => setState(() => _intrattenimento = v),
|
||||
_entertainment,
|
||||
(v) => setState(() => _entertainment = v),
|
||||
),
|
||||
_buildSwitch(
|
||||
"Finanziamenti",
|
||||
_finanziamenti,
|
||||
(v) => setState(() => _finanziamenti = v),
|
||||
_financing,
|
||||
(v) => setState(() => _financing = v),
|
||||
),
|
||||
_buildSwitch(
|
||||
"Telepass",
|
||||
@@ -148,8 +148,8 @@ class _ProviderFormSheetState extends State<ProviderFormSheet> {
|
||||
),
|
||||
_buildSwitch(
|
||||
"Altro/Accessori",
|
||||
_altro,
|
||||
(v) => setState(() => _altro = v),
|
||||
_other,
|
||||
(v) => setState(() => _other = v),
|
||||
),
|
||||
const Divider(),
|
||||
_buildSwitch(
|
||||
|
||||
@@ -93,7 +93,7 @@ class _ProvidersMasterDataScreenState extends State<ProvidersMasterDataScreen> {
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
provider.nome,
|
||||
provider.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: _buildCardSubtitle(
|
||||
@@ -141,14 +141,13 @@ class _ProvidersMasterDataScreenState extends State<ProvidersMasterDataScreen> {
|
||||
return Wrap(
|
||||
spacing: 4,
|
||||
children: [
|
||||
if (p.telefoniaFissa || p.telefoniaMobile)
|
||||
_smallTag("📞 Tel", Colors.blue),
|
||||
if (p.energia) _smallTag("⚡ Energy", Colors.orange),
|
||||
if (p.assicurazioni) _smallTag("🛡️ Assic", Colors.teal),
|
||||
if (p.intrattenimento) _smallTag("📺 Ent", Colors.red),
|
||||
if (p.finanziamenti) _smallTag("💰 Fin", Colors.purple),
|
||||
if (p.landline || p.mobile) _smallTag("📞 Tel", Colors.blue),
|
||||
if (p.energy) _smallTag("⚡ Energy", Colors.orange),
|
||||
if (p.insurance) _smallTag("🛡️ Assic", Colors.teal),
|
||||
if (p.entertainment) _smallTag("📺 Ent", Colors.red),
|
||||
if (p.financing) _smallTag("💰 Fin", Colors.purple),
|
||||
if (p.telepass) _smallTag("🏎️ Telepass", Colors.yellow),
|
||||
if (p.altro) _smallTag("📦 Altro", Colors.grey),
|
||||
if (p.other) _smallTag("📦 Altro", Colors.grey),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class StoreRepository {
|
||||
)
|
||||
''')
|
||||
.eq('company_id', companyId)
|
||||
.order('nome');
|
||||
.order('name');
|
||||
|
||||
return (response as List).map((m) => StoreModel.fromMap(m)).toList();
|
||||
} catch (e) {
|
||||
|
||||
@@ -191,7 +191,7 @@ class _StoreCardState extends State<StoreCard> {
|
||||
(p) => p.id == provider.id,
|
||||
);
|
||||
return CheckboxListTile(
|
||||
title: Text(provider.nome),
|
||||
title: Text(provider.name),
|
||||
value: isAssociated,
|
||||
onChanged: (selected) {
|
||||
if (selected == true) {
|
||||
|
||||
Reference in New Issue
Block a user