Skip to content
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

Add "processing" to add hot signer flow #1499

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/dash/Accounts/Add/Components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ export function AddHotAccount({
const steps = [
firstFlowStep,
<CreatePassword key={1} onCreate={onCreate} autofocus={viewIndex === 1} />,
<ConfirmPassword key={2} password={password} onConfirm={onConfirm} autofocus={viewIndex === 2} />,
<ConfirmPassword
key={2}
password={password}
onConfirm={onConfirm}
autofocus={viewIndex === 2}
lastStep={true}
/>,
<Error key={3} error={error} />
]

Expand Down
8 changes: 7 additions & 1 deletion app/dash/Accounts/Add/style/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,15 @@
font-size 12px
color var(--moon)
text-align center

.addAccountItemOptionProcessing
height 34px
padding 0px 20px
margin-top 12px
font-size 12px
text-align center

.addAccountItemOptionSubmit
background var(--ghostB)
height 32px
border-radius 16px
padding 0px 40px
Expand Down
28 changes: 24 additions & 4 deletions resources/Components/Password/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,36 @@ import { debounce } from '../../utils'

const NO_PASSWORD_ENTERED = 'Enter password'

export const PasswordInput = ({ getError: getInputError, next, title, buttonText, autofocus }) => {
export const PasswordInput = ({
getError: getInputError,
next,
title,
buttonText,
autofocus,
lastStep = false
}) => {
const [error, setError] = useState(NO_PASSWORD_ENTERED)
const inputRef = useFocusableRef(autofocus)
const [disabled, setDisabled] = useState(false)
const [processing, setProcessing] = useState(false)

const resetError = () => setError(NO_PASSWORD_ENTERED)

const clear = () => {
resetError()
inputRef.current && (inputRef.current.value = '')
}

const handleSubmit = () => {
next(inputRef.current.value)
setTimeout(clear, 1_000)
if (lastStep) {
setProcessing(true)
clear()
} else {
setTimeout(() => {
resetError()
clear()
}, 1_000)
}
}

const getError = () =>
Expand Down Expand Up @@ -60,6 +75,10 @@ export const PasswordInput = ({ getError: getInputError, next, title, buttonText
<div role='button' className='addAccountItemOptionError'>
{error}
</div>
) : processing ? (
<div role='button' className='addAccountItemOptionProcessing'>
Processing...
</div>
) : (
<div role='button' className='addAccountItemOptionSubmit' onClick={() => !disabled && handleSubmit()}>
{buttonText}
Expand Down Expand Up @@ -92,7 +111,7 @@ export const CreatePassword = ({ onCreate, autofocus }) => {
)
}

export const ConfirmPassword = ({ password, onConfirm, autofocus }) => {
export const ConfirmPassword = ({ password, onConfirm, autofocus, lastStep }) => {
const getError = (confirmedPassword) => {
if (password !== confirmedPassword) return 'PASSWORDS DO NOT MATCH'
}
Expand All @@ -104,6 +123,7 @@ export const ConfirmPassword = ({ password, onConfirm, autofocus }) => {
title='Confirm Password'
buttonText='Create'
autofocus={autofocus}
lastStep={lastStep}
/>
)
}