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:
@@ -56,7 +56,7 @@ class StaffCubit extends Cubit<StaffState> {
|
||||
state.staffByStore,
|
||||
);
|
||||
newMap[storeId] = staffInStore;
|
||||
emit(state.copyWith(staffByStore: newMap));
|
||||
emit(state.copyWith(staffByStore: newMap, storeStaff: staffInStore));
|
||||
} catch (e) {
|
||||
emit(state.copyWith(status: StaffStatus.error, error: e.toString()));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class StaffState extends Equatable {
|
||||
final List<StaffMemberModel> allStaff;
|
||||
final Map<String, List<StoreModel>> storesByStaff;
|
||||
final Map<String, List<StaffMemberModel>> staffByStore;
|
||||
final List<StaffMemberModel> storeStaff;
|
||||
final String? error;
|
||||
|
||||
const StaffState({
|
||||
@@ -14,6 +15,7 @@ class StaffState extends Equatable {
|
||||
this.allStaff = const [],
|
||||
this.storesByStaff = const {},
|
||||
this.staffByStore = const {},
|
||||
this.storeStaff = const [],
|
||||
this.error,
|
||||
});
|
||||
|
||||
@@ -22,6 +24,7 @@ class StaffState extends Equatable {
|
||||
List<StaffMemberModel>? allStaff,
|
||||
Map<String, List<StoreModel>>? storesByStaff,
|
||||
Map<String, List<StaffMemberModel>>? staffByStore,
|
||||
List<StaffMemberModel>? storeStaff,
|
||||
String? error,
|
||||
}) {
|
||||
return StaffState(
|
||||
@@ -29,6 +32,7 @@ class StaffState extends Equatable {
|
||||
allStaff: allStaff ?? this.allStaff,
|
||||
storesByStaff: storesByStaff ?? this.storesByStaff,
|
||||
staffByStore: staffByStore ?? this.staffByStore,
|
||||
storeStaff: storeStaff ?? this.storeStaff,
|
||||
error: error,
|
||||
);
|
||||
}
|
||||
@@ -39,6 +43,7 @@ class StaffState extends Equatable {
|
||||
allStaff,
|
||||
storesByStaff,
|
||||
staffByStore,
|
||||
storeStaff,
|
||||
error,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class _StaffScreenState extends State<StaffScreen> {
|
||||
initialValue: _selectedStoreId,
|
||||
decoration: const InputDecoration(labelText: "Filtra per Negozio"),
|
||||
items: state.stores
|
||||
.map((s) => DropdownMenuItem(value: s.id, child: Text(s.nome)))
|
||||
.map((s) => DropdownMenuItem(value: s.id, child: Text(s.name)))
|
||||
.toList(),
|
||||
onChanged: (id) {
|
||||
setState(() => _selectedStoreId = id);
|
||||
@@ -355,7 +355,7 @@ class _StaffScreenState extends State<StaffScreen> {
|
||||
store.id,
|
||||
);
|
||||
return FilterChip(
|
||||
label: Text(store.nome),
|
||||
label: Text(store.name),
|
||||
selected: isSelected,
|
||||
onSelected: (selected) {
|
||||
setModalState(() {
|
||||
|
||||
Reference in New Issue
Block a user