...
 
Commits (2)
<div class="m-walletBalance--cash" *ngIf="!inProgress">
<div class="m-walletBalance---cash__onboardingNotice">
<div
class="m-walletBalance---cash__onboardingNotice"
*ngIf="!hasAccount || !account.bankAccount"
>
<p (click)="scrollToSettings()">
<a>Add your bank information</a>
</p>
......
......@@ -35,6 +35,7 @@ export class WalletBalanceCashComponent implements OnInit, OnDestroy {
loaded: boolean = false;
@Output() scrollToCashSettings: EventEmitter<any> = new EventEmitter();
constructor(
protected client: Client,
protected cd: ChangeDetectorRef,
......
<div *ngIf="inProgress" class="m-wallet__spinner">
<div class="mdl-spinner mdl-js-spinner is-active" [mdl]></div>
</div>
<m-pageLayout [menu]="menu" *ngIf="!inProgress">
<m-pageLayout [menu]="menu">
<div class="m-walletDashboard" m-pageLayout__main *ngIf="currencies">
<m-dashboardLayout>
<ng-container m-dashboardLayout__header>
......@@ -11,7 +8,10 @@
</h3>
</div>
</ng-container>
<ng-container m-dashboardLayout__body>
<div *ngIf="inProgress" class="m-wallet__spinner">
<div class="mdl-spinner mdl-js-spinner is-active" [mdl]></div>
</div>
<ng-container m-dashboardLayout__body *ngIf="!inProgress">
<m-shadowboxLayout>
<m-shadowboxHeader__tabs
class="m-shadowboxLayout__header"
......@@ -23,8 +23,10 @@
<div class="m-shadowboxLayout__body">
<div class="m-walletDashboardBalances__wrapper">
<m-walletTokenOnboarding
*ngIf="activeCurrencyId === 'tokens' && !onboardingComplete"
(onboardingCompleted)="onboardingCompleted()"
*ngIf="
activeCurrencyId === 'tokens' && !tokenOnboardingComplete
"
(onboardingCompleted)="tokenOnboardingCompleted()"
(scrollToTokenSettings)="scrollToSettings('tokens')"
></m-walletTokenOnboarding>
<m-walletBalance--tokens
......@@ -66,6 +68,7 @@
></m-walletTransactions--tokens>
<m-walletTransactions--cash
*ngIf="activeCurrencyId === 'cash'"
[noAccount]="wallet.cash.address === null"
></m-walletTransactions--cash>
</ng-container>
<ng-container *ngIf="activeViewId === 'settings'">
......
......@@ -21,9 +21,7 @@ m-walletDashboard {
justify-content: space-around;
align-items: center;
}
m-tooltip {
z-index: 99999;
}
m-shadowboxHeader {
min-height: 103px;
}
......
......@@ -18,7 +18,6 @@ import { ActivatedRoute, Router, ParamMap } from '@angular/router';
import sidebarMenu from './sidebar-menu.default';
import { Menu } from '../../../common/components/sidebar-menu/sidebar-menu.component';
import { ShadowboxHeaderTab } from '../../../interfaces/dashboard';
import { FeaturesService } from '../../../services/features.service';
@Component({
selector: 'm-walletDashboard',
......@@ -38,20 +37,20 @@ export class WalletDashboardComponent implements OnInit, OnDestroy {
activeCurrencyId: string;
activeViewId: string;
onboardingComplete = false;
tokenOnboardingComplete = false;
views: any = {
tokens: [
{ id: 'overview', label: 'Overview' },
{ id: 'transactions', label: 'Transactions' },
{ id: 'settings', label: 'Settings' },
{ id: 'overview', label: 'Overview', display: true },
{ id: 'transactions', label: 'Transactions', display: true },
{ id: 'settings', label: 'Settings', display: true },
],
cash: [
{ id: 'transactions', label: 'Transactions' },
{ id: 'settings', label: 'Settings' },
{ id: 'transactions', label: 'Transactions', display: true },
{ id: 'settings', label: 'Settings', display: true },
],
eth: [{ id: 'settings', label: 'Settings' }],
btc: [{ id: 'settings', label: 'Settings' }],
eth: [{ id: 'settings', label: 'Settings', display: true }],
btc: [{ id: 'settings', label: 'Settings', display: true }],
};
currencies: ShadowboxHeaderTab[] = [];
......@@ -75,7 +74,7 @@ export class WalletDashboardComponent implements OnInit, OnDestroy {
this.session.getLoggedInUser().rewards &&
this.session.getLoggedInUser().eth_wallet
) {
this.onboardingComplete = true;
this.tokenOnboardingComplete = true;
}
this.paramsSubscription = this.route.paramMap.subscribe(
......@@ -161,8 +160,8 @@ export class WalletDashboardComponent implements OnInit, OnDestroy {
this.detectChanges();
}
onboardingCompleted() {
this.onboardingComplete = true;
tokenOnboardingCompleted() {
this.tokenOnboardingComplete = true;
this.detectChanges();
}
......@@ -189,6 +188,7 @@ export class WalletDashboardComponent implements OnInit, OnDestroy {
0
);
}
this.detectChanges();
}
detectChanges() {
......
......@@ -169,24 +169,25 @@ export class WalletDashboardService {
async getStripeAccount() {
const merchant = this.session.getLoggedInUser().merchant;
if (merchant && merchant.service === 'stripe') {
try {
const { account } = <any>(
await this.client.get('api/v2/payments/stripe/connect')
);
if (account) {
console.log('svc getAcc', account);
this.wallet.cash.address = 'stripe';
this.wallet.cash.balance =
(account.totalBalance.amount - account.pendingBalance.amount) / 100;
if (account.bankAccount) {
const bankCurrency = account.bankAccount.currency;
this.wallet.cash.label = bankCurrency.toUpperCase;
const bankCurrency: string = account.bankAccount.currency;
this.wallet.cash.label = bankCurrency.toUpperCase();
this.wallet.cash.unit = bankCurrency;
} else {
// Has stripe account but not setup bank account
const defaultCurrency = account.pendingBalance.currency;
this.wallet.cash.label = defaultCurrency.toUpperCase;
this.wallet.cash.unit = defaultCurrency;
this.wallet.cash.label = 'USD';
this.wallet.cash.unit = 'usd';
}
}
return account;
......@@ -200,7 +201,6 @@ export class WalletDashboardService {
}
async createStripeAccount(form) {
console.log('stripeform', form);
try {
const response = <any>(
await this.client.put('api/v2/wallet/usd/account', form)
......
......@@ -92,22 +92,22 @@ export class WalletCashBankFormComponent implements OnInit {
}
}
async leaveMonetization() {
this.showModal = false;
this.inProgress = true;
this.detectChanges();
this.walletService
.leaveMonetization()
.then((response: any) => {
this.configs.set('merchant', []);
this.leftMonetization = true;
})
.catch(e => {
this.formToastService.error(e.message);
});
this.inProgress = false;
this.detectChanges();
}
// async leaveMonetization() {
// this.showModal = false;
// this.inProgress = true;
// this.detectChanges();
// this.walletService
// .leaveMonetization()
// .then((response: any) => {
// this.configs.set('merchant', []);
// this.leftMonetization = true;
// })
// .catch(e => {
// this.formToastService.error(e.message);
// });
// this.inProgress = false;
// this.detectChanges();
// }
async addBank() {
this.error = '';
......
......@@ -60,35 +60,34 @@ export class WalletCashOnboardingComponent implements OnInit {
async createAccount() {
this.inProgress = true;
this.error = '';
this.detectChanges();
console.log('createAccountFormval', this.form.value);
this.walletService
.createStripeAccount(this.form.value)
.then((response: any) => {
console.log('createStripeAccount response', response);
if (!this.user.programs) {
this.user.programs = [];
}
this.user.programs.push('affiliate');
this.user.merchant = {
id: response.id,
service: 'stripe',
};
this.detectChanges();
})
.catch(e => {
// TODO backend should include e.param to allow inline error handling
this.error = e.message;
});
this.inProgress = false;
this.detectChanges();
if (!this.error) {
try {
const response: any = await this.walletService.createStripeAccount(
this.form.value
);
console.log('createStripeAccount response', response);
if (!this.user.programs) {
this.user.programs = [];
}
this.user.programs.push('affiliate');
this.user.merchant = {
id: response.id,
service: 'stripe',
};
console.log('888emitting submitted');
this.submitted.emit();
} catch (e) {
// TODO backend should include e.param to allow inline error handling
this.error = e.message;
} finally {
this.inProgress = false;
this.detectChanges();
}
}
......
......@@ -8,7 +8,7 @@
[allowedCountries]="allowedCountries"
(submitted)="setView()"
></m-walletCashOnboarding>
<!-- BANK FORM --------------------------- -->
<!-- BANK FORM ----------------------- -->
<m-walletCashBankForm
*ngIf="view === 'bank'"
[account]="account"
......@@ -22,6 +22,6 @@
[allowedCountries]="allowedCountries"
(submitted)="setView()"
></m-walletCashOnboardingExtras>
<!-- ERROR --------------------------- -->
<!-- ERROR ----------------------------- -->
<p *ngIf="view === 'error'" class="m-walletForm__error">{{ error }}</p>
</div>
......@@ -80,9 +80,10 @@ export class WalletSettingsCashComponent implements OnInit {
if (!hasMerchant) {
this.view = 'onboarding';
} else {
await this.getAccount();
this.account = await this.getAccount();
console.log('888settingscashaccount', this.account);
if (this.error) {
this.detectChanges();
return;
}
......@@ -118,7 +119,7 @@ export class WalletSettingsCashComponent implements OnInit {
}
hasBankAccount() {
if (this.account.requirement) {
if (this.account && this.account.requirement) {
return this.account.requirement.indexOf('external_account') === -1;
} else {
return true;
......
......@@ -25,7 +25,6 @@ export class WalletSettingsETHComponent implements OnInit {
async load() {
this.ethWallet = await this.walletService.getEthAccount();
console.log('ethw', this.ethWallet);
this.detectChanges();
}
detectChanges() {
......
<div class="m-walletTransactions m-walletTransactions--cash">
<div *ngIf="inProgress || !init" class="m-walletTransactions__spinner">
<div *ngIf="!init" class="m-wallet__spinner">
<div class="mdl-spinner mdl-js-spinner is-active" [mdl]></div>
</div>
<div class="m-walletTransactionsTable__wrapper" *ngIf="init">
<!-- <div class="m-walletTransactionsTable__row--top">
<div class="m-walletTransactionsTable__time">
Upcoming
</div>
<div class="m-walletTransactionsTable__typeWrapper">
(mouseenter)="showRewardsPopup = true"
(mouseleave)="showRewardsPopup = false"
<i class="material-icons">star_border</i
><span>Estimated Pro Earnings</span>
</div>
<m-walletPendingCashPayout
*ngIf="showRewardsPopup"
></m-walletPendingCashPayout>
</div> -->
<ng-container *ngIf="!inProgress || transactions">
<ng-container *ngIf="init">
<div
class="m-walletTransactionsTable__wrapper"
*ngIf="transactions.length >= 1 || !noAccount"
>
<m-walletTransactionsTable
[currency]="currency"
[transactions]="transactions"
......@@ -25,13 +14,16 @@
</m-walletTransactionsTable>
<infinite-scroll
distance="25%"
(load)="load(false)"
(load)="loadTransactions(false)"
[moreData]="moreData"
[inProgress]="inProgress"
></infinite-scroll>
</ng-container>
</div>
<div class="m-walletTransactions__noTxNotice" *ngIf="init && !transactions">
You don't have any cash transactions yet.
</div>
</div>
<div
class="m-walletTransactions__noTxNotice"
*ngIf="transactions.length === 0 || noAccount"
>
<p>You don't have any cash transactions yet.</p>
</div>
</ng-container>
</div>
......@@ -20,6 +20,8 @@ import * as moment from 'moment';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WalletTransactionsCashComponent implements OnInit {
@Input() noAccount: boolean = false;
init: boolean = false;
inProgress: boolean = true;
offset: string;
......@@ -45,28 +47,54 @@ export class WalletTransactionsCashComponent implements OnInit {
) {}
ngOnInit() {
this.getStripeAccount();
if (!this.noAccount) {
this.getStripeAccount();
} else {
this.init = true;
}
this.detectChanges();
}
async getStripeAccount() {
const account = await this.walletService.getStripeAccount();
if (!account) {
this.init = true;
this.detectChanges();
return;
} else {
if (account.bankAccount) {
this.currency = account.bankAccount.currency.toUpperCase();
}
try {
const account = await this.walletService.getStripeAccount();
console.log('txcashAcct', account);
if (account) {
if (account.bankAccount) {
this.currency = account.bankAccount.currency.toUpperCase();
}
this.runningTotal = account.pendingBalance.amount / 100;
this.runningTotal = account.pendingBalance.amount / 100;
}
} catch (e) {
console.error(e);
this.moreData = false;
} finally {
this.init = true;
this.inProgress = false;
this.detectChanges();
}
this.load(true);
}
async load(refresh: boolean) {
// const account = await this.walletService.getStripeAccount();
// console.log('txcashAcct', account);
// if (!account) {
// this.init = true;
// this.detectChanges();
// return;
// } else {
// if (account.bankAccount) {
// this.currency = account.bankAccount.currency.toUpperCase();
// }
// this.runningTotal = account.pendingBalance.amount / 100;
// this.detectChanges();
// }
// this.loadTransactions(true);
// }
async loadTransactions(refresh: boolean) {
if (this.inProgress && !refresh) {
return;
}
......
......@@ -13,11 +13,6 @@
justify-content: flex-start;
}
}
.m-walletTransactions__spinner {
display: flex;
justify-content: center;
}
[class*='m-walletTransactionsTable__row'] {
display: flex;
justify-content: space-between;
......@@ -133,3 +128,13 @@ m-walletTransactionsTable {
}
}
}
.m-walletTransactions__noTxNotice {
display: flex;
justify-content: space-around;
margin-top: 48px;
p {
@include m-theme() {
color: themed($m-textColor--tertiary);
}
}
}
<div class="m-walletTransactions">
<div *ngIf="inProgress || !init" class="m-walletTransactions__spinner">
<div *ngIf="!init" class="m-wallet__spinner">
<div class="mdl-spinner mdl-js-spinner is-active" [mdl]></div>
</div>
<div class="m-walletTransactionsTable__wrapper" *ngIf="init">
<div class="m-walletTransactionsTable__row--top">
<div class="m-walletTransactionsTable__time">
Upcoming
</div>
<div
class="m-walletTransactionsTable__typeWrapper containsPopover"
(mouseenter)="showRewardsPopup = true"
(mouseleave)="showRewardsPopup = false"
>
<i class="material-icons">star_border</i
><span>Today's Daily Rewards</span>
</div>
<m-walletRewardsPopup
[timestamp]="startOfToday"
*ngIf="showRewardsPopup"
></m-walletRewardsPopup>
<div class="m-walletTransactionsTable__filterWrapper">
<span>Transaction Type</span>
<m-dropdownSelector
*ngIf="transactions"
[filter]="filter"
[showLabel]="false"
(selectionMade)="filterSelected($event)"
></m-dropdownSelector>
<ng-container *ngIf="init">
<div class="m-walletTransactionsTable__wrapper">
<div class="m-walletTransactionsTable__row--top">
<div class="m-walletTransactionsTable__time">
Upcoming
</div>
<div
class="m-walletTransactionsTable__typeWrapper containsPopover"
(mouseenter)="showRewardsPopup = true"
(mouseleave)="showRewardsPopup = false"
>
<i class="material-icons">star_border</i
><span>Today's Daily Rewards</span>
</div>
<m-walletRewardsPopup
[timestamp]="startOfToday"
*ngIf="showRewardsPopup"
></m-walletRewardsPopup>
<div class="m-walletTransactionsTable__filterWrapper">
<span>Transaction Type</span>
<m-dropdownSelector
*ngIf="transactions"
[filter]="filter"
[showLabel]="false"
(selectionMade)="filterSelected($event)"
></m-dropdownSelector>
</div>
</div>
<ng-container *ngIf="transactions.length >= 1">
<m-walletTransactionsTable
currency="tokens"
[transactions]="transactions"
[filterApplied]="filterApplied"
>
</m-walletTransactionsTable>
<infinite-scroll
distance="25%"
(load)="loadTransactions(false)"
[moreData]="moreData"
[inProgress]="inProgress"
></infinite-scroll>
</ng-container>
</div>
<ng-container *ngIf="!inProgress || transactions">
<m-walletTransactionsTable
currency="tokens"
[transactions]="transactions"
[filterApplied]="filterApplied"
>
</m-walletTransactionsTable>
<infinite-scroll
distance="25%"
(load)="load(false)"
[moreData]="moreData"
[inProgress]="inProgress"
></infinite-scroll>
</ng-container>
</div>
<div class="m-walletTransactions__noTxNotice" *ngIf="init && !transactions">
You don't have any token transactions yet.
</div>
<div
class="m-walletTransactions__noTxNotice"
*ngIf="transactions.length === 0"
>
<p>You don't have any token transactions yet.</p>
</div>
</ng-container>
</div>
......@@ -198,7 +198,7 @@ export const MINDS_PROVIDERS: any[] = [
{
provide: BlockchainService,
useFactory: BlockchainService._,
deps: [Client],
deps: [Client, Session],
},
{
provide: WebtorrentService,
......