Skip to content

Commit

Permalink
Mobile category transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Mar 31, 2024
1 parent 38ffccb commit 477e8dc
Show file tree
Hide file tree
Showing 19 changed files with 650 additions and 429 deletions.
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { DevelopmentTopBar } from './DevelopmentTopBar';
import { FatalError } from './FatalError';
import { FinancesApp } from './FinancesApp';
import { ManagementApp } from './manager/ManagementApp';
import { MobileWebMessage } from './MobileWebMessage';
import { MobileWebMessage } from './mobile/MobileWebMessage';
import { UpdateNotification } from './UpdateNotification';

type AppInnerProps = {
Expand Down
15 changes: 4 additions & 11 deletions packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { BudgetMonthCountProvider } from './budget/BudgetMonthCountContext';
import { View } from './common/View';
import { GlobalKeys } from './GlobalKeys';
import { ManageRulesPage } from './ManageRulesPage';
import { Category } from './mobile/budget/Category';
import { MobileNavTabs } from './mobile/MobileNavTabs';
import { TransactionEdit } from './mobile/transactions/TransactionEdit';
import { Modals } from './Modals';
Expand Down Expand Up @@ -210,7 +211,7 @@ function FinancesAppWithoutContext() {
/>

<Route
path="/accounts/:id/transactions/:transactionId"
path="/transactions/:transactionId"
element={
<WideNotSupported>
<TransactionEdit />
Expand All @@ -219,18 +220,10 @@ function FinancesAppWithoutContext() {
/>

<Route
path="/accounts/:id/transactions/new"
path="/categories/:id"
element={
<WideNotSupported>
<TransactionEdit />
</WideNotSupported>
}
/>
<Route
path="/transactions/new"
element={
<WideNotSupported>
<TransactionEdit />
<Category />
</WideNotSupported>
}
/>
Expand Down
42 changes: 8 additions & 34 deletions packages/desktop-client/src/components/accounts/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import { bindActionCreators } from 'redux';
import { validForTransfer } from 'loot-core/client/transfer';
import * as actions from 'loot-core/src/client/actions';
import { useFilters } from 'loot-core/src/client/data-hooks/filters';
import {
SchedulesProvider,
useCachedSchedules,
} from 'loot-core/src/client/data-hooks/schedules';
import { SchedulesProvider } from 'loot-core/src/client/data-hooks/schedules';
import * as queries from 'loot-core/src/client/queries';
import { runQuery, pagedQuery } from 'loot-core/src/client/query-helpers';
import { send, listen } from 'loot-core/src/platform/client/fetch';
Expand All @@ -33,6 +30,7 @@ import { useDateFormat } from '../../hooks/useDateFormat';
import { useFailedAccounts } from '../../hooks/useFailedAccounts';
import { useLocalPref } from '../../hooks/useLocalPref';
import { usePayees } from '../../hooks/usePayees';
import { usePreviewTransactions } from '../../hooks/usePreviewTransactions';
import { SelectedProviderWithItems } from '../../hooks/useSelected';
import {
SplitsExpandedProvider,
Expand Down Expand Up @@ -94,38 +92,14 @@ function AllTransactions({
filtered,
children,
}) {
const { id: accountId } = account;
const scheduleData = useCachedSchedules();
const accountId = account.id;
const prependTransactions = usePreviewTransactions().map(trans => ({
...trans,
_inverse: accountId ? accountId !== trans.account : false,
}));

transactions ??= [];

const schedules = useMemo(
() =>
scheduleData
? scheduleData.schedules.filter(
s =>
!s.completed &&
['due', 'upcoming', 'missed'].includes(
scheduleData.statuses.get(s.id),
),
)
: [],
[scheduleData],
);

const prependTransactions = useMemo(() => {
return schedules.map(schedule => ({
id: `preview/${schedule.id}`,
payee: schedule._payee,
account: schedule._account,
amount: schedule._amount,
date: schedule.next_date,
notes: scheduleData.statuses.get(schedule.id),
schedule: schedule.id,
_inverse: accountId ? accountId !== schedule._account : false,
}));
}, [schedules, accountId]);

let runningBalance = useMemo(() => {
if (!showBalances) {
return 0;
Expand Down Expand Up @@ -172,7 +146,7 @@ function AllTransactions({
return balances;
}, [filtered, prependBalances, balances]);

if (scheduleData == null) {
if (!prependTransactions) {
return children(transactions, balances);
}
return children(allTransactions, allBalances);
Expand Down
4 changes: 3 additions & 1 deletion packages/desktop-client/src/components/common/ButtonLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { Button } from './Button';
type ButtonLinkProps = ComponentProps<typeof Button> & {
to: string;
activeStyle?: CSSProperties;
state?: Record<string, unknown>;
};
export function ButtonLink({
to,
style,
activeStyle,
state,
...props
}: ButtonLinkProps) {
const navigate = useNavigate();
Expand All @@ -28,7 +30,7 @@ export function ButtonLink({
{...props}
onClick={e => {
props.onClick?.(e);
navigate(to);
navigate(to, { state });
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';

import { useNavigate } from '../hooks/useNavigate';
import { SvgCheveronLeft } from '../icons/v1';
import { type CSSProperties, styles, theme } from '../style';

import { Button } from './common/Button';
import { Text } from './common/Text';
import { useNavigate } from '../../hooks/useNavigate';
import { SvgCheveronLeft } from '../../icons/v1';
import { type CSSProperties, styles, theme } from '../../style';
import { Button } from '../common/Button';
import { Text } from '../common/Text';

type MobileBackButtonProps = {
style?: CSSProperties;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { useState } from 'react';

import { useLocalPref } from '../hooks/useLocalPref';
import { useResponsive } from '../ResponsiveProvider';
import { theme, styles } from '../style';

import { Button } from './common/Button';
import { Text } from './common/Text';
import { View } from './common/View';
import { Checkbox } from './forms';
import { useLocalPref } from '../../hooks/useLocalPref';
import { useResponsive } from '../../ResponsiveProvider';
import { theme, styles } from '../../style';
import { Button } from '../common/Button';
import { Text } from '../common/Text';
import { View } from '../common/View';
import { Checkbox } from '../forms';

const buttonStyle = { border: 0, fontSize: 15, padding: '10px 13px' };

Expand Down
Loading

0 comments on commit 477e8dc

Please sign in to comment.