fix: changed owner managment

This commit is contained in:
Alzalia 2025-08-08 16:12:47 +02:00
parent f89efc3c52
commit d2cbb43bcb

View file

@ -22,6 +22,7 @@ class _OwnerPopupState extends State<OwnerPopup> {
String? firstName; String? firstName;
String? lastName; String? lastName;
String? contact; String? contact;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
@ -68,17 +69,7 @@ class _OwnerPopupState extends State<OwnerPopup> {
onSelected: (Owner? owner) { onSelected: (Owner? owner) {
widget.viewModel.currentOwner = owner; widget.viewModel.currentOwner = owner;
}, },
), enableSearch: true,
SizedBox(height: 20),
TextButton(
onPressed: () {
setState(() {
showNewOwner = !showNewOwner;
});
},
child: Text(
(showNewOwner) ? "Annuler" : "Ajouter un propriétaire",
),
), ),
(!showNewOwner) (!showNewOwner)
? SizedBox() ? SizedBox()
@ -139,9 +130,25 @@ class _OwnerPopupState extends State<OwnerPopup> {
return null; return null;
}, },
), ),
SizedBox(height: 10), ],
ElevatedButton( ),
),
],
),
),
actions: [
TextButton(
onPressed: () {
setState(() {
showNewOwner = !showNewOwner;
});
},
child: Text((showNewOwner) ? "Annuler" : "Ajouter un propriétaire"),
),
TextButton(
onPressed: () async { onPressed: () async {
if (showNewOwner) {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
_formKey.currentState!.save(); _formKey.currentState!.save();
await widget.viewModel.addOwner( await widget.viewModel.addOwner(
@ -153,20 +160,9 @@ class _OwnerPopupState extends State<OwnerPopup> {
showNewOwner = false; showNewOwner = false;
}); });
} }
}, } else {
child: Text("Créer"),
),
],
),
),
],
),
),
actions: [
TextButton(
onPressed: () {
widget.onPressAccept(context); widget.onPressAccept(context);
}
}, },
child: Text("Valider"), child: Text("Valider"),
), ),