fix lot of linting errors and make command more userful

This commit is contained in:
Anthony 2021-08-12 13:53:28 +02:00
parent ab2e9094e3
commit 041647d1f6
No known key found for this signature in database
GPG key ID: C386D3C93D50E356
8 changed files with 87 additions and 140 deletions

View file

@ -38,7 +38,7 @@
"build:dir": "yarn build -- --dir -c.compression=store -c.mac.identity=null",
"crossenv": "./node_modules/cross-env/dist/bin/cross-env",
"lint": "eslint 'ui/**/*.{js,jsx}' && eslint 'web/**/*.{js,jsx}' && eslint 'electron/**/*.js' && flow",
"lint-fix": "eslint --fix 'ui/**/*.{js,jsx}' && eslint --fix 'web/**/*.{js,jsx}' && eslint --fix 'electron/**/*.js' && flow",
"lint-fix": "eslint --fix --quiet 'ui/**/*.{js,jsx}' && eslint --fix --quiet 'web/**/*.{js,jsx}' && eslint --fix --quiet 'electron/**/*.js'",
"format": "prettier 'src/**/*.{js,jsx,scss,json}' --write",
"flow-defs": "flow-typed install",
"precommit": "lint-staged",

View file

@ -1,16 +1,7 @@
// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
import React from 'react';
import CreditAmount from 'component/common/credit-amount';
import Button from 'component/button';
import HelpLink from 'component/common/help-link';
import Card from 'component/common/card';
import Icon from 'component/common/icon';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import { formatNumberWithCommas } from 'util/number';
import { Lbryio } from 'lbryinc';
import moment from 'moment';
@ -20,10 +11,6 @@ type Props = {
};
const WalletBalance = (props: Props) => {
const {
} = props;
// receive transactions from parent component
let accountTransactions = props.transactions;
@ -36,7 +23,7 @@ const WalletBalance = (props: Props) => {
accountTransactions.length = 10;
}
const [detailsExpanded, setDetailsExpanded] = React.useState(false);
// const [detailsExpanded, setDetailsExpanded] = React.useState(false);
const [accountStatusResponse, setAccountStatusResponse] = React.useState();
const [subscriptions, setSubscriptions] = React.useState([]);
@ -47,15 +34,13 @@ const WalletBalance = (props: Props) => {
'account',
'status',
{
environment
environment,
},
'post'
);
}
React.useEffect(() => {
(async function() {
const response = await getAccountStatus();
@ -68,7 +53,7 @@ const WalletBalance = (props: Props) => {
return (
<><Card
title={'Tip History'}
body={1 == 1 && (
body={(
<>
<div className="table__wrapper">
<table className="table table--transactions">
@ -116,7 +101,7 @@ const WalletBalance = (props: Props) => {
))}
</tbody>
</table>
{!accountTransactions && <p style={{textAlign:"center", marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
{!accountTransactions && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
</div>
</>
)}
@ -170,7 +155,7 @@ const WalletBalance = (props: Props) => {
))}
</tbody>
</table>
{(!subscriptions || subscriptions.length === 0) && <p style={{textAlign:"center", marginTop: '22px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Subscriptions</p>}
{(!subscriptions || subscriptions.length === 0) && <p style={{textAlign: 'center', marginTop: '22px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Subscriptions</p>}
</div>
</>
}

View file

@ -1,16 +1,12 @@
// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
import React from 'react';
import CreditAmount from 'component/common/credit-amount';
import Button from 'component/button';
import HelpLink from 'component/common/help-link';
import Card from 'component/common/card';
import Icon from 'component/common/icon';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import { formatNumberWithCommas } from 'util/number';
type Props = {
accountDetails: any,
@ -27,8 +23,8 @@ const WalletBalance = (props: Props) => {
const [detailsExpanded, setDetailsExpanded] = React.useState(false);
return (
<>{1 == 1 && <Card
title={<><Icon size="18" icon={ICONS.FINANCE} />{accountDetails && accountDetails.total_received_unpaid/100 || 0} USD</>}
<>{<Card
title={<><Icon size="18" icon={ICONS.FINANCE} />{(accountDetails && (accountDetails.total_received_unpaid / 100)) || 0} USD</>}
subtitle={
<I18nMessage>
This is your remaining balance that can still be withdrawn to your bank account
@ -37,11 +33,11 @@ const WalletBalance = (props: Props) => {
actions={
<>
<h2 className="section__title--small">
${accountDetails && accountDetails.total_tipped / 100 || 0} Total Received Tips
${(accountDetails && (accountDetails.total_tipped / 100)) || 0} Total Received Tips
</h2>
<h2 className="section__title--small">
${accountDetails && accountDetails.total_paid_out/100 || 0} Withdrawn
${(accountDetails && (accountDetails.total_paid_out / 100)) || 0} Withdrawn
<Button
button="link"
label={detailsExpanded ? __('View less') : __('View more')}

View file

@ -1,16 +1,11 @@
// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
import React from 'react';
import CreditAmount from 'component/common/credit-amount';
import Button from 'component/button';
import HelpLink from 'component/common/help-link';
import Card from 'component/common/card';
import Icon from 'component/common/icon';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import { formatNumberWithCommas } from 'util/number';
type Props = {
totalTippedAmount: number,
@ -18,25 +13,23 @@ type Props = {
transactions: any,
};
const WalletBalance = (props: Props) => {
const {
accountDetails,
// accountDetails,
totalTippedAmount,
transactions,
} = props;
const [detailsExpanded, setDetailsExpanded] = React.useState(false);
// const [detailsExpanded, setDetailsExpanded] = React.useState(false);
const [totalCreatorsSupported, setTotalCreatorsSupported] = React.useState(false);
// calculate how many unique users tipped
React.useEffect(() => {
if (transactions) {
let channelNames = []
let channelNames = [];
for (const transaction of transactions) {
channelNames.push(transaction.channel_name)
channelNames.push(transaction.channel_name);
console.log(transaction.channel_name);
}
@ -46,7 +39,7 @@ const WalletBalance = (props: Props) => {
}, [transactions]);
return (
<>{1 == 1 && <Card
<>{<Card
title={<><Icon size="18" icon={ICONS.FINANCE} />{totalTippedAmount} USD</>}
subtitle={
<I18nMessage>

View file

@ -1,16 +1,7 @@
// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
import React from 'react';
import CreditAmount from 'component/common/credit-amount';
import Button from 'component/button';
import HelpLink from 'component/common/help-link';
import Card from 'component/common/card';
import Icon from 'component/common/icon';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import { formatNumberWithCommas } from 'util/number';
import { Lbryio } from 'lbryinc';
import moment from 'moment';
@ -21,47 +12,41 @@ type Props = {
};
const WalletBalance = (props: Props) => {
const {
} = props;
// receive transactions from parent component
let accountTransactions = props.transactions;
console.log('heres transactions')
console.log('heres transactions');
console.log(accountTransactions);
// let totalTippedAmount = props.totalTippedAmount;
// totalTippedAmount = 0;
// reverse so most recent payments come first
if (accountTransactions) {
accountTransactions = accountTransactions.reverse();
}
const [detailsExpanded, setDetailsExpanded] = React.useState(false);
const [accountStatusResponse, setAccountStatusResponse] = React.useState();
// const [detailsExpanded, setDetailsExpanded] = React.useState(false);
// const [accountStatusResponse, setAccountStatusResponse] = React.useState();
// const [totalTippedAmount, setTotalTippedAmount] = React.useState(0);
const [paymentHistoryTransactions, setPaymentHistoryTransactions] = React.useState();
const [subscriptions, setSubscriptions] = React.useState();
const [totalTippedAmount, setTotalTippedAmount] = React.useState(0);
const [lastFour, setLastFour] = React.useState();
var environment = 'test';
function getPaymentHistory() {
return Lbryio.call(
'customer',
'list',
{
environment,
},
'post'
)};
// function getPaymentHistory() {
// return Lbryio.call(
// 'customer',
// 'list',
// {
// environment,
// },
// 'post'
// ); };
function getCustomerStatus() {
return Lbryio.call(
@ -71,7 +56,7 @@ const WalletBalance = (props: Props) => {
environment,
},
'post'
)
);
}
React.useEffect(() => {
@ -92,14 +77,13 @@ const WalletBalance = (props: Props) => {
const subscriptions = [...response];
if (subscriptions && subscriptions.length > 2) {
subscriptions.length = 2
setSubscriptions([])
subscriptions.length = 2;
setSubscriptions([]);
} else {
setSubscriptions([])
setSubscriptions([]);
}
console.log(response);
})();
}, [accountTransactions]);
@ -153,7 +137,7 @@ const WalletBalance = (props: Props) => {
))}
</tbody>
</table>
{(!accountTransactions || accountTransactions.length === 0) && <p style={{textAlign:"center", marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
{(!accountTransactions || accountTransactions.length === 0) && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
</div>
</>
}
@ -207,7 +191,7 @@ const WalletBalance = (props: Props) => {
))}
</tbody>
</table>
{(!subscriptions || subscriptions.length === 0) && <p style={{textAlign:"center", marginTop: '22px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Subscriptions</p>}
{(!subscriptions || subscriptions.length === 0) && <p style={{textAlign: 'center', marginTop: '22px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Subscriptions</p>}
</div>
</>
}

View file

@ -8,7 +8,6 @@ import Page from 'component/page';
import { Lbryio } from 'lbryinc';
import { URL, WEBPACK_WEB_PORT, STRIPE_PUBLIC_KEY } from 'config';
import moment from 'moment';
const isDev = process.env.NODE_ENV !== 'production';
@ -186,7 +185,7 @@ class StripeAccountConnection extends React.Component<Props, State> {
unpaidBalance,
accountNotConfirmedButReceivedTips,
pageTitle,
accountTransactions,
// accountTransactions,
} = this.state;
const { user } = this.props;

View file

@ -6,14 +6,12 @@ import Page from 'component/page';
import Card from 'component/common/card';
import { Lbryio } from 'lbryinc';
import { STRIPE_PUBLIC_KEY } from 'config';
import moment from 'moment';
import Plastic from 'react-plastic';
import Button from 'component/button';
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
let stripeEnvironment = 'test';
// if the key contains pk_live it's a live key
// update the environment for the calls to the backend to indicate which environment to hit
@ -370,7 +368,7 @@ class SettingsStripeCard extends React.Component<Props, State> {
const { scriptFailedToLoad, openModal } = this.props;
const { currentFlowStage, customerTransactions, pageTitle, userCardDetails, paymentMethodId } = this.state;
const { currentFlowStage, pageTitle, userCardDetails, paymentMethodId } = this.state;
return (
<Page backout={{ title: pageTitle, backLabel: __('Done') }} noFooter noSideNavigation>

View file

@ -21,8 +21,7 @@ type Props = {
const WalletPage = (props: Props) => {
console.log(props);
var stripeEnvironment = 'test';
var environment = 'test';
const stripeEnvironment = 'test';
const tab = new URLSearchParams(props.location.search).get('tab');
@ -31,7 +30,6 @@ const WalletPage = (props: Props) => {
const [customerTransactions, setCustomerTransactions] = React.useState();
const [totalTippedAmount, setTotalTippedAmount] = React.useState(0);
function getPaymentHistory() {
return Lbryio.call(
'customer',
@ -40,18 +38,18 @@ const WalletPage = (props: Props) => {
environment: stripeEnvironment,
},
'post'
)};
); };
function getCustomerStatus(){
return Lbryio.call(
'customer',
'status',
{
environment: stripeEnvironment,
},
'post'
)
}
// function getCustomerStatus() {
// return Lbryio.call(
// 'customer',
// 'status',
// {
// environment: stripeEnvironment,
// },
// 'post'
// );
// }
function getAccountStatus() {
return Lbryio.call(
@ -75,7 +73,6 @@ const WalletPage = (props: Props) => {
);
}
// calculate account transactions section
React.useEffect(() => {
(async function() {
@ -87,8 +84,7 @@ const WalletPage = (props: Props) => {
// TODO: some weird naming clash hence getAccountTransactionsa
const getAccountTransactions = await getAccountTransactionsa();
setAccountTransactionResponse(getAccountTransactions)
setAccountTransactionResponse(getAccountTransactions);
} catch (err) {
console.log(err);
}
@ -105,13 +101,12 @@ const WalletPage = (props: Props) => {
let totalTippedAmount = 0;
for (const transaction of customerTransactionResponse) {
totalTippedAmount = totalTippedAmount + transaction.tipped_amount
totalTippedAmount = totalTippedAmount + transaction.tipped_amount;
}
setTotalTippedAmount(totalTippedAmount / 100);
setCustomerTransactions(customerTransactionResponse)
setCustomerTransactions(customerTransactionResponse);
} catch (err) {
console.log(err);
}
@ -126,7 +121,6 @@ const WalletPage = (props: Props) => {
document.getElementsByClassName('lbc-tab-switcher')[0].style.textDecoration = 'underline';
document.getElementsByClassName('fiat-tab-switcher')[0].style.textDecoration = 'none';
document.getElementsByClassName('fiat-payment-history-switcher')[0].style.textDecoration = 'none';
}
function focusAccountHistoryTab() {
@ -137,7 +131,6 @@ const WalletPage = (props: Props) => {
document.getElementsByClassName('lbc-tab-switcher')[0].style.textDecoration = 'none';
document.getElementsByClassName('fiat-tab-switcher')[0].style.textDecoration = 'underline';
document.getElementsByClassName('fiat-payment-history-switcher')[0].style.textDecoration = 'none';
}
function focusPaymentHistoryTab() {
@ -148,7 +141,6 @@ const WalletPage = (props: Props) => {
document.getElementsByClassName('lbc-tab-switcher')[0].style.textDecoration = 'none';
document.getElementsByClassName('fiat-tab-switcher')[0].style.textDecoration = 'none';
document.getElementsByClassName('fiat-payment-history-switcher')[0].style.textDecoration = 'underline';
}
// select the first tab
@ -160,7 +152,7 @@ const WalletPage = (props: Props) => {
// } else if (1 === 2){
focusPaymentHistoryTab();
} else {
focusLBCTab()
focusLBCTab();
}
}, []);
@ -220,14 +212,14 @@ const WalletPage = (props: Props) => {
{/* account received transactions section */}
<div className="fiat-transactions" style={{display: 'none'}}>
<WalletFiatBalance accountDetails={accountStatusResponse} />
<div style={{paddingTop: '25px'}}></div>
<div style={{paddingTop: '25px'}} />
<WalletFiatAccountHistory transactions={accountTransactionResponse} />
</div>
{/* fiat payment history for tips made by user */}
<div className="payment-history-tab" style={{display: 'none'}}>
<WalletFiatPaymentBalance transactions={customerTransactions} totalTippedAmount={totalTippedAmount} accountDetails={accountStatusResponse} />
<div style={{paddingTop: '25px'}}></div>
<div style={{paddingTop: '25px'}} />
<WalletFiatPaymentHistory transactions={customerTransactions} />
</div>