Skip to content

Commit

Permalink
Merge pull request #122 from hotwax/115_facility_logins
Browse files Browse the repository at this point in the history
Implemented: support to set reset password email while creating facility (#115).
  • Loading branch information
ravilodhi authored Dec 19, 2023
2 parents 5e4b439 + a9e8c44 commit 2c66f3a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 15 additions & 6 deletions src/views/AddFacilityConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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.') }}
</ion-note>
</ion-item>
<ion-item>
<ion-label position="floating">{{ translate('Reset password email') }} <ion-text
color="danger">*</ion-text></ion-label>
<ion-input v-model="emailAddress"></ion-input>
</ion-item>
</template>
</template>
</ion-list>
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -252,6 +258,7 @@ export default defineComponent({
"facilityName": this.current.facilityName,
"username": this.username,
"password": this.password,
"emailAddress": this.emailAddress
}
await FacilityService.createFacilityLogin(payload);
Expand All @@ -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
}
}
Expand Down

0 comments on commit 2c66f3a

Please sign in to comment.