-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom mapping and import settings for bank sync providers (#4253)
* barebones UI * add saving and prefs * add last sync functionality * use mapping for synced transactions * note * jest -u * Update VRT * Coderabbit Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * add new fields * rename migration, newer in master * lint * coderabbit * update snapshots * GoCardless handlers fallback and notes * expose new fields from SimpleFIN * update tests * update instructions on GoCardless handlers * lint * feedback * Update VRT --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: youngcw <[email protected]>
- Loading branch information
1 parent
f90fc69
commit 9fd0042
Showing
85 changed files
with
1,366 additions
and
654 deletions.
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
92 changes: 92 additions & 0 deletions
92
packages/desktop-client/src/components/banksync/AccountRow.tsx
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,92 @@ | ||
import React, { memo } from 'react'; | ||
import { Trans } from 'react-i18next'; | ||
|
||
import { format } from 'loot-core/src/shared/months'; | ||
import { type AccountEntity } from 'loot-core/src/types/models'; | ||
|
||
import { useDateFormat } from '../../hooks/useDateFormat'; | ||
import { theme } from '../../style'; | ||
import { Button } from '../common/Button2'; | ||
import { Row, Cell } from '../table'; | ||
|
||
const tsToString = (ts: string | null, dateFormat: string) => { | ||
if (!ts) return 'Unknown'; | ||
|
||
const parsed = new Date(parseInt(ts, 10)); | ||
return `${format(parsed, dateFormat)} ${format(parsed, 'HH:mm:ss')}`; | ||
}; | ||
|
||
type AccountRowProps = { | ||
account: AccountEntity; | ||
hovered: boolean; | ||
onHover: (id: AccountEntity['id'] | null) => void; | ||
onAction: (account: AccountEntity, action: 'link' | 'edit') => void; | ||
}; | ||
|
||
export const AccountRow = memo( | ||
({ account, hovered, onHover, onAction }: AccountRowProps) => { | ||
const backgroundFocus = hovered; | ||
|
||
const dateFormat = useDateFormat() || 'MM/dd/yyyy'; | ||
|
||
const lastSync = tsToString(account.last_sync, dateFormat); | ||
|
||
return ( | ||
<Row | ||
height="auto" | ||
style={{ | ||
fontSize: 13, | ||
backgroundColor: backgroundFocus | ||
? theme.tableRowBackgroundHover | ||
: theme.tableBackground, | ||
}} | ||
collapsed={true} | ||
onMouseEnter={() => onHover && onHover(account.id)} | ||
onMouseLeave={() => onHover && onHover(null)} | ||
> | ||
<Cell | ||
name="accountName" | ||
width={250} | ||
plain | ||
style={{ color: theme.tableText, padding: '10px' }} | ||
> | ||
{account.name} | ||
</Cell> | ||
|
||
<Cell | ||
name="bankName" | ||
width="flex" | ||
plain | ||
style={{ color: theme.tableText, padding: '10px' }} | ||
> | ||
{account.bankName} | ||
</Cell> | ||
|
||
<Cell | ||
name="lastSync" | ||
width={200} | ||
plain | ||
style={{ color: theme.tableText, padding: '10px' }} | ||
> | ||
{account.account_sync_source ? lastSync : ''} | ||
</Cell> | ||
|
||
{account.account_sync_source ? ( | ||
<Cell name="edit" plain style={{ paddingRight: '10px' }}> | ||
<Button onPress={() => onAction(account, 'edit')}> | ||
<Trans>Edit</Trans> | ||
</Button> | ||
</Cell> | ||
) : ( | ||
<Cell name="link" plain style={{ paddingRight: '10px' }}> | ||
<Button onPress={() => onAction(account, 'link')}> | ||
<Trans>Link account</Trans> | ||
</Button> | ||
</Cell> | ||
)} | ||
</Row> | ||
); | ||
}, | ||
); | ||
|
||
AccountRow.displayName = 'AccountRow'; |
37 changes: 37 additions & 0 deletions
37
packages/desktop-client/src/components/banksync/AccountsHeader.tsx
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,37 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { Cell, TableHeader } from '../table'; | ||
|
||
type AccountsHeaderProps = { | ||
unlinked: boolean; | ||
}; | ||
|
||
export function AccountsHeader({ unlinked }: AccountsHeaderProps) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<TableHeader> | ||
<Cell | ||
value={t('Account')} | ||
width={!unlinked ? 250 : 'flex'} | ||
style={{ paddingLeft: '10px' }} | ||
/> | ||
{!unlinked && ( | ||
<> | ||
<Cell | ||
value={t('Bank')} | ||
width="flex" | ||
style={{ paddingLeft: '10px' }} | ||
/> | ||
<Cell | ||
value={t('Last sync')} | ||
width={160} | ||
style={{ paddingLeft: '10px' }} | ||
/> | ||
<Cell value="" width={100} style={{ paddingLeft: '10px' }} /> | ||
</> | ||
)} | ||
</TableHeader> | ||
); | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/desktop-client/src/components/banksync/AccountsList.tsx
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,43 @@ | ||
import React from 'react'; | ||
|
||
import { type AccountEntity } from 'loot-core/src/types/models'; | ||
|
||
import { View } from '../common/View'; | ||
|
||
import { AccountRow } from './AccountRow'; | ||
|
||
type AccountsListProps = { | ||
accounts: AccountEntity[]; | ||
hoveredAccount?: string | null; | ||
onHover: (id: AccountEntity['id'] | null) => void; | ||
onAction: (account: AccountEntity, action: 'link' | 'edit') => void; | ||
}; | ||
|
||
export function AccountsList({ | ||
accounts, | ||
hoveredAccount, | ||
onHover, | ||
onAction, | ||
}: AccountsListProps) { | ||
if (accounts.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<View> | ||
{accounts.map(account => { | ||
const hovered = hoveredAccount === account.id; | ||
|
||
return ( | ||
<AccountRow | ||
key={account.id} | ||
account={account} | ||
hovered={hovered} | ||
onHover={onHover} | ||
onAction={onAction} | ||
/> | ||
); | ||
})} | ||
</View> | ||
); | ||
} |
Oops, something went wrong.