1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

create by license moved from update license component

This commit is contained in:
Kyle Spearrin
2018-07-03 09:55:59 -04:00
parent 70dbca67e7
commit 738eaa6ca7
8 changed files with 103 additions and 54 deletions

View File

@@ -10,24 +10,20 @@ import { Angulartics2 } from 'angulartics2';
import { ApiService } from 'jslib/abstractions/api.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { TokenService } from 'jslib/abstractions/token.service';
@Component({
selector: 'app-update-license',
templateUrl: 'update-license.component.html',
})
export class UpdateLicenseComponent {
@Input() create = true;
@Input() user = true;
@Output() onUpdated = new EventEmitter();
@Output() onCanceled = new EventEmitter();
storageAdjustment = 0;
formPromise: Promise<any>;
constructor(private apiService: ApiService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService,
private tokenService: TokenService) { }
private analytics: Angulartics2, private toasterService: ToasterService) { }
async submit() {
const fileEl = document.getElementById('file') as HTMLInputElement;
@@ -39,25 +35,18 @@ export class UpdateLicenseComponent {
}
try {
const fd = new FormData();
fd.append('license', files[0]);
if (this.user) {
const fd = new FormData();
fd.append('license', files[0]);
if (this.create) {
if (!this.tokenService.getEmailVerified()) {
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('accountEmailMustBeVerified'));
return;
}
this.formPromise = this.apiService.postPremium(fd);
} else {
this.formPromise = this.apiService.postAccountLicense(fd);
}
this.formPromise = this.apiService.postAccountLicense(fd);
} else {
// TODO
}
await this.formPromise;
if (!this.create) {
this.analytics.eventTrack.next({ action: 'Updated License' });
this.toasterService.popAsync('success', null, this.i18nService.t('updatedLicense'));
}
this.analytics.eventTrack.next({ action: 'Updated License' });
this.toasterService.popAsync('success', null, this.i18nService.t('updatedLicense'));
this.onUpdated.emit();
} catch { }
}