-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(trading): added new UI for memo/destination tag
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 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
49 changes: 49 additions & 0 deletions
49
.../wallet/trading/common/TradingSelectedOffer/TradingVerify/TradingVerifyDestinationTag.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,49 @@ | ||
import { ReactNode, useState } from 'react'; | ||
|
||
import { Button, Column, Row, Switch } from '@trezor/components'; | ||
import { spacings } from '@trezor/theme'; | ||
|
||
import { Translation } from 'src/components/suite'; | ||
import { useGuideOpenNode } from 'src/hooks/guide'; | ||
import { DESTINATION_TAG_GUIDE_PATH } from 'src/views/wallet/send/Options/RippleOptions/DestinationTag'; | ||
|
||
export interface TradingVerifyDestinationTagProps { | ||
inputComponent: ReactNode; | ||
onToggle?: (toggled: boolean) => void; | ||
} | ||
|
||
export const TradingVerifyDestinationTag = ({ | ||
inputComponent, | ||
onToggle, | ||
}: TradingVerifyDestinationTagProps) => { | ||
const { openNodeById } = useGuideOpenNode(); | ||
|
||
const [enabled, setEnabled] = useState<boolean>(false); | ||
|
||
const handleToggle = (isChecked: boolean) => { | ||
setEnabled(isChecked); | ||
onToggle?.(isChecked); | ||
}; | ||
|
||
const handleOpenGuide = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.stopPropagation(); | ||
openNodeById(DESTINATION_TAG_GUIDE_PATH); | ||
}; | ||
|
||
return ( | ||
<Column gap={spacings.md}> | ||
<Row justifyContent="space-between"> | ||
<Switch | ||
isChecked={enabled} | ||
onChange={handleToggle} | ||
label={<Translation id="DESTINATION_TAG_SWITCH" />} | ||
/> | ||
<Button variant="tertiary" type="button" size="tiny" onClick={handleOpenGuide}> | ||
<Translation id="DESTINATION_TAG_GUIDE_LINK" /> | ||
</Button> | ||
</Row> | ||
|
||
{enabled && inputComponent} | ||
</Column> | ||
); | ||
}; |