-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Update CloseAccount, AccountAutocomplete, SavedFilterAutocomplete, PayeeAutocomplete components to Typescript. #1923
Merged
MatissJanis
merged 7 commits into
actualbudget:master
from
MikesGlitch:maintenance/typescript-updates
Nov 18, 2023
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
776d0d3
updating some components to typescript
MikesGlitch 01868ab
adding release notes
MikesGlitch ead8b20
SavedFilterAutocomplete filter to typescript
MikesGlitch 14d9d98
payee autocomplete component to ts
MikesGlitch 01aedbe
remove commented out line
MikesGlitch 5343a3e
adding type guard
MikesGlitch b6411c3
adding a space
MikesGlitch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { integerToCurrency } from 'loot-core/src/shared/util'; | ||
import { | ||
type AccountEntity, | ||
type CategoryGroupEntity, | ||
} from 'loot-core/src/types/models'; | ||
|
||
import { type BoundActions } from '../../hooks/useActions'; | ||
import { theme } from '../../style'; | ||
import { type CommonModalProps } from '../../types/modals'; | ||
import AccountAutocomplete from '../autocomplete/AccountAutocomplete'; | ||
import CategoryAutocomplete from '../autocomplete/CategoryAutocomplete'; | ||
import Button from '../common/Button'; | ||
|
@@ -13,7 +19,11 @@ import Paragraph from '../common/Paragraph'; | |
import Text from '../common/Text'; | ||
import View from '../common/View'; | ||
|
||
function needsCategory(account, currentTransfer, accounts) { | ||
function needsCategory( | ||
account: AccountEntity, | ||
currentTransfer: string, | ||
accounts: AccountEntity[], | ||
) { | ||
const acct = accounts.find(a => a.id === currentTransfer); | ||
const isOffBudget = acct && acct.offbudget === 1; | ||
|
||
|
@@ -22,6 +32,16 @@ function needsCategory(account, currentTransfer, accounts) { | |
return account.offbudget === 0 && isOffBudget; | ||
} | ||
|
||
type CloseAccountProps = { | ||
account: AccountEntity; | ||
accounts: AccountEntity[]; | ||
categoryGroups: CategoryGroupEntity[]; | ||
balance: number; | ||
canDelete: boolean; | ||
actions: BoundActions; | ||
modalProps: CommonModalProps; | ||
}; | ||
|
||
function CloseAccount({ | ||
account, | ||
accounts, | ||
|
@@ -30,7 +50,7 @@ function CloseAccount({ | |
canDelete, | ||
actions, | ||
modalProps, | ||
}) { | ||
}: CloseAccountProps) { | ||
let [loading, setLoading] = useState(false); | ||
let [transfer, setTransfer] = useState(''); | ||
let [category, setCategory] = useState(''); | ||
|
@@ -95,7 +115,6 @@ function CloseAccount({ | |
<AccountAutocomplete | ||
includeClosedAccounts={false} | ||
value={transfer} | ||
accounts={accounts} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused |
||
inputProps={{ | ||
placeholder: 'Select account...', | ||
}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Maintenance | ||
authors: [MikesGlitch] | ||
--- | ||
|
||
Convert CloseAccount, AccountAutocomplete, SavedFilterAutocomplete, PayeeAutocomplete components to Typescript. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: you could create a tiny typeguard util function. That would help get rid of this manual type coercion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two typeguards and removed the "as" cast