Skip to content

Commit 2e6625a

Browse files
mrsaicharan1abhinavk96
authored andcommitted
feat: add intial mechanism for billing options(admin) (#3152)
* add intial mechanism for billing options(admin) Added fields for admin invoice contact Changed model names according to server added values for each field Used ES6 syntax Used attrs to access action closure Fixed additional info field remove redundant variable * Fixed validations * Fix travis
1 parent ae7ad3b commit 2e6625a

File tree

8 files changed

+320
-65
lines changed

8 files changed

+320
-65
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import Component from '@ember/component';
2+
import FormMixin from 'open-event-frontend/mixins/form';
3+
import { validPhoneNumber } from 'open-event-frontend/utils/validators';
4+
import { action } from '@ember/object';
5+
6+
export default class extends Component.extend(FormMixin) {
7+
getValidationRules() {
8+
return {
9+
inline : true,
10+
delay : false,
11+
on : 'blur',
12+
fields : {
13+
adminBillingContactName: {
14+
identifier : 'adminBillingContactName',
15+
rules : [
16+
{
17+
type : 'empty',
18+
prompt : this.l10n.t('Please enter the Contact name')
19+
}
20+
]
21+
},
22+
adminBillingPhone: {
23+
identifier : 'adminBillingPhone',
24+
rules : [
25+
{
26+
type : 'regExp',
27+
value : validPhoneNumber,
28+
prompt : this.l10n.t('Please enter a valid mobile number.')
29+
}
30+
]
31+
},
32+
adminBillingEmail: {
33+
identifier : 'adminBillingEmail',
34+
rules : [
35+
{
36+
type : 'empty',
37+
prompt : this.l10n.t('Please enter the email')
38+
},
39+
{
40+
type : 'email',
41+
prompt : this.l10n.t('Please enter a valid email address')
42+
}
43+
]
44+
},
45+
adminBillingCountry: {
46+
identifier : 'adminBillingCountry',
47+
rules : [
48+
{
49+
type : 'empty',
50+
prompt : this.l10n.t('Please enter the country')
51+
}
52+
]
53+
},
54+
55+
adminBillingTaxInfo: {
56+
identifier : 'adminBillingTaxInfo',
57+
rules : [
58+
{
59+
type : 'empty',
60+
prompt : this.l10n.t('Please enter the tax id')
61+
}
62+
]
63+
},
64+
adminCompany: {
65+
identifier : 'adminCompany',
66+
rules : [
67+
{
68+
type : 'empty',
69+
prompt : this.l10n.t('Please enter the company')
70+
}
71+
]
72+
},
73+
adminBillingAddress: {
74+
identifier : 'adminBillingAddress',
75+
rules : [
76+
{
77+
type : 'empty',
78+
prompt : this.l10n.t('Please enter the Address')
79+
}
80+
]
81+
},
82+
adminBillingCity: {
83+
identifier : 'adminBillingCity',
84+
rules : [
85+
{
86+
type : 'empty',
87+
prompt : this.l10n.t('Please enter the city')
88+
}
89+
]
90+
},
91+
92+
adminBillingZip: {
93+
identifier : 'adminBillingZip',
94+
rules : [
95+
{
96+
type : 'empty',
97+
prompt : this.l10n.t('Please enter the zip code')
98+
}
99+
]
100+
}
101+
}
102+
};
103+
}
104+
105+
@action
106+
submit() {
107+
this.onValid(() => {
108+
this.save();
109+
});
110+
}
111+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Controller from '@ember/controller';
2+
import { timezones } from 'open-event-frontend/utils/dictionary/date-time';
3+
import { countries } from 'open-event-frontend/utils/dictionary/demography';
4+
import { action } from '@ember/object';
5+
import { computed } from '@ember/object';
6+
import { paymentCountries } from 'open-event-frontend/utils/dictionary/payment';
7+
import { orderBy, filter } from 'lodash-es';
8+
9+
10+
export default class extends Controller {
11+
timezones = timezones;
12+
@computed()
13+
get countries() {
14+
return orderBy(filter(countries, country => paymentCountries.includes(country.code)), 'name');
15+
}
16+
payment
17+
@action
18+
async updateInvoiceModel() {
19+
this.set('isLoading', true);
20+
try {
21+
await this.model.save();
22+
this.notify.success(this.l10n.t('Admin Billing info has been saved successfully'));
23+
} catch (error) {
24+
this.notify.error(this.l10n.t('An unexpected error has occurred. Settings not saved.'));
25+
}
26+
this.set('isLoading', false);
27+
}
28+
}

app/models/setting.js

Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,80 @@ export default ModelBase.extend({
88
* Attributes
99
*/
1010

11-
appEnvironment : attr('string'),
12-
appName : attr('string'),
13-
tagline : attr('string'),
14-
secret : attr('string'),
15-
storagePlace : attr('string'),
16-
awsKey : attr('string'),
17-
awsSecret : attr('string'),
18-
awsBucketName : attr('string'),
19-
awsRegion : attr('string'),
20-
gsKey : attr('string'),
21-
gsSecret : attr('string'),
22-
gsBucketName : attr('string'),
23-
isGoogleRecaptchaEnabled : attr('boolean', { defaultValue: false }),
24-
googleRecaptchaSitekey : attr('string'),
25-
googleRecaptchaSecretkey : attr('string'),
26-
googleClientId : attr('string'),
27-
googleClientSecret : attr('string'),
28-
fbClientId : attr('string'),
29-
fbClientSecret : attr('string'),
30-
twConsumerKey : attr('string'),
31-
twConsumerSecret : attr('string'),
32-
inClientId : attr('string'),
33-
inClientSecret : attr('string'),
34-
paypalMode : attr('string'),
35-
paypalClient : attr('string'),
36-
paypalSecret : attr('string'),
37-
paypalSandboxClient : attr('string'),
38-
paypalSandboxSecret : attr('string'),
39-
alipaySecretKey : attr('string'),
40-
alipayPublishableKey : attr('string'),
41-
omiseMode : attr('string'),
42-
omiseTestPublic : attr('string'),
43-
omiseTestSecret : attr('string'),
44-
omiseLivePublic : attr('string'),
45-
omiseLiveSecret : attr('string'),
46-
stripeClientId : attr('string'),
47-
stripeSecretKey : attr('string'),
48-
stripePublishableKey : attr('string'),
49-
isPaypalActivated : attr('boolean'),
50-
isStripeActivated : attr('boolean'),
51-
isAliPayActivated : attr('boolean'),
52-
isOmiseActivated : attr('boolean'),
53-
emailService : attr('string'),
54-
emailFrom : attr('string'),
55-
emailFromName : attr('string'),
56-
sendgridKey : attr('string'),
57-
smtpHost : attr('string'),
58-
smtpUsername : attr('string'),
59-
smtpPassword : attr('string'),
60-
smtpPort : attr('string'),
61-
smtpEncryption : attr('string'),
62-
analyticsKey : attr('string'),
63-
googleUrl : attr('string'),
64-
githubUrl : attr('string'),
65-
twitterUrl : attr('string'),
66-
supportUrl : attr('string'),
67-
facebookUrl : attr('string'),
68-
youtubeUrl : attr('string'),
69-
androidAppUrl : attr('string'),
70-
frontendUrl : attr('string'),
71-
webAppUrl : attr('string'),
72-
staticDomain : attr('string'),
73-
cookiePolicy : attr('string'),
74-
cookiePolicyLink : attr('string'),
75-
11+
appEnvironment : attr('string'),
12+
appName : attr('string'),
13+
tagline : attr('string'),
14+
secret : attr('string'),
15+
storagePlace : attr('string'),
16+
awsKey : attr('string'),
17+
awsSecret : attr('string'),
18+
awsBucketName : attr('string'),
19+
awsRegion : attr('string'),
20+
gsKey : attr('string'),
21+
gsSecret : attr('string'),
22+
gsBucketName : attr('string'),
23+
googleClientId : attr('string'),
24+
googleClientSecret : attr('string'),
25+
fbClientId : attr('string'),
26+
fbClientSecret : attr('string'),
27+
twConsumerKey : attr('string'),
28+
twConsumerSecret : attr('string'),
29+
inClientId : attr('string'),
30+
inClientSecret : attr('string'),
31+
paypalMode : attr('string'),
32+
paypalClient : attr('string'),
33+
paypalSecret : attr('string'),
34+
paypalSandboxClient : attr('string'),
35+
paypalSandboxSecret : attr('string'),
36+
alipaySecretKey : attr('string'),
37+
alipayPublishableKey : attr('string'),
38+
omiseMode : attr('string'),
39+
omiseTestPublic : attr('string'),
40+
omiseTestSecret : attr('string'),
41+
omiseLivePublic : attr('string'),
42+
omiseLiveSecret : attr('string'),
43+
stripeClientId : attr('string'),
44+
stripeSecretKey : attr('string'),
45+
stripePublishableKey : attr('string'),
46+
isAliPayActivated : attr('boolean'),
47+
isPaypalActivated : attr('boolean'),
48+
isStripeActivated : attr('boolean'),
49+
isOmiseActivated : attr('boolean'),
50+
emailService : attr('string'),
51+
emailFrom : attr('string'),
52+
emailFromName : attr('string'),
53+
sendgridKey : attr('string'),
54+
smtpHost : attr('string'),
55+
smtpUsername : attr('string'),
56+
smtpPassword : attr('string'),
57+
smtpPort : attr('string'),
58+
smtpEncryption : attr('string'),
59+
analyticsKey : attr('string'),
60+
googleUrl : attr('string'),
61+
githubUrl : attr('string'),
62+
twitterUrl : attr('string'),
63+
supportUrl : attr('string'),
64+
facebookUrl : attr('string'),
65+
youtubeUrl : attr('string'),
66+
androidAppUrl : attr('string'),
67+
frontendUrl : attr('string'),
68+
webAppUrl : attr('string'),
69+
staticDomain : attr('string'),
70+
cookiePolicy : attr('string'),
71+
cookiePolicyLink : attr('string'),
72+
invoiceSendingDay : attr('number'),
73+
invoiceSendingTimezone : attr('string'),
74+
adminBillingContactName : attr('string'),
75+
adminBillingPhone : attr('string'),
76+
adminBillingEmail : attr('string'),
77+
adminBillingState : attr('string'),
78+
adminBillingCountry : attr('string'),
79+
adminBillingTaxInfo : attr('string'),
80+
adminCompany : attr('string'),
81+
adminBillingAddress : attr('string'),
82+
adminBillingCity : attr('string'),
83+
adminBillingZip : attr('string'),
84+
adminBillingAdditionalInfo : attr('string'),
7685
/**
7786
* Computed properties
7887
*/

app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ router.map(function() {
190190
this.route('analytics');
191191
this.route('payment-gateway');
192192
this.route('ticket-fees');
193+
this.route('billing');
193194
});
194195
this.route('modules');
195196
this.route('content', function() {

app/routes/admin/settings/billing.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Route from '@ember/routing/route';
2+
3+
export default class extends Route {
4+
titleToken() {
5+
return this.l10n.t('Admin Billing');
6+
}
7+
model() {
8+
return this.modelFor('admin.settings');
9+
}
10+
}

app/templates/admin/settings.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
{{#link-to 'admin.settings.ticket-fees' class='item'}}
2121
{{t 'Ticket Fees'}}
2222
{{/link-to}}
23+
{{#link-to 'admin.settings.billing' class='item'}}
24+
{{t 'Billing'}}
25+
{{/link-to}}
2326
{{/tabbed-navigation}}
2427
</div>
2528
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="ui basic {{if isLoading 'loading'}} segment">
2+
{{forms/admin/settings/billing timezones=timezones countries=countries model=model save=(action 'updateInvoiceModel')}}
3+
</div>

0 commit comments

Comments
 (0)