-
Notifications
You must be signed in to change notification settings - Fork 77
Enhance/select email for customer without name #177
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
Open
dev-shahed
wants to merge
4
commits into
develop
Choose a base branch
from
enhance/select-email-for-customer-without-name
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a1bd31
enhance(customer): fallback to email in input when name is missing
dev-shahed 65f5c8a
refactor(customer): simplify customer display name/email logic in sea…
dev-shahed 2ceed22
fix(customer): correct customer display name retrieval in orderdata h…
dev-shahed c5a75a9
enhance(customer): add success alert after customer creation
dev-shahed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,7 +226,7 @@ export default { | |
| }, | ||
|
|
||
| 'orderdata.customer_id'(newVal) { | ||
| this.serachInput = newVal ? this.orderdata.billing.first_name + ' ' + this.orderdata.billing.last_name : ''; | ||
| this.serachInput = newVal ? this.getCustomerDisplayName(this.orderdata.billing.first_name, this.orderdata.billing.last_name, this.orderdata.billing.email) : ''; | ||
| } | ||
|
|
||
| }, | ||
|
|
@@ -287,9 +287,14 @@ export default { | |
| this.$emit( 'onCustomerSelected', {} ); | ||
| } | ||
| }, | ||
| getCustomerDisplayName(first_name, last_name, email) { | ||
| return (first_name?.trim() || last_name?.trim()) | ||
| ? `${(first_name || '').trim()} ${(last_name || '').trim()}`.trim() | ||
| : (email || ''); | ||
| }, | ||
| selectCustomer( customer ) { | ||
| this.$emit( 'onCustomerSelected', customer ); | ||
| this.serachInput = customer.first_name + ' ' + customer.last_name; | ||
| this.serachInput = this.getCustomerDisplayName(customer.first_name, customer.last_name, customer.email); | ||
| this.showCustomerResults = false; | ||
| }, | ||
| createCustomer() { | ||
|
|
@@ -318,10 +323,11 @@ export default { | |
|
|
||
| wepos.api.post( wepos.rest.root + wepos.rest.posversion + '/customers', customerData ) | ||
| .done(response => { | ||
| this.serachInput = response.first_name + ' ' + response.last_name; | ||
| this.serachInput = this.getCustomerDisplayName(response.first_name, response.last_name, response.email); | ||
| this.$emit( 'onCustomerSelected', response ); | ||
| $contentWrap.unblock(); | ||
| this.closeNewCustomerModal(); | ||
| alert( this.__( 'Customer created successfully', 'wepos' ) ); | ||
| }).fail( response => { | ||
| $contentWrap.unblock(); | ||
| alert( response.responseJSON.message ); | ||
|
|
@@ -373,9 +379,8 @@ export default { | |
| } ); | ||
|
|
||
| var orderdata = JSON.parse( localStorage.getItem( 'orderdata' ) ); | ||
|
|
||
| if ( orderdata.customer_id != 'undefined' && orderdata.customer_id != 0 ) { | ||
| this.serachInput = orderdata.billing.first_name + ' ' + orderdata.billing.last_name; | ||
| this.serachInput = this.getCustomerDisplayName(orderdata.billing.first_name, orderdata.billing.last_name, orderdata.billing.email); | ||
| } | ||
|
Comment on lines
381
to
384
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Same undefined-billing guard needed here
🤖 Prompt for AI Agents |
||
| } | ||
| }; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential
TypeErrorwhenorderdata.billingis missingthis.orderdata.billingis dereferenced without a null-check.When the order arrives from an endpoint where the
billingobject is not yet populated, the watcher will throw (Cannot read property 'first_name' of undefined) and break reactivity.📝 Committable suggestion
🤖 Prompt for AI Agents