Skip to content

Commit

Permalink
Improved: toast message for creating facility with duplicate facility…
Browse files Browse the repository at this point in the history
…Id (hotwax#185)
  • Loading branch information
amansinghbais committed Jan 29, 2024
1 parent 2bbc4a8 commit 227a26f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/CreateVirtualFacilityModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default defineComponent({
computed: {
...mapGetters({
virtualFacilities: 'facility/getVirtualFacilities',
archivedFacilities: 'facility/getArchivedFacilities',
})
},
data() {
Expand Down Expand Up @@ -130,6 +131,11 @@ export default defineComponent({
this.formData.facilityId = generateInternalId(this.formData.facilityName)
}
if(this.formData.facilityId && this.isFacilityAlreadyExists()) {
showToast(translate('Failed to create parking. Facility with ID already exists.'))
return
}
try {
const payload = {
...this.formData,
Expand Down Expand Up @@ -170,6 +176,9 @@ export default defineComponent({
markFacilityIdTouched() {
(this as any).$refs.facilityId.$el.classList.add('ion-touched');
},
isFacilityAlreadyExists() {
return this.virtualFacilities.some((facility: any) => facility.facilityId === this.formData.facilityId) || this.archivedFacilities.some((facility: any) => facility.facilityId === this.formData.facilityId)
}
},
setup() {
const store = useStore();
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"Failed to create facility.": "Failed to create facility.",
"Failed to create facility login." : "Failed to create facility login.",
"Failed to create parking.": "Failed to create parking.",
"Failed to create parking. Facility with ID already exists.": "Failed to create parking. Facility with ID already exists.",
"Failed to create facility address.": "Failed to create facility address.",
"Failed to create facility group.": "Failed to create facility group.",
"Failed to create facility location": "Failed to create facility location",
Expand Down

0 comments on commit 227a26f

Please sign in to comment.