Fakultas Ilmu Komputer UI

Commit bf4cca8e authored by Usman Sidiq's avatar Usman Sidiq
Browse files

[GREEN] Add working implementation of registrasi

parent 44d1a8f5
Pipeline #41810 failed with stages
in 50 minutes and 54 seconds
......@@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/utils/customButton.dart';
import 'package:ppl_disabilitas/utils/customTextField.dart';
//import 'package:ppl_disabilitas/network/network_interface.dart';
import 'package:ppl_disabilitas/model/user.dart';
//import 'package:ppl_disabilitas/network/network_interface.dart';g
import 'package:ppl_disabilitas/utils/validator.dart';
import 'package:http/http.dart' as http;
......@@ -137,13 +136,8 @@ class RegistrasiState extends State<Registrasi> {
final FormState form = _formKey.currentState;
if (_formKey.currentState.validate()) {
form.save();
User user = User(
username: nameController.text.toString(),
phonenumber: phoneController.text.toString(),
email: emailController.text.toString(),
password: passwordController.text.toString()
);
await createUser(user);
await createUser(nameController.text.toString(), phoneController.text.toString(),
emailController.text.toString(), passwordController.text.toString());
}
}
......@@ -152,11 +146,32 @@ class RegistrasiState extends State<Registrasi> {
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
// static Future<bool> register(User data) async {
createUser(String name, String phone_number, String email, String password) async {
Map data = {
'name' : name,
'phone_number' : phone_number,
'email' : email,
'password' : password,
};
final response = await http.post(
"http://poipole-staging.herokuapp.com/api/register/",
// headers: {"Content-Type": "application/json"},
body: data,
);
if (response.statusCode == 200) {
// await Navigator.pushNamed(context, '/');
return true;
} else {
return false;
}
}
// Future<bool> register(User data) async {
// final response = await http.post(
// 'https://my.api.mockaroo.com/register.json?key=095ee610&__method=POST',
// 'https://10.0.2.2:8000/api/registrasi/',
// body: data);
// if (response.statusCode == 200) {
// if (response.statusCode == 201) {
// print(response.body);
// return true;
// }
// else {
......@@ -170,15 +185,3 @@ class RegistrasiState extends State<Registrasi> {
// );
}
Future<bool> createUser(User data) async {
final response = await http.post(
"https://my.api.mockaroo.com/register.json?key=095ee610&__method=POST",
headers: {"content-type": "application/json"},
body: userToJson(data),
);
if (response.statusCode == 200) {
return true;
} else {
return false;
}
}
Supports Markdown
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