creazione nuovo negozio

This commit is contained in:
2026-04-09 16:01:57 +02:00
parent c8c9dbc1f8
commit e6b8c9854e
6 changed files with 78 additions and 51 deletions

View File

@@ -37,7 +37,7 @@ class _CreateStoreScreenState extends State<CreateStoreScreen> {
/// Funzione magica per copiare i dati dall'azienda salvata in GetIt
void _useCompanyAddress() {
final company = _settings.currentCompany;
final company = context.read<SessionBloc>().state.company;
if (company != null) {
setState(() {
_indirizzoController.text = company.indirizzo;
@@ -61,18 +61,18 @@ class _CreateStoreScreenState extends State<CreateStoreScreen> {
void _onSave() {
if (_formKey.currentState!.validate()) {
final settings = GetIt.I<AppSettings>();
final company = context.read<SessionBloc>().state.company;
if (_settings.currentCompany?.id == null) {
if (company == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Errore: ID Azienda non trovato')),
const SnackBar(content: Text('Errore: Azienda non trovata')),
);
return;
}
final store = StoreModel(
nome: _nomeController.text.trim(),
companyId: _settings.currentCompany!.id,
companyId: company.id,
indirizzo: _indirizzoController.text.trim(),
cap: _capController.text.trim(),
comune: _comuneController.text.trim(),