Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ (typescript) convert CategoryTransactions.jsx to .tsx #3875

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { listen } from 'loot-core/platform/client/fetch';
import * as monthUtils from 'loot-core/shared/months';
import { q } from 'loot-core/shared/query';
import { isPreviewId } from 'loot-core/shared/transactions';
import {
type TransactionEntity,
type CategoryEntity,
} from 'loot-core/src/types/models';

import { useDateFormat } from '../../../hooks/useDateFormat';
import { useNavigate } from '../../../hooks/useNavigate';
Expand All @@ -21,15 +25,23 @@ import { MobileBackButton } from '../MobileBackButton';
import { AddTransactionButton } from '../transactions/AddTransactionButton';
import { TransactionListWithBalances } from '../transactions/TransactionListWithBalances';

export function CategoryTransactions({ category, month }) {
type CategoryTransactionsProps = {
category: CategoryEntity;
month: string;
};

export function CategoryTransactions({
category,
month,
}: CategoryTransactionsProps) {
const dispatch = useDispatch();
const navigate = useNavigate();

const baseTransactionsQuery = useCallback(
() =>
q('transactions')
.options({ splits: 'inline' })
.filter(getCategoryMonthFilter(category, month))
.filter(getCategoryMonthFilter({ category, month }))
.select('*'),
[category, month],
);
Expand Down Expand Up @@ -73,7 +85,7 @@ export function CategoryTransactions({ category, month }) {
});

const onOpenTransaction = useCallback(
transaction => {
(transaction: TransactionEntity) => {
// details of how the native app used to handle preview transactions here can be found at commit 05e58279
if (!isPreviewId(transaction.id)) {
navigate(`/transactions/${transaction.id}`);
Expand Down Expand Up @@ -119,7 +131,13 @@ export function CategoryTransactions({ category, month }) {
);
}

function getCategoryMonthFilter(category, month) {
function getCategoryMonthFilter({
category,
month,
}: {
category: CategoryEntity;
month: string;
}) {
return {
category: category.id,
date: { $transform: '$month', $eq: month },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function TransactionListWithBalances({
onSearch,
onLoadMore,
onOpenTransaction,
onRefresh,
onRefresh = () => {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be undefined as default because there's logic below which checks for this prop. Setting an empty function will introduce a regression.

}) {
const selectedInst = useSelected('transactions', transactions);

Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3875.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [cindywu]
---

Convert CategoryTransactions.jsx to tsx
Loading