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

Maintenance: BudgetSummary & CreateLocalAccount to tsx #1768

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -8,7 +8,7 @@ type InlineFieldProps = {
label: ReactNode;
labelWidth?: number;
children?: ReactNode;
width: number;
width: number | string;
Copy link
Contributor Author

@MikesGlitch MikesGlitch Oct 7, 2023

Choose a reason for hiding this comment

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

width is being used as a string like:

width: '75%'

numbers are also valid. width: 100 would mean 100px

style?: CSSProperties;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';

import { rolloverBudget } from 'loot-core/src/client/queries';
import * as monthUtils from 'loot-core/src/shared/months';
Copy link
Contributor Author

@MikesGlitch MikesGlitch Oct 7, 2023

Choose a reason for hiding this comment

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

Only importing what's needed

import { format, sheetForMonth, prevMonth } from 'loot-core/src/shared/months';

import { theme, styles } from '../../style';
import { type CommonModalProps } from '../../types/modals';
import Button from '../common/Button';
import Modal from '../common/Modal';
import Text from '../common/Text';
Expand Down Expand Up @@ -35,13 +36,18 @@ function ToBudget({ toBudget }) {
);
}

function BudgetSummary({ month, modalProps }) {
const prevMonthName = monthUtils.format(monthUtils.prevMonth(month), 'MMM');
type BudgetSummaryProps = {
modalProps: CommonModalProps;
month: string;
};

function BudgetSummary({ month, modalProps }: BudgetSummaryProps) {
const prevMonthName = format(prevMonth(month), 'MMM');

return (
<Modal title="Budget Details" {...modalProps} animate>
<Modal title="Budget Details" {...modalProps}>
Copy link
Contributor Author

@MikesGlitch MikesGlitch Oct 7, 2023

Choose a reason for hiding this comment

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

Removed animate prop as it doesn't get used by anything as far as I can see. It's nowhere else in the code - seems like an anomaly.

Verified, it is still working as before:
animates by default

{() => (
<NamespaceContext.Provider value={monthUtils.sheetForMonth(month)}>
<NamespaceContext.Provider value={sheetForMonth(month)}>
<View
style={{
flexDirection: 'row',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { useNavigate } from 'react-router-dom';

import { toRelaxedNumber } from 'loot-core/src/shared/util';

import { type BoundActions } from '../../hooks/useActions';
import { theme } from '../../style';
import { type CommonModalProps } from '../../types/modals';
import Button from '../common/Button';
import ExternalLink from '../common/ExternalLink';
import FormError from '../common/FormError';
Expand All @@ -14,7 +16,12 @@ import Modal, { ModalButtons } from '../common/Modal';
import Text from '../common/Text';
import View from '../common/View';

function CreateLocalAccount({ modalProps, actions }) {
type CreateLocalAccountProps = {
modalProps: CommonModalProps;
actions: BoundActions;
};

function CreateLocalAccount({ modalProps, actions }: CreateLocalAccountProps) {
let navigate = useNavigate();
let [name, setName] = useState('');
let [offbudget, setOffbudget] = useState(false);
Expand All @@ -26,7 +33,7 @@ function CreateLocalAccount({ modalProps, actions }) {
let validateBalance = balance => !isNaN(parseFloat(balance));

return (
<Modal title="Create Local Account" {...modalProps} showBack={false}>
Copy link
Contributor Author

@MikesGlitch MikesGlitch Oct 7, 2023

Choose a reason for hiding this comment

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

"showBack" is not a valid property for Modal - it does nothing. This is the only place where a showBack prop is set on Modal - I think this may be old code.

The Back button logic is handled inside this component - verified it still works.
still back button

<Modal title="Create Local Account" {...modalProps}>
{() => (
<View>
<form
Expand Down
Loading