Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
carkom committed Jan 7, 2024
1 parent a4fd9f0 commit 3e05089
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 132 deletions.
23 changes: 12 additions & 11 deletions packages/desktop-client/src/components/reports/ChooseGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { LineGraph } from './graphs/LineGraph';
import { StackedBarGraph } from './graphs/StackedBarGraph';
import { ReportTable } from './graphs/tableGraph/ReportTable';
import { ReportTableHeader } from './graphs/tableGraph/ReportTableHeader';
import { ReportTableList } from './graphs/tableGraph/ReportTableList';
import { ReportTableTotals } from './graphs/tableGraph/ReportTableTotals';
import { ReportOptions } from './ReportOptions';

Expand Down Expand Up @@ -39,6 +38,12 @@ export function ChooseGraph({
months,
}: ChooseGraphProps) {
const balanceTypeOp = ReportOptions.balanceTypeMap.get(balanceType);
const groupByData =
groupBy === 'Category'
? 'groupedData'
: ['Month', 'Year'].includes(groupBy)
? 'monthData'
: 'data';

const saveScrollWidth = value => {
setScrollWidth(!value ? 0 : value);
Expand Down Expand Up @@ -116,16 +121,12 @@ export function ChooseGraph({
saveScrollWidth={saveScrollWidth}
listScrollRef={listScrollRef}
handleScroll={handleScroll}
>
<ReportTableList
data={data}
empty={showEmpty}
monthsCount={months.length}
balanceTypeOp={balanceTypeOp}
mode={mode}
groupBy={groupBy}
/>
</ReportTable>
balanceTypeOp={balanceTypeOp}
groupBy={groupBy}
data={data[groupByData]}
mode={mode}
monthsCount={months.length}
/>
<ReportTableTotals
totalScrollRef={totalScrollRef}
handleScroll={handleScroll}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import React, {
import { type RefProp } from 'react-spring';

import { type CSSProperties } from '../../../../style';
import Block from '../../../common/Block';
import View from '../../../common/View';
import { Block } from '../../../common/Block';
import { View } from '../../../common/View';
import { type GroupedEntity } from '../../entities';

import { ReportTableList } from './ReportTableList';
Expand All @@ -26,7 +26,7 @@ type ReportTableProps = {
monthsCount: number;
};

export default function ReportTable({
export function ReportTable({
saveScrollWidth,
listScrollRef,
handleScroll,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { type CSSProperties, theme } from '../../../../style';
import View from '../../../common/View';
import { View } from '../../../common/View';
import { Cell, Row } from '../../../table';
import { type GroupedEntity } from '../../entities';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ import {
integerToCurrency,
} from 'loot-core/src/shared/util';

<<<<<<<< HEAD:packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
import { styles, theme } from '../../../../style';
import { Row, Cell } from '../../../table';
import { type GroupedEntity } from '../../entities';
========
import { type CSSProperties, styles, theme } from '../../../../style';
import { View } from '../../../common/View';
import { Row, Cell } from '../../../table';
>>>>>>>> upstream/master:packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx

type ReportTableRowProps = {
item: GroupedEntity;
Expand Down Expand Up @@ -135,114 +129,3 @@ export const ReportTableRow = memo(
);
},
);
<<<<<<<< HEAD:packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
========

function GroupedTableRow({
item,
balanceTypeOp,
groupByItem,
mode,
monthsCount,
empty,
}) {
return (
<>
<TableRow
key={item.id}
item={item}
balanceTypeOp={balanceTypeOp}
groupByItem={groupByItem}
mode={mode}
monthsCount={monthsCount}
style={{
color: theme.tableRowHeaderText,
backgroundColor: theme.tableRowHeaderBackground,
fontWeight: 600,
}}
/>
<View>
{item.categories
.filter(i =>
!empty
? balanceTypeOp === 'totalTotals'
? i.totalAssets !== 0 ||
i.totalDebts !== 0 ||
i.totalTotals !== 0
: i[balanceTypeOp] !== 0
: true,
)
.map(cat => {
return (
<TableRow
key={cat.id}
item={cat}
balanceTypeOp={balanceTypeOp}
groupByItem={groupByItem}
mode={mode}
monthsCount={monthsCount}
/>
);
})}
</View>
<Row height={20} />
</>
);
}

export function ReportTableList({
data,
empty,
monthsCount,
balanceTypeOp,
mode,
groupBy,
}) {
const groupByItem = ['Month', 'Year'].includes(groupBy) ? 'date' : 'name';
const groupByData =
groupBy === 'Category'
? 'groupedData'
: ['Month', 'Year'].includes(groupBy)
? 'monthData'
: 'data';

return (
<View>
{data[groupByData]
.filter(i =>
!empty
? balanceTypeOp === 'totalTotals'
? i.totalAssets !== 0 || i.totalDebts !== 0 || i.totalTotals !== 0
: i[balanceTypeOp] !== 0
: true,
)
.map(item => {
if (groupBy === 'Category') {
return (
<GroupedTableRow
key={item.id}
item={item}
balanceTypeOp={balanceTypeOp}
groupByItem={groupByItem}
mode={mode}
monthsCount={monthsCount}
empty={empty}
/>
);
} else {
return (
<TableRow
key={item.id}
item={item}
balanceTypeOp={balanceTypeOp}
groupByItem={groupByItem}
mode={mode}
monthsCount={monthsCount}
/>
);
}
})}
</View>
);
}
>>>>>>>> upstream/master:packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx

0 comments on commit 3e05089

Please sign in to comment.