classification API added

design_3.0_asset_inventory_module
WaseemAbbasi22 4 days ago
parent a763538771
commit 4a283a685c

@ -320,4 +320,6 @@ class URLs {
static get getAssetsTemp => '$_baseUrl/AssetInventory/GetAssetsTemp';
static get convertDetailToComplete => '$_baseUrl/AssetInventory/ConvertDetailToComplete';
static get getClassification => '$_baseUrl/AssetInventory/Classification';
}

@ -108,6 +108,9 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
onChanged: (value) {
isRegistered = value;
resetData();
if (value) {
_scannedAssetModel?.status = 'Not Registered';
}
setState(() {});
},
disabledOpacity: 1,
@ -164,7 +167,7 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
if (value != null) {
_pickedAssetModel = value;
_scannedAssetModel = _scannedAssetModel?.mergeWith(_pickedAssetModel) ?? _pickedAssetModel;
getClassificationData(assetImportId: _pickedAssetModel?.assetImportId);
populateFormValues();
setState(() {});
}
@ -288,9 +291,11 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
siteInfoContainer(label: context.translation.department, value: _scannedAssetModel?.departmentName ?? '-'),
12.height,
siteInfoContainer(label: context.translation.room, value: _scannedAssetModel?.roomName ?? '-'),
],
if (_scannedAssetModel?.status != null && _scannedAssetModel!.status!.isNotEmpty) ...[
12.height,
classificationWidget(label: _scannedAssetModel?.status),
],
if (_scannedAssetModel?.status != null && _scannedAssetModel!.status!.isNotEmpty) classificationWidget(label: _scannedAssetModel?.status),
12.height,
Text(
'Asset Photo'.addTranslation,
@ -463,4 +468,22 @@ class _AssetInventoryFormViewState extends State<AssetInventoryFormView> {
sessionId: (widget.assetInventoryModel?.sessionId ?? 0).toInt(),
);
}
Future<void> getClassificationData({num? assetImportId}) async {
AssetInventoryProvider provider = Provider.of<AssetInventoryProvider>(context, listen: false);
Map<String, dynamic> payload = {
"assetImportId": assetImportId,
"sessionId": widget.assetInventoryModel?.sessionId,
"siteId": widget.assetInventoryModel?.site?.id,
"buildingId": widget.assetInventoryModel?.building?.id,
"floorId": widget.assetInventoryModel?.floor?.id,
"departmentId": widget.assetInventoryModel?.department?.id,
};
await provider.getClassification(payload: payload).then((value) {
if (value != null) {
_scannedAssetModel?.status = value;
}
setState(() {});
});
}
}

@ -284,7 +284,6 @@ class AssetInventoryProvider extends ChangeNotifier {
}) async {
isLoading = true;
try {
log('payload i got is ${model?.toJson()}');
final response = await ApiManager.instance.post(URLs.saveAssetInSession, body: model?.toJson() ?? {});
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
@ -303,6 +302,32 @@ class AssetInventoryProvider extends ChangeNotifier {
}
}
Future<String?> getClassification({
required Map<String, dynamic> payload,
}) async {
isLoading = true;
String? classification;
try {
final response = await ApiManager.instance.post(URLs.getClassification, body: payload);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
log('classifcation on response ${json.decode(response.body)["data"]['classification']}');
classification = json.decode(response.body)["data"]['classification'];
isLoading = false;
notifyListeners();
return classification;
} else {
isLoading = false;
notifyListeners();
return classification;
}
} catch (error) {
isLoading = false;
notifyListeners();
return classification;
}
}
Future<bool> deleteAssetISession({required num id}) async {
try {
isLoading = true;

Loading…
Cancel
Save