diff --git a/src/components/CreateVirtualFacilityModal.vue b/src/components/CreateVirtualFacilityModal.vue index a278713c..045f47c1 100644 --- a/src/components/CreateVirtualFacilityModal.vue +++ b/src/components/CreateVirtualFacilityModal.vue @@ -95,6 +95,7 @@ export default defineComponent({ computed: { ...mapGetters({ virtualFacilities: 'facility/getVirtualFacilities', + archivedFacilities: 'facility/getArchivedFacilities', }) }, data() { @@ -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, @@ -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(); diff --git a/src/locales/en.json b/src/locales/en.json index 87822266..608d5d38 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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",