Skip to content

Commit

Permalink
feat: add onboarding automation steps (#111)
Browse files Browse the repository at this point in the history
* feat: add onboarding automation steps

* fix: add children to StepBody
  • Loading branch information
moritzkirstein authored Feb 7, 2024
1 parent ad706f3 commit 625a638
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
Expand Down
6 changes: 6 additions & 0 deletions content/onboarding/steps/automationWalletState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Automation wallet state",
"subtitle": "Quickly verify if your automation wallet is active and funded",
"body": "From the contextual menu under the automation icon on the menubar, you'll be able to enable/disable the automation.\n\nYou can quickly asses the automation wallet state by looking at the icon:\n\n- the automation is enabled if the icon has a colored background\n\n- the wallet is completely funded if the top right indicator is green, partially funded if the indicator is yellow, and insufficient funded if the indicator is red.",
"image": "/images/onboarding/automation_wallet_state.png"
}
8 changes: 8 additions & 0 deletions content/onboarding/steps/importAutomationWallet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"title": "Activate Automation",
"subtitle": "Activate the assets consumption automation",
"body": "Click on the button to import the wallet you want to use for the automation, you will be asked to provide the encrypted json file and the password to unlock it.",
"image": "/images/onboarding/automation_wallet_import.png",
"buttonLabel": "Import Wallet Json",
"buttonSuccess": "Wallet Imported Successfully"
}
180 changes: 180 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/components/@shared/Onboarding/StepBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export default function StepBody({
body,
image,
actions,
refreshOption
refreshOption,
children
}: {
body: string
image?: string
actions?: IStepAction[]
refreshOption?: boolean
children?: ReactElement
}): ReactElement {
return (
<div className={styles.content}>
Expand All @@ -36,6 +38,7 @@ export default function StepBody({
{actions?.map((action) => (
<StepAction key={action.buttonLabel} {...action} />
))}
{children}
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/components/@shared/Onboarding/Steps/AutomationWalletState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { ReactElement } from 'react'
import { OnboardingStep } from '..'
import StepBody from '../StepBody'
import StepHeader from '../StepHeader'
import content from '../../../../../content/onboarding/steps/automationWalletState.json'

export default function AutomationWalletState(): ReactElement {
const { title, subtitle, body, image }: OnboardingStep = content

return (
<div>
<StepHeader title={title} subtitle={subtitle} />
<StepBody body={body} image={image} />
</div>
)
}
36 changes: 36 additions & 0 deletions src/components/@shared/Onboarding/Steps/ImportWallet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { ReactElement, useEffect, useState } from 'react'
import { OnboardingStep } from '..'
import StepBody from '../StepBody'
import StepHeader from '../StepHeader'
import content from '../../../../../content/onboarding/steps/importAutomationWallet.json'
import Import from '@components/Header/UserPreferences/Automation/Import'
import { useAutomation } from '@context/Automation/AutomationProvider'
import Decrypt from '@components/Header/UserPreferences/Automation/Decrypt'
import Alert from '@components/@shared/atoms/Alert'

export default function ImportWallet(): ReactElement {
const { title, subtitle, body, image }: OnboardingStep = content
const { autoWallet, hasValidEncryptedWallet } = useAutomation()
const [needsImport, setNeedsImport] = useState<boolean>(
!hasValidEncryptedWallet
)

useEffect(() => {
setNeedsImport(!hasValidEncryptedWallet)
}, [hasValidEncryptedWallet])

return (
<div>
<StepHeader title={title} subtitle={subtitle} />
<StepBody body={body} image={image}>
{autoWallet ? (
<Alert text={content.buttonSuccess} state="success" />
) : needsImport ? (
<Import />
) : (
<Decrypt />
)}
</StepBody>
</div>
)
}
4 changes: 4 additions & 0 deletions src/components/@shared/Onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { useAccount, useNetwork, useProvider } from 'wagmi'
import { useUserPreferences } from '@context/UserPreferences'
import useBalance from '@hooks/useBalance'
import { GEN_X_NETWORK_ID } from 'chains.config'
import ImportWallet from './Steps/ImportWallet'
import AutomationWalletState from './Steps/AutomationWalletState'

export interface OnboardingStep {
title: string
Expand All @@ -27,6 +29,8 @@ const steps = [
{ shortLabel: 'MetaMask', component: <DownloadMetamask /> },
{ shortLabel: 'Connect', component: <ConnectAccount /> },
{ shortLabel: 'Tokens', component: <ImportCustomTokens /> },
{ shortLabel: 'Import', component: <ImportWallet /> },
{ shortLabel: 'Automation', component: <AutomationWalletState /> },
{ shortLabel: 'Ready', component: <Ready /> }
]

Expand Down

0 comments on commit 625a638

Please sign in to comment.