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

View File

@ -81,10 +81,41 @@ class _PropertyOwnerInfoEditOffline
Container(
margin: const EdgeInsets.only(
left: 0, top: 20, right: 0, bottom: 10),
child: const Text('PROPERTY OWNER INFO',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.left),
child: Row(
children: [
Expanded(
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),
customDropDownField(

View File

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