rinominati i campi in inglese per diminuire confusione
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -4,30 +4,30 @@ import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||
|
||||
class StoreModel extends Equatable {
|
||||
final String? id;
|
||||
final String nome;
|
||||
final String name;
|
||||
final String companyId;
|
||||
final bool isActive;
|
||||
final bool isPaid;
|
||||
final DateTime? paymentExpiration;
|
||||
final String indirizzo;
|
||||
final String cap;
|
||||
final String comune;
|
||||
final String provincia;
|
||||
final String address;
|
||||
final String zipCode;
|
||||
final String city;
|
||||
final String province;
|
||||
final List<ProviderModel> associatedProviders; // Provider associati
|
||||
final List<StaffMemberModel>
|
||||
associatedStaffMembers; // Membri dello staff associati
|
||||
|
||||
const StoreModel({
|
||||
this.id,
|
||||
required this.nome,
|
||||
required this.name,
|
||||
required this.companyId,
|
||||
this.isActive = true,
|
||||
this.isPaid = false,
|
||||
this.paymentExpiration,
|
||||
required this.indirizzo,
|
||||
required this.cap,
|
||||
required this.comune,
|
||||
required this.provincia,
|
||||
required this.address,
|
||||
required this.zipCode,
|
||||
required this.city,
|
||||
required this.province,
|
||||
this.associatedProviders = const [],
|
||||
this.associatedStaffMembers = const [],
|
||||
});
|
||||
@@ -36,15 +36,15 @@ class StoreModel extends Equatable {
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
nome,
|
||||
name,
|
||||
companyId,
|
||||
isActive,
|
||||
isPaid,
|
||||
paymentExpiration,
|
||||
indirizzo,
|
||||
cap,
|
||||
comune,
|
||||
provincia,
|
||||
address,
|
||||
zipCode,
|
||||
city,
|
||||
province,
|
||||
associatedProviders,
|
||||
associatedStaffMembers,
|
||||
];
|
||||
@@ -52,29 +52,29 @@ class StoreModel extends Equatable {
|
||||
// Il mitico copyWith per creare nuove istanze modificando solo ciò che serve
|
||||
StoreModel copyWith({
|
||||
String? id,
|
||||
String? nome,
|
||||
String? name,
|
||||
String? companyId,
|
||||
bool? isActive,
|
||||
bool? isPaid,
|
||||
DateTime? paymentExpiration,
|
||||
String? indirizzo,
|
||||
String? cap,
|
||||
String? comune,
|
||||
String? provincia,
|
||||
String? address,
|
||||
String? zipCode,
|
||||
String? city,
|
||||
String? province,
|
||||
List<ProviderModel>? associatedProviders,
|
||||
List<StaffMemberModel>? associatedStaffMembers,
|
||||
}) {
|
||||
return StoreModel(
|
||||
id: id ?? this.id,
|
||||
nome: nome ?? this.nome,
|
||||
name: name ?? this.name,
|
||||
companyId: companyId ?? this.companyId,
|
||||
isActive: isActive ?? this.isActive,
|
||||
isPaid: isPaid ?? this.isPaid,
|
||||
paymentExpiration: paymentExpiration ?? this.paymentExpiration,
|
||||
indirizzo: indirizzo ?? this.indirizzo,
|
||||
cap: cap ?? this.cap,
|
||||
comune: comune ?? this.comune,
|
||||
provincia: provincia ?? this.provincia,
|
||||
address: address ?? this.address,
|
||||
zipCode: zipCode ?? this.zipCode,
|
||||
city: city ?? this.city,
|
||||
province: province ?? this.province,
|
||||
associatedProviders: associatedProviders ?? this.associatedProviders,
|
||||
associatedStaffMembers:
|
||||
associatedStaffMembers ?? this.associatedStaffMembers,
|
||||
@@ -83,12 +83,12 @@ class StoreModel extends Equatable {
|
||||
|
||||
factory StoreModel.empty() {
|
||||
return const StoreModel(
|
||||
nome: '',
|
||||
name: '',
|
||||
companyId: '',
|
||||
indirizzo: '',
|
||||
cap: '',
|
||||
comune: '',
|
||||
provincia: '',
|
||||
address: '',
|
||||
zipCode: '',
|
||||
city: '',
|
||||
province: '',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,17 +118,17 @@ class StoreModel extends Equatable {
|
||||
}
|
||||
return StoreModel(
|
||||
id: map['id'] as String,
|
||||
nome: map['nome'],
|
||||
name: map['name'],
|
||||
companyId: map['company_id'] as String,
|
||||
isActive: map['is_active'] ?? true,
|
||||
isPaid: map['is_paid'] ?? false,
|
||||
paymentExpiration: map['payment_expiration'] != null
|
||||
? DateTime.parse(map['payment_expiration'])
|
||||
: null,
|
||||
indirizzo: map['indirizzo'],
|
||||
cap: map['cap'],
|
||||
comune: map['comune'],
|
||||
provincia: map['provincia'],
|
||||
address: map['address'],
|
||||
zipCode: map['zip_code'],
|
||||
city: map['city'],
|
||||
province: map['province'],
|
||||
associatedProviders: providers,
|
||||
associatedStaffMembers: staffMembers,
|
||||
);
|
||||
@@ -137,16 +137,16 @@ class StoreModel extends Equatable {
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'nome': nome,
|
||||
'name': name,
|
||||
'company_id': companyId,
|
||||
'is_active': isActive,
|
||||
'is_paid': isPaid,
|
||||
if (paymentExpiration != null)
|
||||
'payment_expiration': paymentExpiration!.toIso8601String(),
|
||||
'indirizzo': indirizzo,
|
||||
'cap': cap,
|
||||
'comune': comune,
|
||||
'provincia': provincia,
|
||||
'address': address,
|
||||
'zip_code': zipCode,
|
||||
'city': city,
|
||||
'province': province,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ class _CreateStoreScreenState extends State<CreateStoreScreen> {
|
||||
final company = context.read<SessionCubit>().state.company;
|
||||
if (company != null) {
|
||||
setState(() {
|
||||
_indirizzoController.text = company.indirizzo;
|
||||
_capController.text = company.cap;
|
||||
_indirizzoController.text = company.address;
|
||||
_capController.text = company.zipCode;
|
||||
_comuneController.text =
|
||||
company.citta; // Nel DB company è 'citta', store è 'comune'
|
||||
_provinciaController.text = company.provincia;
|
||||
company.city; // Nel DB company è 'citta', store è 'comune'
|
||||
_provinciaController.text = company.province;
|
||||
// Suggeriamo anche un nome se vuoto
|
||||
if (_nomeController.text.isEmpty) {
|
||||
_nomeController.text = '${company.ragioneSociale} - Sede';
|
||||
_nomeController.text = '${company.name} - Sede';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -68,12 +68,12 @@ class _CreateStoreScreenState extends State<CreateStoreScreen> {
|
||||
}
|
||||
|
||||
final store = StoreModel(
|
||||
nome: _nomeController.text.trim(),
|
||||
name: _nomeController.text.trim(),
|
||||
companyId: company.id!,
|
||||
indirizzo: _indirizzoController.text.trim(),
|
||||
cap: _capController.text.trim(),
|
||||
comune: _comuneController.text.trim(),
|
||||
provincia: _provinciaController.text.trim().toUpperCase(),
|
||||
address: _indirizzoController.text.trim(),
|
||||
zipCode: _capController.text.trim(),
|
||||
city: _comuneController.text.trim(),
|
||||
province: _provinciaController.text.trim().toUpperCase(),
|
||||
);
|
||||
|
||||
context.read<StoreCubit>().createStore(store);
|
||||
|
||||
@@ -53,11 +53,11 @@ class _StoreCardState extends State<StoreCard> {
|
||||
color: widget.store.isActive ? context.accent : Colors.grey,
|
||||
),
|
||||
title: Text(
|
||||
widget.store.nome,
|
||||
widget.store.name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: Text(
|
||||
"${widget.store.comune} (${widget.store.provincia}) - ${widget.store.indirizzo}",
|
||||
"${widget.store.city} (${widget.store.province}) - ${widget.store.address}",
|
||||
),
|
||||
trailing: Switch(
|
||||
value: widget.store.isActive,
|
||||
@@ -129,7 +129,7 @@ class _StoreCardState extends State<StoreCard> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Personale di ${store.nome}",
|
||||
"Personale di ${store.name}",
|
||||
style: context.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -184,7 +184,7 @@ class _StoreCardState extends State<StoreCard> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text("Providers di ${store.nome}", style: context.titleLarge),
|
||||
Text("Providers di ${store.name}", style: context.titleLarge),
|
||||
const SizedBox(height: 16),
|
||||
...state.allProviders.map((provider) {
|
||||
final isAssociated = _tempAssociatedProviders.any(
|
||||
|
||||
@@ -24,11 +24,11 @@ class _StoreFormState extends State<StoreForm> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.store != null) {
|
||||
nomeController.text = widget.store!.nome;
|
||||
indirizzoController.text = widget.store!.indirizzo;
|
||||
capController.text = widget.store!.cap;
|
||||
comuneController.text = widget.store!.comune;
|
||||
provinciaController.text = widget.store!.provincia;
|
||||
nomeController.text = widget.store!.name;
|
||||
indirizzoController.text = widget.store!.address;
|
||||
capController.text = widget.store!.zipCode;
|
||||
comuneController.text = widget.store!.city;
|
||||
provinciaController.text = widget.store!.province;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,11 +124,11 @@ class _StoreFormState extends State<StoreForm> {
|
||||
id: widget
|
||||
.store
|
||||
?.id, // Se nullo, Supabase ne crea uno nuovo
|
||||
nome: nomeController.text,
|
||||
indirizzo: indirizzoController.text,
|
||||
cap: capController.text,
|
||||
comune: comuneController.text,
|
||||
provincia: provinciaController.text,
|
||||
name: nomeController.text,
|
||||
address: indirizzoController.text,
|
||||
zipCode: capController.text,
|
||||
city: comuneController.text,
|
||||
province: provinciaController.text,
|
||||
companyId: context
|
||||
.read<SessionCubit>()
|
||||
.state
|
||||
|
||||
Reference in New Issue
Block a user