<commit_before>import React from 'react';
import {formatMoney} from '../utilities';
import {
    popupHistory
  } from '../../redux/actions';
import {
    fetchAccounts
} from '../../redux/services';

function makeTotalsRow(props){
    var {balance=0, pendingTotal=0, dueTotal=0, assetsTotal=0, debts=0, debtsTotal=0, updating} = props;
    //console.log(props);
    const currentBalance = localStorage.getItem('currentBalance');
    if(currentBalance){
      balance = currentBalance;
    }
    const onClickBalance = (e) => {
        e.preventDefault();
        var cb = prompt("Current Balance", currentBalance || balance);
        if(!cb){
            return;
        }
        cb = cb.replace(/\$|,/g, '');
        localStorage.setItem('currentBalance', cb);
        document.location.reload();
      };
    return (
        <div className="column totals">
            <a className="button totals">
                <table className="u-full-width">
                <tbody>
                    <tr className="header">
                        <td colSpan="2" className="title center">Current</td>
                    </tr>
                    <tr className="header"
                        onClick={onClickBalance}
                        onContextMenu={updating ? ()=>{} : onClickBalance}

                    >
                        <td className="title">Balance</td>
                        <td className="status">{formatMoney(balance)}</td>
                    </tr>
                    { Boolean(Number(pendingTotal)) &&
                    <tr className="header">
                        <td className="title">Pending</td>
                        <td className="status">{formatMoney(pendingTotal)}</td>
                    </tr>
                    }
                    { Boolean(Number(dueTotal)) &&
                    <tr className="header">
                        <td className="title">Due</td>
                        <td className="status">{formatMoney(dueTotal)}</td>
                    </tr>
                    }
                    <tr className="header">
                        <td className="title"></td>
                        <td className="status">{formatMoney(balance - pendingTotal - dueTotal)}</td>
                    </tr>
                    <tr className="header">
                        <td colSpan="2" className="title center">
                            <button
                                className='balance-update-button'
                                onClick={updating ? ()=>{} : fetchAccounts}
                            >{
                                updating
                                    ? <i className="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
                                    : 'Update'
                            }</button>
                        </td>
                    </tr>
                </tbody>
                </table>
            </a>
            <a className="button totals">
                <table className="u-full-width">
                <tbody>
                    <tr className="header">
                        <td colSpan="2" className="title center">Monthly</td>
                    </tr>
                    <tr className="header">
                        <td className="title">Assets</td>
                        <td className="status">{formatMoney(assetsTotal)}</td>
                    </tr>
                    <tr className="header">
                        <td className="title">Debt</td>
                        <td className="status">{formatMoney(debts)}</td>
                    </tr><commit_msg>try try again with getting balance updated<commit_after>import React from 'react';
import {formatMoney} from '../utilities';
import {
    popupHistory
  } from '../../redux/actions';
import {
    fetchAccounts
} from '../../redux/services';

function makeTotalsRow(props){
    var {balance=0, pendingTotal=0, dueTotal=0, assetsTotal=0, debts=0, debtsTotal=0, updating} = props;
    //console.log(props);
    const currentBalance = localStorage.getItem('currentBalance');
    if(currentBalance){
      balance = currentBalance;
    }
    const onClickBalance = (e) => {
        e.preventDefault();
        var cb = prompt("Current Balance", currentBalance || balance);
        if(!cb){
            return;
        }
        cb = cb.replace(/\$|,/g, '');
        localStorage.setItem('currentBalance', cb);
        document.location.reload();
      };
    return (
        <div className="column totals">
            <a className="button totals">
                <table className="u-full-width">
                <tbody>
                    <tr className="header">
                        <td colSpan="2" className="title center">Current</td>
                    </tr>
                    <tr className="header"
                        onClick={onClickBalance}
                        onContextMenu={onClickBalance}
                    >
                        <td className="title">Balance</td>
                        <td className="status">{formatMoney(balance)}</td>
                    </tr>
                    { Boolean(Number(pendingTotal)) &&
                    <tr className="header">
                        <td className="title">Pending</td>
                        <td className="status">{formatMoney(pendingTotal)}</td>
                    </tr>
                    }
                    { Boolean(Number(dueTotal)) &&
                    <tr className="header">
                        <td className="title">Due</td>
                        <td className="status">{formatMoney(dueTotal)}</td>
                    </tr>
                    }
                    <tr className="header">
                        <td className="title"></td>
                        <td className="status">{formatMoney(balance - pendingTotal - dueTotal)}</td>
                    </tr>
                    <tr className="header">
                        <td colSpan="2" className="title center">
                            <button
                                className='balance-update-button'
                                onClick={onClickBalance}
                                // onClick={updating ? ()=>{} : fetchAccounts}
                            >{
                                updating
                                    ? <i className="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
                                    : 'Update'
                            }</button>
                        </td>
                    </tr>
                </tbody>
                </table>
            </a>
            <a className="button totals">
                <table className="u-full-width">
                <tbody>
                    <tr className="header">
                        <td colSpan="2" className="title center">Monthly</td>
                    </tr>
                    <tr className="header">
                        <td className="title">Assets</td>
                        <td className="status">{formatMoney(assetsTotal)}</td>
                    </tr>
                    <tr className="header">
                        <td className="title">Debt</td>
                        <td className="status">{formatMoney(debts)}</td>
                    </tr>
{'fraction_non_alphanumeric': 0.12837094111172262, 'fraction_numerical': 0.00275178866263071, 'mean_word_length': 1.160820451843044, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 132, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5509610', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1661, 'n_words': 313}