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

[Mobile]: More functionalities #2472

Merged
merged 35 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
db83253
Balance modals
joel-jeremy Mar 17, 2024
238a9de
Release notes
joel-jeremy Mar 17, 2024
849d864
Fix typecheck errors
joel-jeremy Mar 17, 2024
b350fde
Fix errors
joel-jeremy Mar 18, 2024
5f481f7
Mobile scheduled transaction modal
joel-jeremy Mar 18, 2024
8e49824
Cleanup
joel-jeremy Mar 18, 2024
1992f77
Fix props
joel-jeremy Mar 18, 2024
725dd14
Fix typecheck errors
joel-jeremy Mar 18, 2024
c141a19
Updates
joel-jeremy Mar 18, 2024
033759c
Fix autocomplete typings
joel-jeremy Mar 19, 2024
e596360
Update autocomplete types
joel-jeremy Mar 19, 2024
e732d12
Fix typecheck errors
joel-jeremy Mar 20, 2024
3168755
Fix typecheck errors
joel-jeremy Mar 20, 2024
7f3543d
Remote optional type
joel-jeremy Mar 20, 2024
2507561
Pass this to apply
joel-jeremy Mar 20, 2024
919fbce
Use bind
joel-jeremy Mar 20, 2024
5b416f3
Fix typecheck error
joel-jeremy Mar 20, 2024
6c40ff3
Ignore typecheck error for now
joel-jeremy Mar 20, 2024
ca7f5b8
Add onClose in Autocomplete
joel-jeremy Mar 20, 2024
9bd4778
open category modal on enter in transfer modal
joel-jeremy Mar 20, 2024
a680417
Budget summary modals
joel-jeremy Mar 20, 2024
f142e37
Accounts update
joel-jeremy Mar 21, 2024
7617c94
Add paddingBottom
joel-jeremy Mar 21, 2024
1fcb9ef
Fix typecheck error
joel-jeremy Mar 21, 2024
43b20c3
Revert navigate
joel-jeremy Mar 21, 2024
66f8c18
Disable esline
joel-jeremy Mar 21, 2024
4ed9781
Close account and Reopen account
joel-jeremy Mar 21, 2024
f4b062d
Improve SingleInputModal
joel-jeremy Mar 22, 2024
abf68f3
Fix lint error
joel-jeremy Mar 22, 2024
e9d0a4a
Fix category autocomplete modal header
joel-jeremy Mar 22, 2024
e14ede9
Rebase updates
joel-jeremy Mar 24, 2024
db44102
Cleanup
joel-jeremy Mar 27, 2024
66e4225
Clearer error message
joel-jeremy Apr 3, 2024
dfb61b0
Close report balance tooltip on selection
joel-jeremy Apr 4, 2024
2ae6d8c
Updated based on review
joel-jeremy Apr 4, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
198 changes: 180 additions & 18 deletions packages/desktop-client/src/components/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ import { useLocation } from 'react-router-dom';
import { type State } from 'loot-core/src/client/state-types';
import { type PopModalAction } from 'loot-core/src/client/state-types/modals';
import { send } from 'loot-core/src/platform/client/fetch';
import * as monthUtils from 'loot-core/src/shared/months';

import { useActions } from '../hooks/useActions';
import { useSyncServerStatus } from '../hooks/useSyncServerStatus';

import { CategoryGroupMenu } from './modals/CategoryGroupMenu';
import { CategoryMenu } from './modals/CategoryMenu';
import { CloseAccount } from './modals/CloseAccount';
import { AccountAutocompleteModal } from './modals/AccountAutocompleteModal';
import { AccountMenuModal } from './modals/AccountMenuModal';
import { CategoryAutocompleteModal } from './modals/CategoryAutocompleteModal';
import { CategoryGroupMenuModal } from './modals/CategoryGroupMenuModal';
import { CategoryMenuModal } from './modals/CategoryMenuModal';
import { CloseAccountModal } from './modals/CloseAccountModal';
import { ConfirmCategoryDelete } from './modals/ConfirmCategoryDelete';
import { ConfirmTransactionEdit } from './modals/ConfirmTransactionEdit';
import { ConfirmUnlinkAccount } from './modals/ConfirmUnlinkAccount';
import { CoverModal } from './modals/CoverModal';
import { CreateAccount } from './modals/CreateAccount';
import { CreateEncryptionKey } from './modals/CreateEncryptionKey';
import { CreateLocalAccount } from './modals/CreateLocalAccount';
Expand All @@ -24,22 +29,30 @@ import { EditRule } from './modals/EditRule';
import { FixEncryptionKey } from './modals/FixEncryptionKey';
import { GoCardlessExternalMsg } from './modals/GoCardlessExternalMsg';
import { GoCardlessInitialise } from './modals/GoCardlessInitialise';
import { HoldBufferModal } from './modals/HoldBufferModal';
import { ImportTransactions } from './modals/ImportTransactions';
import { LoadBackup } from './modals/LoadBackup';
import { ManageRulesModal } from './modals/ManageRulesModal';
import { MergeUnusedPayees } from './modals/MergeUnusedPayees';
import { Notes } from './modals/Notes';
import { PayeeAutocompleteModal } from './modals/PayeeAutocompleteModal';
import { PlaidExternalMsg } from './modals/PlaidExternalMsg';
import { ReportBudgetSummary } from './modals/ReportBudgetSummary';
import { RolloverBudgetSummary } from './modals/RolloverBudgetSummary';
import { ReportBalanceMenuModal } from './modals/ReportBalanceMenuModal';
import { ReportBudgetSummaryModal } from './modals/ReportBudgetSummaryModal';
import { RolloverBalanceMenuModal } from './modals/RolloverBalanceMenuModal';
import { RolloverBudgetSummaryModal } from './modals/RolloverBudgetSummaryModal';
import { RolloverToBudgetMenuModal } from './modals/RolloverToBudgetMenuModal';
import { ScheduledTransactionMenuModal } from './modals/ScheduledTransactionMenuModal';
import { SelectLinkedAccounts } from './modals/SelectLinkedAccounts';
import { SimpleFinInitialise } from './modals/SimpleFinInitialise';
import { SingleInput } from './modals/SingleInput';
import { SingleInputModal } from './modals/SingleInputModal';
import { SwitchBudgetType } from './modals/SwitchBudgetType';
import { TransferModal } from './modals/TransferModal';
import { DiscoverSchedules } from './schedules/DiscoverSchedules';
import { PostsOfflineNotification } from './schedules/PostsOfflineNotification';
import { ScheduleDetails } from './schedules/ScheduleDetails';
import { ScheduleLink } from './schedules/ScheduleLink';
import { NamespaceContext } from './spreadsheet/NamespaceContext';

export type CommonModalProps = {
onClose: () => PopModalAction;
Expand Down Expand Up @@ -97,12 +110,11 @@ export function Modals() {

case 'close-account':
return (
<CloseAccount
<CloseAccountModal
modalProps={modalProps}
account={options.account}
balance={options.balance}
canDelete={options.canDelete}
actions={actions}
/>
);

Expand Down Expand Up @@ -255,9 +267,51 @@ export function Modals() {
/>
);

case 'category-autocomplete':
return (
<CategoryAutocompleteModal
key={name}
modalProps={modalProps}
autocompleteProps={{
value: null,
categoryGroups: options.categoryGroups,
onSelect: options.onSelect,
showHiddenCategories: options.showHiddenCategories,
}}
onClose={options.onClose}
/>
);

case 'account-autocomplete':
return (
<AccountAutocompleteModal
key={name}
modalProps={modalProps}
autocompleteProps={{
value: null,
onSelect: options.onSelect,
includeClosedAccounts: options.includeClosedAccounts,
}}
onClose={options.onClose}
/>
);

case 'payee-autocomplete':
return (
<PayeeAutocompleteModal
key={name}
modalProps={modalProps}
autocompleteProps={{
value: null,
onSelect: options.onSelect,
}}
onClose={options.onClose}
/>
);

case 'new-category':
return (
<SingleInput
<SingleInputModal
modalProps={modalProps}
title="New Category"
inputPlaceholder="Category name"
Expand All @@ -269,7 +323,7 @@ export function Modals() {

case 'new-category-group':
return (
<SingleInput
<SingleInputModal
modalProps={modalProps}
title="New Category Group"
inputPlaceholder="Category group name"
Expand All @@ -281,17 +335,22 @@ export function Modals() {

case 'rollover-budget-summary':
return (
<RolloverBudgetSummary
<NamespaceContext.Provider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to think about how to remove the need to wrap modal components with this in order for useSheetValue to work. By default, there is no namespace context for any of our modals.

key={name}
modalProps={modalProps}
month={options.month}
onBudgetAction={options.onBudgetAction}
/>
value={monthUtils.sheetForMonth(options.month)}
>
<RolloverBudgetSummaryModal
key={name}
modalProps={modalProps}
month={options.month}
onBudgetAction={options.onBudgetAction}
/>
</NamespaceContext.Provider>
);

case 'report-budget-summary':
return (
<ReportBudgetSummary
<ReportBudgetSummaryModal
key={name}
modalProps={modalProps}
month={options.month}
Expand Down Expand Up @@ -348,9 +407,23 @@ export function Modals() {
/>
);

case 'account-menu':
return (
<AccountMenuModal
key={name}
modalProps={modalProps}
accountId={options.accountId}
onSave={options.onSave}
onEditNotes={options.onEditNotes}
onCloseAccount={options.onCloseAccount}
onReopenAccount={options.onReopenAccount}
onClose={options.onClose}
/>
);

case 'category-menu':
return (
<CategoryMenu
<CategoryMenuModal
key={name}
modalProps={modalProps}
categoryId={options.categoryId}
Expand All @@ -363,7 +436,7 @@ export function Modals() {

case 'category-group-menu':
return (
<CategoryGroupMenu
<CategoryGroupMenuModal
key={name}
modalProps={modalProps}
groupId={options.groupId}
Expand All @@ -387,6 +460,95 @@ export function Modals() {
/>
);

case 'rollover-balance-menu':
return (
<NamespaceContext.Provider
key={name}
value={monthUtils.sheetForMonth(options.month)}
>
<RolloverBalanceMenuModal
modalProps={modalProps}
categoryId={options.categoryId}
onCarryover={options.onCarryover}
onTransfer={options.onTransfer}
onCover={options.onCover}
/>
</NamespaceContext.Provider>
);

case 'rollover-to-budget-menu':
return (
<NamespaceContext.Provider
key={name}
value={monthUtils.sheetForMonth(options.month)}
>
<RolloverToBudgetMenuModal
modalProps={modalProps}
onTransfer={options.onTransfer}
onHoldBuffer={options.onHoldBuffer}
onResetHoldBuffer={options.onResetHoldBuffer}
/>
</NamespaceContext.Provider>
);

case 'hold-buffer':
return (
<NamespaceContext.Provider
key={name}
value={monthUtils.sheetForMonth(options.month)}
>
<HoldBufferModal
modalProps={modalProps}
month={options.month}
onSubmit={options.onSubmit}
/>
</NamespaceContext.Provider>
);

case 'report-balance-menu':
return (
<NamespaceContext.Provider
key={name}
value={monthUtils.sheetForMonth(options.month)}
>
<ReportBalanceMenuModal
modalProps={modalProps}
categoryId={options.categoryId}
onCarryover={options.onCarryover}
/>
</NamespaceContext.Provider>
);

case 'transfer':
return (
<TransferModal
modalProps={modalProps}
title={options.title}
amount={options.amount}
onSubmit={options.onSubmit}
showToBeBudgeted={options.showToBeBudgeted}
/>
);

case 'cover':
return (
<CoverModal
modalProps={modalProps}
categoryId={options.categoryId}
onSubmit={options.onSubmit}
/>
);

case 'scheduled-transaction-menu':
return (
<ScheduledTransactionMenuModal
modalProps={modalProps}
transactionId={options.transactionId}
onPost={options.onPost}
onSkip={options.onSkip}
/>
);

default:
console.error('Unknown modal:', name);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ type AccountItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
Copy link
Member

Choose a reason for hiding this comment

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

❓ question: ‏what's the plan with this? Do you plan on using it in the near future? If not - we can remove the export statement (which should solve the eslint issue).

Same question for the other files.

export function AccountItem({
item,
className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ type CategoryItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
export function CategoryItem({
item,
className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ type CreatePayeeButtonProps = {
style?: CSSProperties;
};

// eslint-disable-next-line import/no-unused-modules
export function CreatePayeeButton({
Icon,
payeeName,
Expand Down Expand Up @@ -471,6 +472,7 @@ type PayeeItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
export function PayeeItem({
item,
className,
Expand Down
7 changes: 6 additions & 1 deletion packages/desktop-client/src/components/budget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useLocalPref } from '../../hooks/useLocalPref';
import { useNavigate } from '../../hooks/useNavigate';
import { styles } from '../../style';
import { View } from '../common/View';
import { NamespaceContext } from '../spreadsheet/NamespaceContext';
import {
SWITCH_BUDGET_MESSAGE_TYPE,
TitlebarContext,
Expand Down Expand Up @@ -404,7 +405,11 @@ function BudgetInner(props: BudgetInnerProps) {
);
}

return <View style={{ flex: 1 }}>{table}</View>;
return (
<NamespaceContext.Provider value={monthUtils.sheetForMonth(startMonth)}>
<View style={{ flex: 1 }}>{table}</View>
</NamespaceContext.Provider>
);
}

const RolloverBudgetSummary = memo<{ month: string }>(props => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function BalanceMenu({
onCarryover?.(!carryover);
break;
default:
throw new Error(`Unsupported item: ${name}`);
throw new Error(`Unrecognized menu option: ${name}`);
}
}}
items={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function BalanceMenu({
onCover?.();
break;
default:
throw new Error(`Unsupported item: ${name}`);
throw new Error(`Unrecognized menu option: ${name}`);
}
}}
items={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type RolloverContextDefinition = {
currentMonth: string;
};

const Context = createContext<RolloverContextDefinition>({
const RolloverContext = createContext<RolloverContextDefinition>({
summaryCollapsed: false,
onBudgetAction: () => {
throw new Error('Unitialised context method called: onBudgetAction');
Expand All @@ -34,7 +34,7 @@ export function RolloverProvider({
const currentMonth = monthUtils.currentMonth();

return (
<Context.Provider
<RolloverContext.Provider
value={{
currentMonth,
summaryCollapsed,
Expand All @@ -43,10 +43,10 @@ export function RolloverProvider({
}}
>
{children}
</Context.Provider>
</RolloverContext.Provider>
);
}

export function useRollover() {
return useContext(Context);
return useContext(RolloverContext);
}
Loading
Loading