Commit 26b9540e authored by Ilham Maulana's avatar Ilham Maulana 💻

fix: adding validator to loan book form

parent bc0e46c6
......@@ -47,6 +47,15 @@ class _LoanBookForm extends State<LoanBookForm> {
),
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
validator: (String? value) {
if (value == null || value.isEmpty) {
return "Loan day cannot be empty";
} else if (value is int) {
return "Please enter loan day in number";
} else {
return null;
}
},
),
),
actions: [
......@@ -58,11 +67,14 @@ class _LoanBookForm extends State<LoanBookForm> {
),
FilledButton(
onPressed: () {
authProvider.createMemberLoan(
if (_formKey.currentState!.validate()) {}
authProvider
.createMemberLoan(
authProvider.user!.accountId,
widget.bookId,
int.parse(loanDayController.text),
);
)
.then((_) => Navigator.of(context).pop());
},
child: const Text('Submit'),
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment