From a9e8c44c17014374e7cd0ac98c9a0a214535c18b Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Tue, 19 Dec 2023 11:29:42 +0530 Subject: [PATCH] Implemented: support to set reset password email while creating facility (#115). --- src/locales/en.json | 1 + src/views/AddFacilityConfig.vue | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index e11db7fc..986657f5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -228,6 +228,7 @@ "Please contact the administrator.": "Please contact the administrator.", "Please enter a valid value": "Please enter a valid value", "Please fill all the required fields": "Please fill all the required fields", + "Please provide a valid email.": "Please provide a valid email.", "Please provide a password.": "Please provide a password.", "Primary": "Primary", "primary store": "primary store", diff --git a/src/views/AddFacilityConfig.vue b/src/views/AddFacilityConfig.vue index 6ad430a0..82e8d1d1 100644 --- a/src/views/AddFacilityConfig.vue +++ b/src/views/AddFacilityConfig.vue @@ -96,6 +96,11 @@ {{ translate('Password should be at least 5 characters long, it contains at least one number, one alphabet and one special character.') }} + + {{ translate('Reset password email') }} * + + @@ -152,7 +157,7 @@ import { starOutline } from 'ionicons/icons'; import { translate } from "@hotwax/dxp-components"; -import { isValidPassword, showToast } from "@/utils"; +import { isValidPassword, isValidEmail, showToast } from "@/utils"; import { hasError } from "@/adapter"; import logger from "@/logger"; import { FacilityService } from "@/services/FacilityService"; @@ -201,6 +206,7 @@ export default defineComponent({ createLoginCreds: false as any, password: '', username: '', + emailAddress: '', selectedProductStores: [] as any, primaryFacilityGroupId: '' // storing productStoreId initially in this, as at this point we don't fetch shopifyShopId } @@ -252,6 +258,7 @@ export default defineComponent({ "facilityName": this.current.facilityName, "username": this.username, "password": this.password, + "emailAddress": this.emailAddress } await FacilityService.createFacilityLogin(payload); @@ -262,15 +269,17 @@ export default defineComponent({ }, async saveStoreConfig() { if (this.createLoginCreds) { - if (!this.username) { - showToast(translate('Username is required.')) + + if (!this.username || !this.password || !this.emailAddress) { + showToast(translate('Please fill all the required fields')) return - } else if (await UserService.isUserLoginIdExists(this.username)) { + } + if (this.username && await UserService.isUserLoginIdExists(this.username)) { showToast(translate('Could not create login user: user with ID already exists.', { userLoginId: this.username })) return; } - if (!this.password) { - showToast(translate('Please provide a password.')) + if (!isValidEmail(this.emailAddress)) { + showToast(translate('Please provide a valid email.')) return } }