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

Added a test to make sure updated numbers do not match existing ones #53

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/screens/ArtisanHub/AddArtisan.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ export default class AddArtisan extends Component {
validFields = this.displayErrorMessage("Only alphabetic characters allowed for name.")
}
}

if (this.state.phoneNumber) {
//console.log("Artisans ======> " + JSON.stringify(this.props.Artisans))
//console.log("Tried entering phone nuber: " + this.state.phoneNumber)

let phoneMatch = this.props.Artisans.some((artisan) => {
//console.log(JSON.stringify(artisan))
return artisan.phoneNumber == this.state.phoneNumber
})

if (phoneMatch) {
console.log("Found matching number!");
validFields = this.displayErrorMessage("Phone field cant be used already")
}
}

if (!this.state.phoneNumber)
validFields = this.displayErrorMessage("Phone field required")
Expand Down
15 changes: 15 additions & 0 deletions src/screens/ArtisanHub/EditArtisan.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ class EditArtisan extends Component {
validFields = this.displayErrorMessage("Only alphabetic characters allowed for name.")
}
}

if (this.state.phoneNumber) {
//console.log("Artisans ======> " + JSON.stringify(this.props.Artisans))
//console.log("Tried entering phone nuber: " + this.state.phoneNumber)

let phoneMatch = this.props.Artisans.some((artisan) => {
//console.log(JSON.stringify(artisan))
return artisan.phoneNumber == this.state.phoneNumber
})

if (phoneMatch) {
console.log("Found matching number!");
validFields = this.displayErrorMessage("Phone field cant be used already")
}
}

if (!this.state.phoneNumber)
validFields = this.displayErrorMessage("Phone field required")
Expand Down