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

@@ -11,27 +11,41 @@ enum SessionStatus {
class SessionState extends Equatable {
final SessionStatus status;
final String? userId;
final String? companyId;
final CompanyModel? company;
final StoreModel? selectedStore;
final List<StoreModel> availableStores; // Utile per uno switcher in futuro
const SessionState._({
const SessionState({
this.status = SessionStatus.unknown,
this.userId,
this.companyId,
this.company,
this.selectedStore,
this.availableStores = const [],
});
const SessionState.unknown() : this._();
const SessionState.unauthenticated()
: this._(status: SessionStatus.unauthenticated);
const SessionState.authenticatedNoCompany(String userId)
: this._(status: SessionStatus.authenticatedNoCompany, userId: userId);
const SessionState.authenticatedNoStore(String userId, String companyId)
: this._(
status: SessionStatus.authenticatedNoStore,
userId: userId,
companyId: companyId,
);
const SessionState.ready(String userId)
: this._(status: SessionStatus.ready, userId: userId);
@override
List<Object?> get props => [status, userId];
List<Object?> get props => [
status,
userId,
company,
selectedStore,
availableStores,
];
// copyWith per aggiornare solo un pezzo (es. quando cambi negozio)
SessionState copyWith({
SessionStatus? status,
String? userId,
CompanyModel? company,
StoreModel? selectedStore,
List<StoreModel>? availableStores,
}) {
return SessionState(
status: status ?? this.status,
userId: userId ?? this.userId,
company: company ?? this.company,
selectedStore: selectedStore ?? this.selectedStore,
availableStores: availableStores ?? this.availableStores,
);
}
}