-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
4b6b2ed
commit 92b7f98
Showing
9 changed files
with
315 additions
and
13 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
40 changes: 40 additions & 0 deletions
40
apps/minifront/src/components/v2/transfer-layout/index.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,40 @@ | ||
import { Card } from '@repo/ui/Card'; | ||
import { Outlet, useNavigate } from 'react-router-dom'; | ||
import { Grid } from '@repo/ui/Grid'; | ||
import { Tabs } from '@repo/ui/Tabs'; | ||
import { usePagePath } from '../../../fetchers/page-path'; | ||
import { PagePath } from '../../metadata/paths'; | ||
|
||
/** @todo: Remove this function and its uses after we switch to v2 layout */ | ||
const v2PathPrefix = (path: string) => `/v2${path}`; | ||
|
||
const TABS_OPTIONS = [ | ||
{ label: 'Send', value: v2PathPrefix(PagePath.SEND) }, | ||
{ label: 'Receive', value: v2PathPrefix(PagePath.RECEIVE) }, | ||
]; | ||
|
||
export const TransferLayout = () => { | ||
const pagePath = usePagePath(); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<Grid container> | ||
<Grid mobile={0} tablet={2} desktop={3} xl={4} /> | ||
|
||
<Grid tablet={8} desktop={6} xl={4}> | ||
<Card title='Transfer Assets'> | ||
<Tabs | ||
value={v2PathPrefix(pagePath)} | ||
onChange={value => navigate(value)} | ||
options={TABS_OPTIONS} | ||
actionType='accent' | ||
/> | ||
|
||
<Outlet /> | ||
</Card> | ||
</Grid> | ||
|
||
<Grid mobile={0} tablet={2} desktop={3} xl={4} /> | ||
</Grid> | ||
); | ||
}; |
16 changes: 16 additions & 0 deletions
16
apps/minifront/src/components/v2/transfer-layout/receive-page/index.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,16 @@ | ||
import { AccountSelector } from '@repo/ui/AccountSelector'; | ||
import { Card } from '@repo/ui/Card'; | ||
import { FormField } from '@repo/ui/FormField'; | ||
import { getAddrByIndex } from '../../../../fetchers/address'; | ||
|
||
export const ReceivePage = () => { | ||
return ( | ||
<Card.Stack> | ||
<Card.Section> | ||
<FormField label='Address'> | ||
<AccountSelector getAddressByIndex={getAddrByIndex} /> | ||
</FormField> | ||
</Card.Section> | ||
</Card.Stack> | ||
); | ||
}; |
124 changes: 124 additions & 0 deletions
124
apps/minifront/src/components/v2/transfer-layout/send-page/index.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,124 @@ | ||
import { Card } from '@repo/ui/Card'; | ||
import { FormField } from '@repo/ui/FormField'; | ||
import { SegmentedControl } from '@repo/ui/SegmentedControl'; | ||
import { TextInput } from '@repo/ui/TextInput'; | ||
import { AllSlices } from '../../../../state'; | ||
import { sendValidationErrors } from '../../../../state/send'; | ||
import { FeeTier_Tier } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/fee/v1/fee_pb'; | ||
import { Button } from '@repo/ui/Button'; | ||
import { ArrowUpFromDot } from 'lucide-react'; | ||
import { useMemo } from 'react'; | ||
import { useStoreShallow } from '../../../../utils/use-store-shallow'; | ||
import { useRefreshFee } from './use-refresh-fee'; | ||
|
||
const sendPageSelector = (state: AllSlices) => ({ | ||
selection: state.send.selection, | ||
amount: state.send.amount, | ||
recipient: state.send.recipient, | ||
memo: state.send.memo, | ||
fee: state.send.fee, | ||
feeTier: state.send.feeTier, | ||
assetFeeMetadata: state.send.assetFeeMetadata, | ||
setAmount: state.send.setAmount, | ||
setSelection: state.send.setSelection, | ||
setRecipient: state.send.setRecipient, | ||
setFeeTier: state.send.setFeeTier, | ||
setMemo: state.send.setMemo, | ||
sendTx: state.send.sendTx, | ||
txInProgress: state.send.txInProgress, | ||
}); | ||
|
||
const FEE_TIER_OPTIONS = [ | ||
{ | ||
label: 'Low', | ||
value: FeeTier_Tier.LOW, | ||
}, | ||
{ | ||
label: 'Medium', | ||
value: FeeTier_Tier.MEDIUM, | ||
}, | ||
{ | ||
label: 'High', | ||
value: FeeTier_Tier.HIGH, | ||
}, | ||
]; | ||
|
||
export const SendPage = () => { | ||
const { | ||
selection, | ||
amount, | ||
recipient, | ||
memo, | ||
fee, | ||
feeTier, | ||
assetFeeMetadata, | ||
setAmount, | ||
setSelection, | ||
setRecipient, | ||
setFeeTier, | ||
setMemo, | ||
sendTx, | ||
txInProgress, | ||
} = useStoreShallow(sendPageSelector); | ||
|
||
useRefreshFee(); | ||
|
||
const validationErrors = useMemo(() => { | ||
return sendValidationErrors(selection, amount, recipient); | ||
}, [selection, amount, recipient]); | ||
|
||
const submitButtonDisabled = useMemo( | ||
() => | ||
!Number(amount) || | ||
!recipient || | ||
!!Object.values(validationErrors).find(Boolean) || | ||
txInProgress || | ||
!selection, | ||
[amount, recipient, validationErrors, txInProgress, selection], | ||
); | ||
|
||
return ( | ||
<> | ||
<Card.Stack> | ||
<Card.Section> | ||
<FormField label="Recipient's address"> | ||
<TextInput value={recipient} onChange={setRecipient} placeholder='penumbra1abc123...' /> | ||
</FormField> | ||
</Card.Section> | ||
|
||
<Card.Section> | ||
<FormField label='Amount' helperText='#0: 123,456.789'> | ||
<TextInput | ||
type='number' | ||
value={amount} | ||
onChange={setAmount} | ||
placeholder='Amount to send...' | ||
min={0} | ||
/> | ||
</FormField> | ||
</Card.Section> | ||
|
||
<Card.Section> | ||
<FormField label='Fee Tier'> | ||
<SegmentedControl value={feeTier} onChange={setFeeTier} options={FEE_TIER_OPTIONS} /> | ||
</FormField> | ||
</Card.Section> | ||
|
||
<Card.Section> | ||
<FormField label='Memo'> | ||
<TextInput value={memo} onChange={setMemo} placeholder='Optional Message...' /> | ||
</FormField> | ||
</Card.Section> | ||
</Card.Stack> | ||
|
||
<Button | ||
type='submit' | ||
icon={ArrowUpFromDot} | ||
actionType='accent' | ||
disabled={submitButtonDisabled} | ||
> | ||
Send | ||
</Button> | ||
</> | ||
); | ||
}; |
15 changes: 12 additions & 3 deletions
15
...ponents/send/send-form/use-refresh-fee.ts → ...nsfer-layout/send-page/use-refresh-fee.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
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
Oops, something went wrong.