Skip to content

Commit 57a7604

Browse files
committed
wip: wallet flow
1 parent 5635d65 commit 57a7604

File tree

20 files changed

+895
-615
lines changed

20 files changed

+895
-615
lines changed

api/typeDefs/wallet.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ const typeDefs = gql`
139139
): Boolean!
140140
141141
# delete
142-
removeWallet(id: ID!): Boolean
143-
removeWalletProtocol(id: ID!): Boolean
142+
deleteWallet(id: ID!): Boolean
144143
145144
# crypto
146145
updateWalletEncryption(keyHash: String!, wallets: [WalletEncryptionUpdate!]!): Boolean
@@ -149,7 +148,7 @@ const typeDefs = gql`
149148
disablePassphraseExport: Boolean
150149
151150
# settings
152-
setWalletSettings(settings: WalletSettingsInput!): Boolean
151+
setWalletSettings(settings: WalletSettingsInput!): WalletSettings!
153152
setWalletPriorities(priorities: [WalletPriorityUpdate!]!): Boolean
154153
155154
# logs

fragments/users.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ export const SET_SETTINGS = gql`
131131
}
132132
}`
133133

134-
export const DELETE_WALLET = gql`
135-
mutation removeWallet {
136-
removeWallet
137-
}`
138-
139134
export const NAME_QUERY = gql`
140135
query nameAvailable($name: String!) {
141136
nameAvailable(name: $name)

pages/wallets/[...slug].js renamed to pages/wallets/[type].js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { useQuery } from '@apollo/client'
88
import { useRouter } from 'next/router'
99

1010
const variablesFunc = params => {
11-
const id = Number(params.slug[0])
12-
return !Number.isNaN(id) ? { id } : { name: unurlify(params.slug[0]) }
11+
const id = Number(params.type)
12+
return !Number.isNaN(id) ? { id } : { name: unurlify(params.type) }
1313
}
1414
export const getServerSideProps = getGetServerSideProps({ query: WALLET, variables: variablesFunc, authRequired: true })
1515

@@ -20,9 +20,9 @@ export default function WalletForms ({ ssrData }) {
2020
// Warning: fragment with name WalletTemplateFields already exists.
2121
// graphql-tag enforces all fragment names across your application to be unique
2222
// this is not a problem because the warning is only meant to avoid overwriting fragments but we're reusing it
23-
const { data, refetch } = useQuery(WALLET, { variables })
23+
const { data } = useQuery(WALLET, { variables })
2424
const dat = useData(data, ssrData)
2525

2626
const decryptedWallet = useDecryptedWallet(dat?.wallet)
27-
return <WalletFormsComponent wallet={decryptedWallet ?? dat?.wallet} refetch={refetch} />
27+
return <WalletFormsComponent wallet={decryptedWallet ?? ssrData?.wallet} />
2828
}

pages/wallets/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ export default function Wallet () {
113113
<WalletLayoutSubHeader>use real bitcoin</WalletLayoutSubHeader>
114114
<div className='text-center'>
115115
<WalletLayoutLink href='/wallets/logs'>wallet logs</WalletLayoutLink>
116-
<span className='mx-2'></span>
117-
<WalletLayoutLink href='/wallets/settings'>settings</WalletLayoutLink>
118116
{showPassphrase && (
119117
<>
120118
<span className='mx-2'></span>

pages/wallets/settings.js

Lines changed: 0 additions & 185 deletions
This file was deleted.

styles/wallet.module.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@
106106
flex-direction: column;
107107
}
108108

109+
@media (max-width: 768px) {
110+
.form {
111+
margin-top: 1rem;
112+
}
113+
}
114+
109115
.separator {
110116
display: flex;
111117
align-items: center;
@@ -136,3 +142,12 @@
136142
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
137143
container-type: inline-size;
138144
}
145+
146+
.progressNumber {
147+
display: inline-block;
148+
background-color: var(--bs-body-bg);
149+
border-radius: 50%;
150+
width: 24px;
151+
height: 24px;
152+
line-height: 24px;
153+
}

wallets/client/components/card.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Link from 'next/link'
77
import RecvIcon from '@/svgs/arrow-left-down-line.svg'
88
import SendIcon from '@/svgs/arrow-right-up-line.svg'
99
import DragIcon from '@/svgs/draggable.svg'
10-
import { useWalletImage, useWalletSupport, useWalletStatus, WalletStatus, useProtocolTemplates } from '@/wallets/client/hooks'
10+
import { useWalletImage, useWalletSupport, useWalletStatus, WalletStatus } from '@/wallets/client/hooks'
1111
import { isWallet, urlify, walletDisplayName } from '@/wallets/lib/util'
1212
import { Draggable } from '@/wallets/client/components'
1313

@@ -55,15 +55,7 @@ export function WalletCard ({ wallet, draggable = false, index, ...props }) {
5555
}
5656

5757
function WalletLink ({ wallet, children }) {
58-
const support = useWalletSupport(wallet)
59-
const protocols = useProtocolTemplates(wallet)
60-
const firstSend = protocols.find(p => p.send)
61-
const firstRecv = protocols.find(p => !p.send)
62-
63-
let href = '/wallets'
64-
href += isWallet(wallet) ? `/${wallet.id}` : `/${urlify(wallet.name)}`
65-
href += support.send ? `/send/${urlify(firstSend.name)}` : `/receive/${urlify(firstRecv.name)}`
66-
58+
const href = '/wallets' + (isWallet(wallet) ? `/${wallet.id}` : `/${urlify(wallet.name)}`)
6759
return <Link href={href}>{children}</Link>
6860
}
6961

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import classNames from 'classnames'
2+
import { Button } from 'react-bootstrap'
3+
import ArrowLeft from '@/svgs/arrow-left-line.svg'
4+
5+
import { useBack, useSkip } from './hooks'
6+
7+
export function BackButton ({ className }) {
8+
const back = useBack()
9+
return (
10+
<Button className={classNames('me-3 text-muted nav-link fw-bold', className)} variant='link' onClick={back}>
11+
{/* 'theme' adds hover style */}
12+
<ArrowLeft className='theme' width={24} height={24} />
13+
</Button>
14+
)
15+
}
16+
17+
export function SkipButton ({ className }) {
18+
const skip = useSkip()
19+
return <Button className={classNames('ms-auto me-3 text-muted nav-link fw-bold', className)} variant='link' onClick={skip}>skip</Button>
20+
}

0 commit comments

Comments
 (0)