Skip to content

Commit

Permalink
Add Model clear, and link transactions automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
xentara1 committed Jan 17, 2024
1 parent 2e937ec commit 3e17d1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export function ScheduleLink({
actions: BoundActions;
modalProps?: CommonModalProps;
transactionIds: string[];
getTransaction: (a: string) => TransactionEntity;
pushModal: (a: string, b: ModalParams) => void;
getTransaction: (tranID: string) => TransactionEntity;
pushModal: (name: string, params: ModalParams) => void;
}) {
const [filter, setFilter] = useState('');

Expand All @@ -56,11 +56,10 @@ export function ScheduleLink({
actions.popModal();
}
async function onCreate() {
const firstId1 = [...ids][0];
actions.popModal();
pushModal('schedule-edit', {
id: null,
transaction: getTransaction(firstId1),
transaction: getTransaction(ids[0]),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export function SelectedTransactionsButton({
case 'link-schedule':
pushModal('schedule-link', {
transactionIds: [...selectedItems],
getTransaction : getTransaction,
pushModal: pushModal,
getTransaction,
pushModal,
});
break;
case 'unlink-schedule':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, useCallback, useMemo } from 'react';
import React, { memo, useCallback, useEffect, useMemo } from 'react';
import { useSelector } from 'react-redux';

import {
Expand Down Expand Up @@ -156,11 +156,19 @@ export function SimpleTransactionsTable({
transactions = transactions.map(trans =>
serializeTransaction(trans, dateFormat),
);
const selected = transactions.filter(x => x.selected).map(x => x.id);
selected.forEach(x => dispatchSelected({ type: 'select', id: x }));
return transactions;
}, [transactions]);

useEffect(() => {
const selected = transactions.filter(x => x.selected).map(x => x.id);
//Type Select will toggle the record
//On init this class is called twice,(due to the memoization
//So we check if it is selected before we dispatch.
selected.forEach(
x => !selectedItems.has(x) && dispatchSelected({ type: 'select', id: x }),
);
}, [transactions]);

const renderItem = useCallback(
({ item }) => {
return (
Expand Down

0 comments on commit 3e17d1f

Please sign in to comment.