-
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 3 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,99 @@ | ||
| import Component from '@ember/component'; | ||
| import FormMixin from 'open-event-frontend/mixins/form'; | ||
| import { validPhoneNumber } from 'open-event-frontend/utils/validators'; | ||
| import { pick } from 'lodash-es'; | ||
|
|
||
| export default Component.extend(FormMixin, { | ||
|
|
||
| async didInsertElement() { | ||
mrsaicharan1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this._super(...arguments); | ||
| let actualUser = await this.authManager.currentUser; | ||
|
||
| let userBillingInfo = pick(actualUser, ['billingContactName', 'billingCity', 'billingPhone', 'company', 'billingTaxInfo', 'billingAddress', 'billingZipCode', 'billingAdditionalInfo']); | ||
| this.set('userBillingInfo', userBillingInfo); | ||
| this.set('actualUser', actualUser); | ||
mrsaicharan1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
|
|
||
| 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') | ||
| } | ||
| ] | ||
| }, | ||
| 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.') | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }; | ||
| }, | ||
| actions: { | ||
| submit() { | ||
| this.onValid(async() => { | ||
| 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import Route from '@ember/routing/route'; | ||
| import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; | ||
|
|
||
| export default Route.extend(AuthenticatedRouteMixin, { | ||
| titleToken() { | ||
| return this.l10n.t('Billing Info'); | ||
| }, | ||
| beforeModel() { | ||
| this._super(...arguments); | ||
| this.replaceWith('account.billing-info.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 |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| import Route from '@ember/routing/route'; | ||
|
|
||
| export default Route.extend({ | ||
| 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 |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| import Route from '@ember/routing/route'; | ||
| import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; | ||
|
|
||
| export default Route.extend({ | ||
| export default 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
| 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,41 @@ | ||
| <form class="ui form" {{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=(mut userBillingInfo.billingContactName)}} | ||
mrsaicharan1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="phone">{{t 'Phone'}}</label> | ||
| {{input type='text' id='phone' value=(mut userBillingInfo.billingPhone)}} | ||
mrsaicharan1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="company">{{t 'Company'}}</label> | ||
| {{input type='text' id='company' value=(mut userBillingInfo.company)}} | ||
| </div> | ||
| <div class="field"> | ||
| <label for="taxID">{{t 'Tax ID or Business ID'}}</label> | ||
| {{input type='text' id='taxID' value=(mut userBillingInfo.billingTaxInfo)}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="address">{{t 'Address'}}</label> | ||
| {{textarea rows='2' id='address' value=(mut userBillingInfo.billingAddress)}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="city">{{t 'City'}}</label> | ||
| {{input type='text' id='city' value=(mut userBillingInfo.billingCity)}} | ||
| </div> | ||
| <div class="field"> | ||
| <label class="required" for="zip">{{t 'Zip Code'}}</label> | ||
| {{input type='text' id='zip' value=(mut userBillingInfo.billingZipCode)}} | ||
| </div> | ||
| <div class="field"> | ||
| <label for="additionalInfo">{{t 'Additional Information'}}</label> | ||
| {{textarea rows='4' id='additionalInfo' value=(mut userBillingInfo.billingAdditionalInfo)}} | ||
| </div> | ||
|
|
||
| <button type="submit" class="ui teal submit button update-changes"> | ||
mrsaicharan1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {{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
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.
Uh oh!
There was an error while loading. Please reload this page.