fix(registration) Finished fixing registration after code refactoring

This commit is contained in:
2024-03-14 16:24:33 +03:00
parent e4637d54e8
commit 4a5fa3dd5c
4 changed files with 19 additions and 14 deletions

View File

@@ -76,19 +76,24 @@ class AdditionalInformationScreen extends StatelessWidget {
UserRegistrationSheet sheet =
state.additionalInformationModelObj!.userRegistrationSheet;
sheet.additionalInfo = state.editTextController!.text;
//print(json.encode(sheet.toJson()));
final response = await http.post(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'),
headers: {'Content-Type': 'application/json'},
body: json.encode(sheet),
);
var res = await jsonDecode(response.body);
final box = await Hive.openBox('token');
final token = res['token'];
box.put('token', token);
Navigator.pushNamed(
context,
AppRoutes.myProfile,
body: jsonEncode(sheet.toJson()),
);
print(response.statusCode);
print(response.body);
if (response.statusCode == 200) {
var res = await jsonDecode(response.body);
final box = await Hive.openBox('token');
final token = res['token'];
box.put('token', token);
Navigator.pushNamed(
context,
AppRoutes.myProfile,
);
}
};
}