Fakultas Ilmu Komputer UI

Commit 9b5301da authored by Muhammad Farhan Ghaffar's avatar Muhammad Farhan Ghaffar
Browse files

feat: adding code for post foto and fixing checkpoint button

parent fc700584
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.1\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-06-27 19:38:57.585871","version":"2.1.0-12.1.pre"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.1\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"D:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-06-27 22:11:01.512574","version":"2.1.0-12.1.pre"}
\ No newline at end of file
......@@ -3,7 +3,8 @@ import 'dart:io';
import 'package:fundex_app/pages/business/EquityOfferings.dart';
import 'package:fundex_app/storage/storage.dart';
import 'package:http/http.dart' show Client;
// import 'package:http/http.dart' as http;
import 'package:http/http.dart' as http;
import 'package:image_picker/image_picker.dart';
class Api {
Client client = Client();
......@@ -1202,29 +1203,157 @@ class Api {
}
}
// Future postFotoMemberDoc(String val, String name) async {
// var apiURL =
// Uri.parse('https://canary.fundex.id/api/v1.1/member-document?document_type_id=document_type_id&is_public=true');
// var req = http.MultipartRequest('POST', apiURL);
// var token = await secureStorage.readSecureData('accessToken');
// req.files.add(
// http.MultipartFile(
// 'picture',
// File(val).readAsBytes().asStream(),
// File(val).lengthSync(),
// filename: val.split("/").last
// )
// );
// var response = await req.send();
// if(response.statusCode == 200) {
// var jsonObject = json.decode(req.body);
// var data = (jsonObject as Map<String, dynamic>)['data'];
// var id = data['id'];
// await secureStorage.writeSecureData('id_domicileAddressId', id.toString());
// await secureStorage.writeSecureData(name, id.toString());
// print('Uploaded!');
// }
// }
Future postFotoMemberDoc(PickedFile file, String name) async {
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-document?document_type_id=4&is_public=true');
var req = http.MultipartRequest('POST', apiURL);
var token = await secureStorage.readSecureData('accessToken');
Map<String, String> headers = {
"Authorization": "Bearer $token"
};
var filenya = File(file.path);
req.files.add(
http.MultipartFile(
'file',
filenya.readAsBytes().asStream(),
filenya.lengthSync(),
filename: filenya.path.split("/").last
)
);
req.headers.addAll(headers);
var streamedResponse = await req.send();
var response = await http.Response.fromStream(streamedResponse);
if (response.statusCode == 200) {
print("Uploaded!! ");
var jsonObject = json.decode(response.body);
var data = (jsonObject as Map<String, dynamic>)['data'];
var memDoc = (data as Map<String, dynamic>)['member_document'];
var id = memDoc['id'];
await secureStorage.writeSecureData(name, id.toString());
print(await secureStorage.readSecureData(name));
} else {
print(response.reasonPhrase);
print(response.request);
print(response.body);
throw Exception('Get Failed');
}
}
// ignore: non_constant_identifier_names
Future identity_doc_id() async {
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'attribute_name': 'identity_doc_id', 'attribute_value': await secureStorage.readSecureData('id_DOCidentitydocid')}));
if (apiResult.statusCode == 200) {
var jsonObject = json.decode(apiResult.body);
var data = (jsonObject as Map<String, dynamic>)['data'];
var id = data['id'];
await secureStorage.writeSecureData('id_ATTRidentitydocid', id.toString());
print('identity_doc_id berhasil');
print(apiResult.statusCode);
print(apiResult.body);
} else {
print('domicile address ' + apiResult.statusCode.toString());
print(apiResult.reasonPhrase);
print(apiResult.request);
print(apiResult.body);
throw Exception('Gagal menyimpan gender');
}
}
// ignore: non_constant_identifier_names
Future npwp_doc_id() async {
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'attribute_name': 'identity_doc_id', 'attribute_value': await secureStorage.readSecureData('id_DOCnpwpdocid')}));
if (apiResult.statusCode == 200) {
var jsonObject = json.decode(apiResult.body);
var data = (jsonObject as Map<String, dynamic>)['data'];
var id = data['id'];
await secureStorage.writeSecureData('id_ATTRnpwpdocid', id.toString());
print('npwp_doc_id berhasil');
print(apiResult.statusCode);
print(apiResult.body);
} else {
print('domicile address ' + apiResult.statusCode.toString());
print(apiResult.reasonPhrase);
print(apiResult.request);
print(apiResult.body);
throw Exception('Gagal menyimpan gender');
}
}
// ignore: non_constant_identifier_names
Future selfie_additional_doc_id() async {
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'attribute_name': 'identity_doc_id', 'attribute_value': await secureStorage.readSecureData('id_DOCselfieadditionaldocid')}));
if (apiResult.statusCode == 200) {
var jsonObject = json.decode(apiResult.body);
var data = (jsonObject as Map<String, dynamic>)['data'];
var id = data['id'];
await secureStorage.writeSecureData('id_ATTRselfieadditionaldocid', id.toString());
print('selfie_additional_doc_id berhasil');
print(apiResult.statusCode);
print(apiResult.body);
} else {
print('domicile address ' + apiResult.statusCode.toString());
print(apiResult.reasonPhrase);
print(apiResult.request);
print(apiResult.body);
throw Exception('Gagal menyimpan gender');
}
}
// ignore: non_constant_identifier_names
Future selfie_photo_doc_id() async {
var apiURL =
Uri.parse('https://canary.fundex.id/api/v1.1/member-attribute');
var token = await secureStorage.readSecureData('accessToken');
final apiResult = await client.post(apiURL,
headers: <String, String>{
'Content-type': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $token',
},
body: jsonEncode(
{'attribute_name': 'identity_doc_id', 'attribute_value': await secureStorage.readSecureData('id_DOCselfiephotodocid')}));
if (apiResult.statusCode == 200) {
var jsonObject = json.decode(apiResult.body);
var data = (jsonObject as Map<String, dynamic>)['data'];
var id = data['id'];
await secureStorage.writeSecureData('id_ATTRselfiephotodocid', id.toString());
print('selfie_additional_doc_id berhasil');
print(apiResult.statusCode);
print(apiResult.body);
} else {
print('domicile address ' + apiResult.statusCode.toString());
print(apiResult.reasonPhrase);
print(apiResult.request);
print(apiResult.body);
throw Exception('Gagal menyimpan gender');
}
}
Future getFotoMemberDoc(int id) async {
var apiURL =
......
......@@ -591,15 +591,20 @@ class _DataPendukungState extends State<DataPendukung> {
Container(
key: Key('container garis bulat checkpoint'),
child: Row(children: <Widget>[
CheckpointBiodata,
valStep1 == 'true' ?
CheckpointBiodata : buletanCheckpoint,
garisCheckpoint,
CheckpointAlamat,
valStep2 == 'true' ?
CheckpointAlamat : buletanCheckpoint,
garisCheckpoint,
CheckpointBiodataKeluarga,
valStep3 == 'true' ?
CheckpointBiodataKeluarga : buletanCheckpoint,
garisCheckpoint,
CheckpointDataIdentitas,
valStep4 == 'true' ?
CheckpointDataIdentitas : buletanCheckpoint,
garisCheckpoint,
buletanChecklistCheckpoint
valStep5 == 'true' ?
buletanChecklistCheckpoint : buletanCheckpoint
])),
//container text-nya
......@@ -1263,7 +1268,7 @@ class _DataPendukungState extends State<DataPendukung> {
// ignore: non_constant_identifier_names
Widget get CheckpointDataIdentitas {
return valStep5 == "false" ?
return valStep5 == "true" ?
Container(
height: 24,
width: 24,
......
......@@ -11,6 +11,7 @@ import 'package:fundex_app/pages/kyc/biodata_keluarga_body.dart';
import 'package:fundex_app/pages/kyc/biodata_pendukung.dart';
import 'package:fundex_app/pages/kyc/design.dart';
import 'package:image_picker/image_picker.dart';
import 'package:fundex_app/storage/storage.dart';
class DataIdentitas extends StatefulWidget {
@override
......@@ -294,15 +295,20 @@ class _DataIdentitasState extends State<DataIdentitas> {
Container(
key: Key('container garis bulat checkpoint'),
child: Row(children: <Widget>[
CheckpointBiodata,
valStep1 == 'true' ?
CheckpointBiodata : buletanCheckpoint,
garisCheckpoint,
CheckpointAlamat,
valStep2 == 'true' ?
CheckpointAlamat : buletanCheckpoint,
garisCheckpoint,
CheckpointBiodataKeluarga,
valStep3 == 'true' ?
CheckpointBiodataKeluarga : buletanCheckpoint,
garisCheckpoint,
buletanChecklistCheckpoint,
valStep4 == 'true' ?
buletanChecklistCheckpoint : buletanCheckpoint,
garisCheckpoint,
CheckpointDataPendukung
valStep5 == 'true' ?
CheckpointDataPendukung : buletanCheckpoint
])),
//container text-nya
......@@ -642,42 +648,56 @@ class _DataIdentitasState extends State<DataIdentitas> {
primary: primary,
onPrimary: secondary,
),
onPressed: () {
onPressed: () async {
if (!_formkey.currentState
.validate()) {
print("Failed");
return;
}
// if (_imageFileKTP == null
// || _imageFileNPWP == null
// || _imageFileFotoSelfie == null
// || _imageFileFotoSelfieDenganKTP == null) {
// validateImageKTP(_imageFileKTP);
// validateImageNPWP(_imageFileNPWP);
// validateImageFotoSelfie(_imageFileFotoSelfie);
// validateImageFotoSelfieKTP(_imageFileFotoSelfieDenganKTP);
// print("Failed2");
// return;
// }
String fileNameKTP = _imageFileKTP.path.split('/').last;
String fileNameNPWP = _imageFileNPWP.path.split('/').last;
String fileNameFotoSelfie = _imageFileFotoSelfie.path.split('/').last;
String fileNameFotoSelfieDenganKTP = _imageFileFotoSelfieDenganKTP.path.split('/').last;
print(fileNameKTP);
print(fileNameNPWP);
print(fileNameFotoSelfie);
print(fileNameFotoSelfieDenganKTP);
// print('yu'+_imageFileKTP);
print('ya'+_imageFileKTP.path);
print(File(_imageFileKTP.path));
print(File(_imageFileKTP.path).path.split('/').last);
print(File(_imageFileKTP.path).readAsBytes().asStream());
print(File(_imageFileKTP.path).length());
print(File(_imageFileKTP.path).lengthSync());
// String fileNameKTP = _imageFileKTP.path.split('/').last;
// String fileNameNPWP = _imageFileNPWP.path.split('/').last;
// String fileNameFotoSelfie = _imageFileFotoSelfie.path.split('/').last;
// String fileNameFotoSelfieDenganKTP = _imageFileFotoSelfieDenganKTP.path.split('/').last;
// print(fileNameKTP);
// print(fileNameNPWP);
// print(fileNameFotoSelfie);
// print(fileNameFotoSelfieDenganKTP);
if (alreadyFilledSection == true) {
Api().putMemberAttribute(getIdNoKTP,
'identity_number', _noKTP);
Api().putMemberAttribute(getIdNoNPWP,
'npwp_number', _noPWP);
Api().postFotoMemberDoc(_imageFileKTP, 'id_DOCidentitydocid');
Api().putMemberAttribute(getIdFotoKTPMemberAttr,
'identity_doc_id', await SecureStorage().readSecureData('id_DOCidentitydocid'));
Api().postFotoMemberDoc(_imageFileKTP, 'id_DOCidentitydocid');
Api().putMemberAttribute(getIdFotoNPWPMemberAttr,
'npwp_doc_id', await SecureStorage().readSecureData('id_DOCnpwpdocid'));
Api().postFotoMemberDoc(_imageFileKTP, 'id_DOCidentitydocid');
Api().putMemberAttribute(getIdFotoSelfieMemberAttr,
'selfie_photo_doc_id', await SecureStorage().readSecureData('id_DOCselfiephotodocid'));
Api().postFotoMemberDoc(_imageFileKTP, 'id_DOCidentitydocid');
Api().putMemberAttribute(getIdFotoSelfieKtpMemberAttr,
'selfie_additional_doc_id', await SecureStorage().readSecureData('id_DOCselfieadditionaldocid'));
} else {
Api().identity_number(_noKTP);
Api().npwp_number(_noPWP);
Api().postFotoMemberDoc(_imageFileKTP, 'id_DOCidentitydocid');
Api().identity_doc_id();
Api().postFotoMemberDoc(_imageFileNPWP, 'id_DOCnpwpdocid');
Api().npwp_doc_id();
Api().postFotoMemberDoc(_imageFileFotoSelfie, 'id_DOCselfiephotodocid');
Api().selfie_additional_doc_id();
Api().postFotoMemberDoc(_imageFileFotoSelfieDenganKTP, 'id_DOCselfieadditionaldocid');
Api().selfie_photo_doc_id();
Api().kyc_progress(
true, true, true, true, false);
}
......
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