reworked operation (#12)
Reviewed-on: #12 Co-authored-by: Mark M2 Macbook <marco@catelli.it> Co-committed-by: Mark M2 Macbook <marco@catelli.it>
This commit is contained in:
@@ -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,14 +184,14 @@ 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(
|
||||
(p) => p.id == provider.id,
|
||||
);
|
||||
return CheckboxListTile(
|
||||
title: Text(provider.nome),
|
||||
title: Text(provider.name),
|
||||
value: isAssociated,
|
||||
onChanged: (selected) {
|
||||
if (selected == true) {
|
||||
|
||||
@@ -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