From dca97e80e7782d1af07661d0819b5927b929fd53 Mon Sep 17 00:00:00 2001 From: radhika587 Date: Thu, 13 Jan 2022 17:19:27 +0530 Subject: [PATCH] add error message --- .../V1/Admin/Payment/PaymentMethodsController.php | 2 +- resources/scripts/admin/views/modules/View.vue | 14 +++++++++++++- resources/scripts/helpers/error-handling.js | 6 +++++- resources/scripts/locales/en.json | 5 +++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/V1/Admin/Payment/PaymentMethodsController.php b/app/Http/Controllers/V1/Admin/Payment/PaymentMethodsController.php index 8b18f049..53fbcb92 100644 --- a/app/Http/Controllers/V1/Admin/Payment/PaymentMethodsController.php +++ b/app/Http/Controllers/V1/Admin/Payment/PaymentMethodsController.php @@ -89,7 +89,7 @@ class PaymentMethodsController extends Controller } if ($paymentMethod->expenses()->exists()) { - return respondJson('payments_attached', 'Expenses Attached.'); + return respondJson('expenses_attached', 'Expenses Attached.'); } $paymentMethod->delete(); diff --git a/resources/scripts/admin/views/modules/View.vue b/resources/scripts/admin/views/modules/View.vue index e08b6f98..b3af7e4a 100644 --- a/resources/scripts/admin/views/modules/View.vue +++ b/resources/scripts/admin/views/modules/View.vue @@ -861,9 +861,21 @@ async function installModule() { } if (!requestResponse.data.success) { + let displayMsg = ref('') + + if ( + requestResponse.data.message === 'crater_version_is_not_supported' + ) { + displayMsg.value = t('modules.version_not_supported', { + version: requestResponse.data.min_crater_version, + }) + } else { + displayMsg.value = getErrorMessage(requestResponse.data.message) + } + notificationStore.showNotification({ type: 'error', - message: getErrorMessage(requestResponse.data.message), + message: displayMsg.value, }) isInstalling.value = false diff --git a/resources/scripts/helpers/error-handling.js b/resources/scripts/helpers/error-handling.js index fb7193f8..b7e01bcc 100644 --- a/resources/scripts/helpers/error-handling.js +++ b/resources/scripts/helpers/error-handling.js @@ -62,7 +62,11 @@ export const showError = (error) => { break case 'payments_attached': - showToaster('settings.payment_modes.already_in_use') + showToaster('settings.payment_modes.payments_attached') + break + + case 'expenses_attached': + showToaster('settings.payment_modes.expenses_attached') break case 'role_attached_to_users': diff --git a/resources/scripts/locales/en.json b/resources/scripts/locales/en.json index f16b6cf2..4ef1bdef 100644 --- a/resources/scripts/locales/en.json +++ b/resources/scripts/locales/en.json @@ -686,7 +686,7 @@ "no_reviews_found": "There are no reviews for this module yet!", "module_not_purchased": "Module Not Purchased", "module_not_found": "Module Not Found", - "version_not_supported": "This module version doesn't support the current version of Crater", + "version_not_supported": "The minimum required version for this module does not match. Please upgrade your crater app to version: {version} to proceed.", "last_updated": "Last Updated On", "connect_installation": "Connect your installation", "api_token_description": "Login to {url} and connect this installation by entering the API Token. Your purchased modules will show up here after the connection is established.", @@ -1146,7 +1146,8 @@ "payment_mode_added": "Payment Mode Added", "payment_mode_updated": "Payment Mode Updated", "payment_mode_confirm_delete": "You will not be able to recover this Payment Mode", - "already_in_use": "Payment Mode is already in use", + "payments_attached": "This payment method is already attached to payments. Please delete the attached payments to proceed with deletion.", + "expenses_attached": "This payment method is already attached to expenses. Please delete the attached expenses to proceed with deletion.", "deleted_message": "Payment Mode deleted successfully" }, "expense_category": {