Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: toast message for creating facility with duplicate facility id (#185) #186

Closed

Conversation

amansinghbais
Copy link
Contributor

Related Issues

Closes #185

Short Description and Why It's Useful

Improved the create parking workflow to show clear error message while creating parking with duplicate facility ID.

Screenshots of Visual Changes before/after (If There Are Any)

Contribution and Currently Important Rules Acceptance

@@ -130,6 +131,11 @@ export default defineComponent({
this.formData.facilityId = generateInternalId(this.formData.facilityName)
}

if(this.formData.facilityId && this.isFacilityAlreadyExists()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check is not required, as flow of code will not come here without having a facilityId.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only check for facilityId in facilities those are displayed on the UI as we fetch facilities in batches, and will not check across all the facilities available.

@@ -170,6 +176,29 @@ export default defineComponent({
markFacilityIdTouched() {
(this as any).$refs.facilityId.$el.classList.add('ion-touched');
},
async isFacilityAlreadyExists() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should return a boolean instead of returning a number.

logger.error(err)
}

return facilitiesCount > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead we should define a variable isFacilityExist and toggle its value based on the api response.

@amansinghbais
Copy link
Contributor Author

Based on discussion, we have concluded to show server side error messages in case of api failure due to duplicate facilityId.

Hence closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Create Parking workflow to show clear error message while creating parking with duplicate facility ID.
2 participants