-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Create user payment information form #3215
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
Merged
niranjan94
merged 14 commits into
fossasia:development
from
uds5501:user-payment-information
Jul 12, 2019
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
db2f6f8
Create user payment information form
uds5501 6d40ea7
default reroute billing info to payment info
uds5501 22f8a4f
Merge branch 'development' into user-payment-information
mariobehling 3391e41
change route name to billing
uds5501 350636f
use authManager.currentUser
uds5501 9cac0e4
Merge branch 'development' into user-payment-information
uds5501 b1325ac
Merge branch 'development' into user-payment-information
uds5501 97984e8
follow ES6 patterns and work on suggestions
uds5501 a5861c8
Merge branch 'development' into user-payment-information
uds5501 ae50f4d
add loader in the form
uds5501 9ed2d4c
Merge branch 'development' into user-payment-information
uds5501 a280615
Merge branch 'development' into user-payment-information
mrsaicharan1 2972e50
Merge branch 'development' into user-payment-information
kushthedude e33d085
Merge branch 'development' into user-payment-information
kushthedude 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 |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import Component from '@ember/component'; | ||
| import FormMixin from 'open-event-frontend/mixins/form'; | ||
| import { validPhoneNumber } from 'open-event-frontend/utils/validators'; | ||
| import { pick, orderBy } from 'lodash-es'; | ||
| import { action, computed } from '@ember/object'; | ||
| import { countries } from 'open-event-frontend/utils/dictionary/demography'; | ||
|
|
||
| export default class extends Component.extend(FormMixin) { | ||
| didInsertElement() { | ||
| super.didInsertElement(...arguments); | ||
| this.set('userBillingInfo', pick(this.authManager.currentUser, ['billingContactName', 'billingCity', 'billingPhone', 'company', 'billingTaxInfo', 'billingCountry', 'billingState', 'billingAddress', 'billingZipCode', 'billingAdditionalInfo'])); | ||
| } | ||
|
|
||
| getValidationRules() { | ||
| return { | ||
| inline : true, | ||
| delay : false, | ||
| on : 'blur', | ||
|
|
||
| fields: { | ||
| name: { | ||
| identifier : 'contactName', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter your name') | ||
| } | ||
| ] | ||
| }, | ||
| company: { | ||
| identifier : 'company', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter your company') | ||
| } | ||
| ] | ||
| }, | ||
| country: { | ||
| identifier : 'country', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter your country') | ||
| } | ||
| ] | ||
| }, | ||
| address: { | ||
| identifier : 'address', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter your billing address') | ||
| } | ||
| ] | ||
| }, | ||
| city: { | ||
| identifier : 'city', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter your billing city') | ||
| } | ||
| ] | ||
| }, | ||
| zipCode: { | ||
| identifier : 'zip', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter the zip code') | ||
| } | ||
| ] | ||
| }, | ||
| phone: { | ||
| identifier : 'phone', | ||
| rules : [ | ||
| { | ||
| type : 'empty', | ||
| prompt : this.l10n.t('Please enter a phone number.') | ||
| }, | ||
| { | ||
| type : 'regExp', | ||
| value : validPhoneNumber, | ||
| prompt : this.l10n.t('Please enter a valid phone number.') | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @computed() | ||
| get countries() { | ||
| return orderBy(countries, 'name'); | ||
| } | ||
|
|
||
| @action | ||
| submit() { | ||
| this.onValid(async() => { | ||
| this.set('isLoading', true); | ||
| try { | ||
| this.authManager.currentUser.setProperties(this.userBillingInfo); | ||
| await this.authManager.currentUser.save(); | ||
| this.notify.success(this.l10n.t('Your billing details has been updated')); | ||
| } catch (error) { | ||
| this.authManager.currentUser.rollbackAttributes(); | ||
| this.notify.error(this.l10n.t('An unexpected error occurred')); | ||
| } | ||
| this.set('isLoading', false); | ||
| }); | ||
| } | ||
| } | ||
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import Route from '@ember/routing/route'; | ||
| import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; | ||
|
|
||
| export default class extends Route.extend(AuthenticatedRouteMixin) { | ||
| titleToken() { | ||
| return this.l10n.t('Billing Info'); | ||
| } | ||
|
|
||
| beforeModel() { | ||
| super.beforeModel(...arguments); | ||
| this.replaceWith('account.billing.payment-info'); | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import Route from '@ember/routing/route'; | ||
|
|
||
| export default class extends Route { | ||
| titleToken() { | ||
| return this.l10n.t('Invoices'); | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import Route from '@ember/routing/route'; | ||
| import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; | ||
|
|
||
| export default class extends Route.extend(AuthenticatedRouteMixin) { | ||
| titleToken() { | ||
| return this.l10n.t('Payment Info'); | ||
| } | ||
| } |
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
Empty file.
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
File renamed without changes.
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <div class="ui basic {{if isLoading 'loading' ''}} segment"> | ||
| {{forms/user-payment-info-form}} | ||
| </div> |
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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <form class="ui form {{if isLoading 'loading'}}" {{action 'submit' on='submit'}}> | ||
| <h3 class="ui header"> | ||
| {{t 'Payment Information'}} | ||
| </h3> | ||
| <div class="field"> | ||
| <label class="required" for="contactName">{{t 'Contact Name'}}</label> | ||
| {{input type='text' id='contactName' value=userBillingInfo.billingContactName}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="phone">{{t 'Phone'}}</label> | ||
| {{input type='text' id='phone' value=userBillingInfo.billingPhone}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="company">{{t 'Company'}}</label> | ||
| {{input type='text' id='company' value=userBillingInfo.company}} | ||
| </div> | ||
| <div class="field"> | ||
| <label for="taxID">{{t 'Tax ID or Business ID'}}</label> | ||
| {{input type='text' id='taxID' value=userBillingInfo.billingTaxInfo}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="address">{{t 'Address'}}</label> | ||
| {{textarea rows='2' id='address' value=userBillingInfo.billingAddress}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="city">{{t 'City'}}</label> | ||
| {{input type='text' id='city' value=userBillingInfo.billingCity}} | ||
| </div> | ||
| <div class="field"> | ||
| <label for="state">{{t 'State'}}</label> | ||
| {{input type='text' id='state' value=userBillingInfo.billingState}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required">{{t 'Country'}}</label> | ||
| {{#ui-dropdown class='search selection' selected=userBillingInfo.billingCountry forceSelection=false | ||
| fullTextSearch=true}} | ||
| {{input type='hidden' id='country' value=userBillingInfo.billingCountry}} | ||
| <i class="dropdown icon"></i> | ||
| <div class="default text">{{t 'Select country'}}</div> | ||
| <div class="menu"> | ||
| {{#each countries as |country|}} | ||
| <div class="item" data-value="{{country.name}}"> | ||
| <i class="{{lowercase country.code}} flag"></i> | ||
| {{country.name}} | ||
| </div> | ||
| {{/each}} | ||
| </div> | ||
| {{/ui-dropdown}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="zip">{{t 'Zip Code'}}</label> | ||
| {{input type='text' id='zip' value=userBillingInfo.billingZipCode}} | ||
| </div> | ||
| <div class="field"> | ||
| <label for="additionalInfo">{{t 'Additional Information'}}</label> | ||
| {{textarea rows='4' id='additionalInfo' value=userBillingInfo.billingAdditionalInfo}} | ||
| </div> | ||
|
|
||
| <button type="submit" class="ui teal submit button"> | ||
| {{t 'Submit'}} | ||
| </button> | ||
| </form> |
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
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
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
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.
Show a loading UI..
See others forms and stick to something that is similar to the others
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.
Okay, I used the existing loading UI being used in the other forms.