Skip to content

Commit

Permalink
fix weird transaction positions editing
Browse files Browse the repository at this point in the history
  • Loading branch information
mikonse committed May 8, 2022
1 parent 7859f27 commit 9751e37
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions web/src/components/transactions/purchase/PurchaseItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,17 @@ export default function PurchaseItems({ group, transaction }: PropTypes) {
const [positions, setPositions] = useState([]);

useEffect(() => {
setPositions(transaction.positions
.map((p) => ({ ...p, is_empty: false }))
.concat([
{
...localPositionChanges.empty,
is_empty: true,
},
]));
}, [transaction, setPositions, localPositionChanges])
setPositions(
transaction.positions
.map((p) => ({ ...p, is_empty: false }))
.concat([
{
...localPositionChanges.empty,
is_empty: true,
},
])
);
}, [transaction, setPositions, localPositionChanges]);

// find all accounts that take part in the transaction, either via debitor shares or purchase items
// TODO: should we add creditor accounts as well?
Expand Down Expand Up @@ -542,7 +544,7 @@ export default function PurchaseItems({ group, transaction }: PropTypes) {
</TableHead>
<TableBody>
{transaction.is_wip
? positions.map(position => (
? positions.map((position) => (
<TableRow hover key={position.id}>
<PositionTableRow
position={position}
Expand All @@ -558,7 +560,7 @@ export default function PurchaseItems({ group, transaction }: PropTypes) {
</TableRow>
))
: positions.map(
position =>
(position) =>
!position.is_empty && (
<TableRow hover key={position.id}>
<TableCell>{position.name}</TableCell>
Expand Down

0 comments on commit 9751e37

Please sign in to comment.