diff --git a/lib/api/api.dart b/lib/api/api.dart index c80521e..7879b26 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -41,6 +41,20 @@ Future loginPost(data) async { return {'statusCode': req.statusCode, 'data': req.data}; } +Future resetPost(data) async { + Response req = await Dio().post( + ('$host/request-reset-password'), + data: data, + options: Options( + contentType: Headers.formUrlEncodedContentType, + validateStatus: (status) { + return status! < 400; + }, + ), + ); + return {'statusCode': req.statusCode, 'data': req.data}; +} + Future getSessions(session) async { var req = await Dio() .post('$host/sessions', queryParameters: {'session_token': session}); diff --git a/lib/components/forgot_pass_body.dart b/lib/components/forgot_pass_body.dart index ad12597..b949e4b 100644 --- a/lib/components/forgot_pass_body.dart +++ b/lib/components/forgot_pass_body.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; +import 'package:nekoya_flutter/api/api.dart'; import 'package:nekoya_flutter/screens/otp.dart'; class ForgotPassBody extends StatefulWidget { @@ -10,6 +11,8 @@ class ForgotPassBody extends StatefulWidget { } class _ForgotPassBodyState extends State { + TextEditingController emailController = TextEditingController(); + @override Widget build(BuildContext context) { return Container( @@ -41,12 +44,16 @@ class _ForgotPassBodyState extends State { ), Container( padding: const EdgeInsets.only(bottom: 20), - child: const TextField( + child: TextField( + controller: emailController, + keyboardType: TextInputType.emailAddress, style: TextStyle(color: Colors.white), decoration: InputDecoration( - border: OutlineInputBorder(), + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.white)), hintText: 'EMAIL', - fillColor: Colors.white), + fillColor: Colors.white, + hintStyle: TextStyle(color: Colors.white)), ), ), ElevatedButton( @@ -60,6 +67,10 @@ class _ForgotPassBodyState extends State { borderRadius: BorderRadius.circular(18.0), side: const BorderSide(color: Colors.red)))), onPressed: () { + Map data = { + "email": emailController.text, + }; + resetPost(data); Navigator.push(context, MaterialPageRoute(builder: (context) => const Otp())); },