From cee72a7a4397b27cfb426b24e2d8907fd3130cbc Mon Sep 17 00:00:00 2001 From: Swetha K Date: Thu, 19 Dec 2024 20:27:02 +0530 Subject: [PATCH] MOSIP-37899: Updated add devices integration Signed-off-by: Swetha K --- pmp-revamp-ui/public/i18n/ara.json | 2 +- pmp-revamp-ui/public/i18n/eng.json | 2 +- pmp-revamp-ui/public/i18n/fra.json | 2 +- .../deviceProviderServices/AddDevices.js | 89 ++----------------- 4 files changed, 8 insertions(+), 87 deletions(-) diff --git a/pmp-revamp-ui/public/i18n/ara.json b/pmp-revamp-ui/public/i18n/ara.json index c199b46b..883906f3 100644 --- a/pmp-revamp-ui/public/i18n/ara.json +++ b/pmp-revamp-ui/public/i18n/ara.json @@ -1146,7 +1146,7 @@ "PMS_DEVICE_ERROR_005": "الهيئة الفرعية للتنفيذ غير موجودة.", "PMS_DEVICE_ERROR_006": "الجهاز غير موجود.", "PMS_DEVICE_ERROR_007": "الجهاز غير مرتبط بمعرف الشريك.", - "PMS_DEVICE_ERROR_008": "حدث خطأ أثناء إضافة تعيين جهاز غير نشط لـ sbi.", + "PMS_DEVICE_ERROR_008": "خطأ أثناء إضافة الجهاز إلى sbi.", "PMS_DEVICE_ERROR_009": "نظرًا لأن SBI إما معطل أو لم تتم الموافقة عليه بعد.", "PMS_DEVICE_ERROR_010": "تفاصيل الجهاز المحددة ليست في انتظار حالة الموافقة.", "PMS_DEVICE_ERROR_011": "حدث خطأ أثناء الموافقة على الجهاز أو رفضه لرسم خرائط Sbi.", diff --git a/pmp-revamp-ui/public/i18n/eng.json b/pmp-revamp-ui/public/i18n/eng.json index 66f91dcd..578ce4eb 100644 --- a/pmp-revamp-ui/public/i18n/eng.json +++ b/pmp-revamp-ui/public/i18n/eng.json @@ -1141,7 +1141,7 @@ "PMS_DEVICE_ERROR_005": "SBI do not exists.", "PMS_DEVICE_ERROR_006": "Device do not exists.", "PMS_DEVICE_ERROR_007": "Device is not associated with partner Id.", - "PMS_DEVICE_ERROR_008": "Error while adding inactive device mapping for sbi.", + "PMS_DEVICE_ERROR_008": "Error while adding device for sbi.", "PMS_DEVICE_ERROR_009": "Given SBI is either deactivated or not approved yet.", "PMS_DEVICE_ERROR_010": "Given device details are not in pending for approval status.", "PMS_DEVICE_ERROR_011": "Error while approving or rejecting device for Sbi Mapping.", diff --git a/pmp-revamp-ui/public/i18n/fra.json b/pmp-revamp-ui/public/i18n/fra.json index c3ccb847..6e832d83 100644 --- a/pmp-revamp-ui/public/i18n/fra.json +++ b/pmp-revamp-ui/public/i18n/fra.json @@ -1146,7 +1146,7 @@ "PMS_DEVICE_ERROR_005": "SBI n'existe pas.", "PMS_DEVICE_ERROR_006": "L'appareil n'existe pas.", "PMS_DEVICE_ERROR_007": "L'appareil n'est pas associé à l'ID du partenaire.", - "PMS_DEVICE_ERROR_008": "Erreur lors de l'ajout du mappage de périphériques inactifs pour sbi.", + "PMS_DEVICE_ERROR_008": "Erreur lors de l'ajout d'un périphérique pour sbi.", "PMS_DEVICE_ERROR_009": "Étant donné que le SBI est soit désactivé, soit pas encore approuvé.", "PMS_DEVICE_ERROR_010": "Les détails de l'appareil donné ne sont pas en attente d'approbation.", "PMS_DEVICE_ERROR_011": "Erreur lors de l'approbation ou du rejet de l'appareil pour Sbi Mapping.", diff --git a/pmp-revamp-ui/src/pages/partner/deviceProviderServices/AddDevices.js b/pmp-revamp-ui/src/pages/partner/deviceProviderServices/AddDevices.js index 140e191b..ba8a1564 100644 --- a/pmp-revamp-ui/src/pages/partner/deviceProviderServices/AddDevices.js +++ b/pmp-revamp-ui/src/pages/partner/deviceProviderServices/AddDevices.js @@ -182,93 +182,13 @@ function AddDevices() { deviceSubTypeCode: entry.deviceSubType, make: trimAndReplace(entry.make), model: trimAndReplace(entry.model) - }); + }, "mosip.pms.add.device.to.sbi.id.post", true); try { - const response = await HttpService.post(getPartnerManagerUrl(`/devicedetail`, process.env.NODE_ENV), request); - - if (response?.data?.response?.id) { - inactiveMappingDeviceToSbi(response.data.response.id, index, false); - } else { - const errorCode = response.data.errors[0].errorCode; - if (errorCode === "PMS_AUT_003") { - const deviceDetails = await searchDeviceDetails(entry, index); - if (deviceDetails && deviceDetails.id) { - inactiveMappingDeviceToSbi(deviceDetails.id, index, true); - } else { - newEntries[index].errorMsg = t('addDevices.errorInAddDevice'); - setDeviceEntries(newEntries); - } - } else { - handleError(response.data, index, newEntries); - } - } - } catch (err) { - newEntries[index].errorMsg = t('addDevices.unableToAddDevice'); - setDeviceEntries(newEntries); - console.error("Error fetching data: ", err); - } - setDataLoaded(true); - setIsSubmitClicked(false); - }; - - const searchDeviceDetails = async(entry, index) => { - const newEntries = [...deviceEntries]; - setDataLoaded(false); - const searchRequest = createRequest({ - filters: [ - {"columnName": "deviceProviderId", "type": "equals", "value": selectedSbidata.partnerId}, - {"columnName": "partnerOrganizationName", "type": "equals", "value": getUserProfile().orgName}, - {"columnName": "deviceTypeCode", "type": "equals", "value": entry.deviceType}, - {"columnName": "deviceSubTypeCode", "type": "equals", "value": entry.deviceSubType}, - {"columnName": "make", "type": "equals", "value": trimAndReplace(entry.make)}, - {"columnName": "model", "type": "equals", "value": trimAndReplace(entry.model)}, - {"columnName": "approvalStatus", "type": "equals", "value": "pending_approval"} - ], - sort: [], - pagination: {pageStart: 0, pageFetch: 100}, - languageCode: "eng", - purpose: "REGISTRATION", - deviceProviderId: selectedSbidata.partnerId - }); - try { - const response = await HttpService.post(getPartnerManagerUrl(`/devicedetail/search`, process.env.NODE_ENV), searchRequest); - if (response?.data?.response) { - const searchDetails = response.data.response.data; - let filteredItem = {}; - if (searchDetails !== null) { - filteredItem = searchDetails.find(item => item.make === entry.make && item.model === entry.model); - } - return filteredItem; - } else { - handleError(response.data, index, newEntries); - } - } catch (err) { - newEntries[index].errorMsg = t('addDevices.unableToAddDevice'); - setDeviceEntries(newEntries); - console.error("Error fetching data: ", err); - } - setDataLoaded(true); - }; - - const inactiveMappingDeviceToSbi = async (deviceDetailId, index, isDeviceAlreadyMapped) => { - const newEntries = [...deviceEntries]; - setDataLoaded(false); - try { - const request = createRequest({ - deviceDetailId: deviceDetailId, - sbiId: selectedSbidata.sbiId, - partnerId: selectedSbidata.partnerId - }, "mosip.pms.add.inactive.mapping.device.to.sbi.id.post", true); - - const response = await HttpService.post(getPartnerManagerUrl(`/devicedetail/inactive-mapping-device-to-sbi`, process.env.NODE_ENV), request, { - headers: { - 'Content-Type': 'application/json' - } - }); + const response = await HttpService.post(getPartnerManagerUrl(`/securebiometricinterface/${selectedSbidata.sbiId}/devices`, process.env.NODE_ENV), request); if (response?.data?.response) { newEntries[index].isSubmitted = true; - newEntries[index].successMsg = isDeviceAlreadyMapped ? t('addDevices.successMsgForExistingDeviceMapping') : t('addDevices.successMsgForNewDeviceMapping'); + newEntries[index].successMsg = t('addDevices.successMsgForNewDeviceMapping'); setDeviceEntries(newEntries); updateButtonStates(); } else { @@ -277,9 +197,10 @@ function AddDevices() { } catch (err) { newEntries[index].errorMsg = t('addDevices.unableToAddDevice'); setDeviceEntries(newEntries); - console.error('Error fetching data:', err); + console.error("Error fetching data: ", err); } setDataLoaded(true); + setIsSubmitClicked(false); }; const handleError = (responseData, index, newEntries) => {