Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Compositr authored Oct 10, 2023
2 parents e2b3f2a + 3dfe633 commit 296d59a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ type SingleAutocompleteProps = {
openOnFocus?: boolean;
getHighlightedIndex?: (suggestions) => number | null;
highlightFirst?: boolean;
onUpdate: (id: unknown, value: string) => void;
onUpdate?: (id: unknown, value: string) => void;
strict?: boolean;
onSelect: (id: unknown, value: string) => void;
tableBehavior?: boolean;
Expand Down
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;
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';
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}>
{() => (
<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}>
<Modal title="Create Local Account" {...modalProps}>
{() => (
<View>
<form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ export default function ImportTransactions({ modalProps, options }) {
// options which are simple post-processing. That means if you
// parsed different files without closing the modal, it wouldn't
// re-read this.
let [csvDelimiter, setCsvDelimiter] = useState(
let [delimiter, setDelimiter] = useState(
prefs[`csv-delimiter-${accountId}`] ||
(filename.endsWith('.tsv') ? '\t' : ','),
);
Expand Down Expand Up @@ -666,7 +666,7 @@ export default function ImportTransactions({ modalProps, options }) {
const fileType = getFileType(options.filename);
const parseOptions = getParseOptions(
fileType,
{ csvDelimiter, hasHeaderRow },
{ delimiter, hasHeaderRow },
{ fallbackMissingPayeeToMemo },
);

Expand Down Expand Up @@ -716,7 +716,7 @@ export default function ImportTransactions({ modalProps, options }) {
const fileType = getFileType(res[0]);
const parseOptions = getParseOptions(
fileType,
{ csvDelimiter, hasHeaderRow },
{ delimiter, hasHeaderRow },
{ fallbackMissingPayeeToMemo },
);

Expand Down Expand Up @@ -787,7 +787,7 @@ export default function ImportTransactions({ modalProps, options }) {
savePrefs({
[`csv-mappings-${accountId}`]: JSON.stringify(fieldMappings),
});
savePrefs({ [`csv-delimiter-${accountId}`]: csvDelimiter });
savePrefs({ [`csv-delimiter-${accountId}`]: delimiter });
}

if (filetype === 'csv' || filetype === 'qif') {
Expand Down Expand Up @@ -966,11 +966,12 @@ export default function ImportTransactions({ modalProps, options }) {
options={[
[',', ','],
[';', ';'],
['|', '|'],
['\t', 'tab'],
]}
value={csvDelimiter}
value={delimiter}
onChange={value => {
setCsvDelimiter(value);
setDelimiter(value);
parse(
filename,
getParseOptions('csv', {
Expand All @@ -990,7 +991,7 @@ export default function ImportTransactions({ modalProps, options }) {
parse(
filename,
getParseOptions('csv', {
delimiter: csvDelimiter,
delimiter,
hasHeaderRow: !hasHeaderRow,
}),
);
Expand Down Expand Up @@ -1070,8 +1071,8 @@ export default function ImportTransactions({ modalProps, options }) {

function getParseOptions(fileType, csvOptions, ofxOptions) {
if (fileType === 'csv') {
const { csvDelimiter, hasHeaderRow } = csvOptions;
return { csvDelimiter, hasHeaderRow };
const { delimiter, hasHeaderRow } = csvOptions;
return { delimiter, hasHeaderRow };
} else if (isOfxFile(fileType)) {
const { fallbackMissingPayeeToMemo } = ofxOptions;
return { fallbackMissingPayeeToMemo };
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1768.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MikesGlitch]
---

Convert BudgetSummary modal(mobile) and CreateLocalAccounts components to TypeScript.
6 changes: 6 additions & 0 deletions upcoming-release-notes/1774.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [KaiBelmo]
---

Fix selecting delimiters in CSV options when uploading a CSV; it will apply to parsing. Also added a new delimiter '|'.

0 comments on commit 296d59a

Please sign in to comment.