-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: major refactoring of automation
- Loading branch information
1 parent
f5295dd
commit 7b17c43
Showing
13 changed files
with
380 additions
and
306 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
src/components/Header/UserPreferences/Automation/Address.module.css
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,19 @@ | ||
.delete > svg { | ||
fill: var(--brand-alert-red); | ||
} | ||
|
||
.address { | ||
display: flex; | ||
justify-content: space-between; | ||
font-size: var(--font-size-base); | ||
width: 100%; | ||
padding-bottom: calc(var(--spacer) / 4); | ||
} | ||
|
||
.address strong { | ||
color: var(--brand-blue); | ||
} | ||
|
||
.address button { | ||
margin-left: calc(var(--spacer) / 4); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/components/Header/UserPreferences/Automation/Address.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, { ReactElement } from 'react' | ||
import { accountTruncate } from '../../../../@utils/wallet' | ||
import { useAutomation } from '../../../../@context/Automation/AutomationProvider' | ||
import { useUserPreferences } from '../../../../@context/UserPreferences' | ||
import Copy from '../../../@shared/atoms/Copy' | ||
import Cross from '@images/cross.svg' | ||
import styles from './Address.module.css' | ||
import Button from '../../../@shared/atoms/Button' | ||
|
||
export default function Address({ | ||
showDelete | ||
}: { | ||
showDelete: boolean | ||
}): ReactElement { | ||
const { autoWalletAddress } = useAutomation() | ||
const { setAutomationWalletJSON } = useUserPreferences() | ||
|
||
return ( | ||
<div className={styles.address}> | ||
<span> | ||
Address: <strong>{accountTruncate(autoWalletAddress)}</strong> | ||
<Copy text={autoWalletAddress} /> | ||
</span> | ||
{showDelete && ( | ||
<Button | ||
onClick={() => setAutomationWalletJSON(undefined)} | ||
className={styles.delete} | ||
title="Delete" | ||
style="text" | ||
size="small" | ||
> | ||
<Cross /> | ||
</Button> | ||
)} | ||
</div> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/components/Header/UserPreferences/Automation/Decrypt.module.css
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,24 @@ | ||
.wrapper { | ||
width: 100%; | ||
} | ||
|
||
.button { | ||
width: 100%; | ||
} | ||
|
||
.form { | ||
display: flex; | ||
} | ||
|
||
.form > * { | ||
margin: 0; | ||
} | ||
|
||
.form > button { | ||
margin-left: calc(var(--spacer) / 4); | ||
padding: calc(var(--spacer) / 4) calc(var(--spacer) / 2); | ||
} | ||
|
||
.help { | ||
font-size: var(--font-size-small); | ||
} |
63 changes: 63 additions & 0 deletions
63
src/components/Header/UserPreferences/Automation/Decrypt.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,63 @@ | ||
import React, { ReactElement, useEffect, useRef, useState } from 'react' | ||
import styles from './Decrypt.module.css' | ||
import Button from '../../../@shared/atoms/Button' | ||
import { toast } from 'react-toastify' | ||
import { useAutomation } from '../../../../@context/Automation/AutomationProvider' | ||
import Loader from '../../../@shared/atoms/Loader' | ||
import InputElement from '../../../@shared/FormInput/InputElement' | ||
import Input from '../../../@shared/FormInput' | ||
import { Field } from 'formik' | ||
|
||
export default function Decrypt(): ReactElement { | ||
const { isLoading, decryptPercentage, decryptAutomationWallet } = | ||
useAutomation() | ||
|
||
const decrpytToastRef = useRef(null) | ||
const [showPasswordInput, setShowPasswordInput] = useState<boolean>() | ||
const passwordInputRef = useRef(null) | ||
|
||
useEffect(() => { | ||
toast.update(decrpytToastRef.current, { progress: decryptPercentage }) | ||
}, [decrpytToastRef, decryptPercentage]) | ||
|
||
return ( | ||
<div className={styles.wrapper}> | ||
{isLoading ? ( | ||
<Loader message="Decrypting..." /> | ||
) : showPasswordInput ? ( | ||
<> | ||
<form | ||
onSubmit={async (e) => { | ||
e.preventDefault() | ||
decrpytToastRef.current = toast.info(`Decrypting Wallet...`) | ||
await decryptAutomationWallet(passwordInputRef.current.value) | ||
toast.done(decrpytToastRef.current) | ||
setShowPasswordInput(false) | ||
}} | ||
className={styles.form} | ||
> | ||
<InputElement | ||
name="password" | ||
placeholder="Password" | ||
label="Password" | ||
type="password" | ||
ref={passwordInputRef} | ||
/> | ||
<Button type="submit">Decrypt</Button> | ||
</form> | ||
<span className={styles.help}> | ||
Enter the password that was used to encrypt this wallet. | ||
</span> | ||
</> | ||
) : ( | ||
<Button | ||
onClick={() => setShowPasswordInput(true)} | ||
disabled={isLoading} | ||
className={styles.button} | ||
> | ||
Decrypt Wallet | ||
</Button> | ||
)} | ||
</div> | ||
) | ||
} |
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
Oops, something went wrong.