Additional changes

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
cyzoox 2024-07-25 10:48:59 +08:00
parent 9f0cc75a3f
commit eeb83380bd
3 changed files with 76 additions and 43 deletions

View File

@ -309,7 +309,7 @@ class CrudBloc extends Bloc<CrudEvent, CrudState> {
genCode: "5TH"); genCode: "5TH");
Response addResponse = await post( Response addResponse = await post(
Uri.parse( Uri.parse(
'http://${Url.instance.host()}/api/rptass_app/additional_items/'), 'https://${Url.instance.host()}/api/rptass_app/additional_items/'),
headers: headers, headers: headers,
body: jsonEncode(addItems)); body: jsonEncode(addItems));
print(addResponse.body); print(addResponse.body);
@ -350,7 +350,7 @@ class CrudBloc extends Bloc<CrudEvent, CrudState> {
buccPercentage: structure.buccPercentage); buccPercentage: structure.buccPercentage);
Response response = await post( Response response = await post(
Uri.parse( Uri.parse(
'http://${Url.instance.host()}/api/rptass_app/bldgappr_structure/'), 'https://${Url.instance.host()}/api/rptass_app/bldgappr_structure/'),
headers: headers, headers: headers,
body: jsonEncode(bldgStruc)); body: jsonEncode(bldgStruc));
print(response.body); print(response.body);
@ -368,7 +368,7 @@ class CrudBloc extends Bloc<CrudEvent, CrudState> {
return await post( return await post(
Uri.parse( Uri.parse(
'http://${Url.instance.host()}/api/rptass_app/bldgappr_details/'), 'https://${Url.instance.host()}/api/rptass_app/bldgappr_details/'),
headers: headers, headers: headers,
body: jsonEncode(details)); body: jsonEncode(details));
} }
@ -389,7 +389,7 @@ class CrudBloc extends Bloc<CrudEvent, CrudState> {
var request = MultipartRequest( var request = MultipartRequest(
'POST', 'POST',
Uri.parse( Uri.parse(
'http://${Url.instance.host()}/api/rptass_app/bldgappr_sketch/'), 'https://${Url.instance.host()}/api/rptass_app/bldgappr_sketch/'),
); );
// Add the headers to the request // Add the headers to the request
@ -454,46 +454,48 @@ class CrudBloc extends Bloc<CrudEvent, CrudState> {
await SQLServices.instance.readAllBldgOwner(); await SQLServices.instance.readAllBldgOwner();
for (PropertyInfo infos in propertyOwner) { for (PropertyInfo infos in propertyOwner) {
final details = await _prepareBuildingDetails(event, infos); if (infos.dateSynced == null) {
final details = await _prepareBuildingDetails(event, infos);
Response detailsResponse = await _postBuildingDetails(details); Response detailsResponse = await _postBuildingDetails(details);
final datas = json.decode(detailsResponse.body); final datas = json.decode(detailsResponse.body);
print(datas); print(datas);
await _postAdditionalItems(datas, infos); await _postAdditionalItems(datas, infos);
await _postBuildingStructures(datas, infos); await _postBuildingStructures(datas, infos);
await _uploadImage(datas, infos); await _uploadImage(datas, infos);
if (detailsResponse.statusCode == 201) { if (detailsResponse.statusCode == 201) {
final detailsInfo = PropertyInfo( final detailsInfo = PropertyInfo(
id: infos.id, id: infos.id,
transCode: infos.transCode, transCode: infos.transCode,
assessedById: infos.assessedById, assessedById: infos.assessedById,
assessedByName: infos.assessedByName, assessedByName: infos.assessedByName,
tdn: infos.tdn, tdn: infos.tdn,
pin: infos.pin, pin: infos.pin,
fname: infos.fname, fname: infos.fname,
mname: infos.mname, mname: infos.mname,
bday: infos.bday, bday: infos.bday,
lname: infos.lname, lname: infos.lname,
address: infos.address, address: infos.address,
telno: infos.telno, telno: infos.telno,
tin: infos.tin, tin: infos.tin,
adminUser: infos.adminUser, adminUser: infos.adminUser,
adminAddress: infos.adminAddress, adminAddress: infos.adminAddress,
adminTin: infos.adminTin, adminTin: infos.adminTin,
adminTelno: infos.adminTelno, adminTelno: infos.adminTelno,
faasType: "Building", faasType: "Building",
dateSynced: dateSynced:
DateFormat('MM/dd/yyyy hh:mm a').format(DateTime.now())); DateFormat('MM/dd/yyyy hh:mm a').format(DateTime.now()));
await SQLServices.instance.updateBldgOwner(infos.id, detailsInfo); await SQLServices.instance.updateBldgOwner(infos.id, detailsInfo);
}
} }
}
propertyOwner = await SQLServices.instance.readAllBldgOwner(); propertyOwner = await SQLServices.instance.readAllBldgOwner();
emit(PropertyInfoLoaded(propertyInfos: propertyOwner)); emit(PropertyInfoLoaded(propertyInfos: propertyOwner));
}
} catch (e) { } catch (e) {
print(e.toString()); print(e.toString());
emit(PropertyOwnerInfoErrorState(errorMessage: e.toString())); emit(PropertyOwnerInfoErrorState(errorMessage: e.toString()));

View File

@ -81,10 +81,41 @@ class _PropertyOwnerInfoEditOffline
Container( Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10), left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY OWNER INFO', child: Row(
style: TextStyle( children: [
fontWeight: FontWeight.bold, fontSize: 18), Expanded(
textAlign: TextAlign.left), child: const Text(
'PROPERTY OWNER INFO',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.center,
),
),
],
),
),
Align(
alignment: Alignment.topRight,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
),
onPressed: () {},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('SAVE'), // <-- Text
SizedBox(
width: 5,
),
Icon(
// <-- Icon
Icons.save,
size: 24.0,
),
],
),
),
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
customDropDownField( customDropDownField(

View File

@ -5,7 +5,7 @@ class Url {
String host() { String host() {
// // // return '192.168.10.183:3000'; // // // return '192.168.10.183:3000';
// return 'agusandelnorte.gov.ph'; return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000"; // return "192.168.10.219:3000";
// return "192.168.10.241"; // return "192.168.10.241";
// return "192.168.10.185"; // return "192.168.10.185";
@ -16,7 +16,7 @@ class Url {
// return "192.168.10.247"; // return "192.168.10.247";
// return "playcensys.agusandelnorte.gov.ph"; // return "playcensys.agusandelnorte.gov.ph";
// return "10.10.10.110:8000"; // return "10.10.10.110:8000";
return "192.168.80.20:8000"; // return "192.168.80.20:8000";
} }
String prefixHost() { String prefixHost() {