-
-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reset SimpleFIN credential button in settings to resolve a state …
…in which SimpleFIN is unable to sync
- Loading branch information
1 parent
6021d4a
commit 998b4af
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
packages/desktop-client/src/components/settings/SimpleFINReset.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,60 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { useActions } from '../../hooks/useActions'; | ||
import { useSimpleFinStatus } from '../../hooks/useSimpleFinStatus'; | ||
import { ButtonWithLoading } from '../common/Button'; | ||
import { Text } from '../common/Text'; | ||
|
||
import { Setting } from './UI'; | ||
|
||
export function SimpleFINResetCredential() { | ||
const actions = useActions(); | ||
const [isSimpleFinSetupComplete, setIsSimpleFinSetupComplete] = useState< | ||
boolean | null | ||
>(null); | ||
const [loadingSimpleFinAccounts, setLoadingSimpleFinAccounts] = | ||
useState(false); | ||
|
||
const onSimpleFinInit = () => { | ||
setLoadingSimpleFinAccounts(true); | ||
actions.pushModal('simplefin-init', { | ||
onSuccess: () => { | ||
setIsSimpleFinSetupComplete(true); | ||
}, | ||
}); | ||
setLoadingSimpleFinAccounts(false); | ||
}; | ||
const { configuredSimpleFin } = useSimpleFinStatus(); | ||
useEffect(() => { | ||
setIsSimpleFinSetupComplete(configuredSimpleFin); | ||
}, [configuredSimpleFin]); | ||
|
||
return ( | ||
<Setting | ||
primaryAction={ | ||
<ButtonWithLoading | ||
loading={loadingSimpleFinAccounts} | ||
disabled={!isSimpleFinSetupComplete} | ||
onClick={onSimpleFinInit} | ||
> | ||
Reset SimpleFIN Credential | ||
</ButtonWithLoading> | ||
} | ||
> | ||
{isSimpleFinSetupComplete ? ( | ||
<Text> | ||
<strong>Reset SimpleFIN Credential</strong> In some cases (like | ||
importing from an existing database to a new instance), you may need | ||
to generate a new SimpleFINsetup token to receive a valid access | ||
token. If you are having trouble, generate a new setup token and enter | ||
it here. | ||
</Text> | ||
) : ( | ||
<Text> | ||
<strong>Reset SimpleFIN Credential</strong> is only available when | ||
SimpleFIN has been enabled and configured. | ||
</Text> | ||
)} | ||
</Setting> | ||
); | ||
} |
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: Bugfix | ||
authors: [mattpetters] | ||
--- | ||
|
||
Add reset SimpleFIN credential button to resolve a state in which SimpleFIN is unable to sync |