-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
231 additions
and
77 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
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
57 changes: 57 additions & 0 deletions
57
...uite/src/components/suite/modals/ReduxModal/DeviceContextModal/PassphraseModalContext.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,57 @@ | ||
import React, { createContext, useContext, useState } from 'react'; | ||
|
||
import type { TrezorDevice } from '@suite-common/suite-types/libDev/src'; | ||
|
||
type PassphraseState = 'initial' | 'best-practices'; | ||
|
||
const INITIAL_STATE: PassphraseState = 'initial'; | ||
|
||
type PassphraseModalContextType = { | ||
passphraseState: PassphraseState; | ||
setPassphraseState: (passphraseState: PassphraseState) => void; | ||
device: TrezorDevice | undefined; | ||
setDevice: (device: TrezorDevice) => void; | ||
}; | ||
|
||
type PassphraseModalProviderProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const initialPassphraseModal: PassphraseModalContextType = { | ||
passphraseState: INITIAL_STATE, | ||
setPassphraseState: () => {}, | ||
device: undefined, | ||
setDevice: () => {}, | ||
}; | ||
|
||
export const PassphraseModalContext = | ||
createContext<PassphraseModalContextType>(initialPassphraseModal); | ||
|
||
export const PassphraseModalProvider = ({ children }: PassphraseModalProviderProps) => { | ||
const [passphraseState, setPassphraseState] = useState<PassphraseState>( | ||
initialPassphraseModal.passphraseState, | ||
); | ||
const [device, setDevice] = useState<TrezorDevice | undefined>(undefined); | ||
|
||
const value: PassphraseModalContextType = { | ||
passphraseState, | ||
setPassphraseState, | ||
device, | ||
setDevice, | ||
}; | ||
|
||
return ( | ||
<PassphraseModalContext.Provider value={value}>{children}</PassphraseModalContext.Provider> | ||
); | ||
}; | ||
|
||
PassphraseModalProvider.displayName = 'PassphraseModalProvider'; | ||
|
||
export const usePassphraseModalContext = () => { | ||
const context = useContext(PassphraseModalContext); | ||
if (!context) { | ||
throw new Error('usePassphraseModalContext must be used within a PassphraseModalProvider'); | ||
} | ||
|
||
return context; | ||
}; |
28 changes: 28 additions & 0 deletions
28
...c/components/suite/modals/ReduxModal/DeviceContextModal/PassphraseWalletBestPractices.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,28 @@ | ||
import { PassphraseWalletConfirmationStep2 } from './PassphraseWalletConfirmationStep2'; | ||
import { CardWithDevice } from '../../../../../views/suite/SwitchDevice/CardWithDevice'; | ||
import { SwitchDeviceModal } from '../../../../../views/suite/SwitchDevice/SwitchDeviceModal'; | ||
|
||
type PassphraseWalletBestPracticesProps = { | ||
onCancel: () => void; | ||
onNext: () => void; | ||
onBack: () => void; | ||
device: any; | ||
}; | ||
|
||
export const PassphraseWalletBestPractices = ({ | ||
onCancel, | ||
onNext, | ||
onBack, | ||
device, | ||
}: PassphraseWalletBestPracticesProps) => ( | ||
<SwitchDeviceModal onCancel={onCancel}> | ||
<CardWithDevice | ||
onCancel={onCancel} | ||
device={device} | ||
onBackButtonClick={onBack} | ||
isFullHeaderVisible | ||
> | ||
<PassphraseWalletConfirmationStep2 onNext={onNext} /> | ||
</CardWithDevice> | ||
</SwitchDeviceModal> | ||
); |
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
2 changes: 1 addition & 1 deletion
2
packages/suite/src/components/suite/modals/ReduxModal/DeviceContextModal/types.ts
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 |
---|---|---|
@@ -1 +1 @@ | ||
export type ContentType = 'step1' | 'step2' | 'step3'; | ||
// export type ContentType = 'step1' | 'step2' | 'step3'; |
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.