Skip to content

Commit d84baa2

Browse files
Merge branch 'develop' into sr/issue-757/simple-wallet-setup
2 parents 50dd027 + bd44a5e commit d84baa2

File tree

9 files changed

+177
-7
lines changed

9 files changed

+177
-7
lines changed

api/schema/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const PermissionResolver = require('./resolvers/PermissionResolver')
1313
const ProjectResolver = require('./resolvers/ProjectResolver')
1414
const RateResolver = require('./resolvers/RateResolver')
1515
const TimeEntryResolver = require('./resolvers/TimeEntryResolver')
16+
const WalletResolver = require('./resolvers/WalletResolver')
1617

1718
//import types
1819
const AllocationType = require('./types/AllocationType')
@@ -26,6 +27,7 @@ const PermissionType = require('./types/PermissionType')
2627
const ProjectType = require('./types/ProjectType')
2728
const RateType = require('./types/RateType')
2829
const TimeEntry = require('./types/TimeEntryType')
30+
const Wallet = require('./types/WalletType')
2931

3032
//merge types
3133
const typeDefs = mergeTypeDefs([
@@ -39,7 +41,8 @@ const typeDefs = mergeTypeDefs([
3941
PermissionType,
4042
ProjectType,
4143
RateType,
42-
TimeEntry
44+
TimeEntry,
45+
Wallet
4346
])
4447

4548
//merge resolvers
@@ -54,7 +57,8 @@ const resolvers = mergeResolvers([
5457
PermissionResolver,
5558
ProjectResolver,
5659
RateResolver,
57-
TimeEntryResolver
60+
TimeEntryResolver,
61+
WalletResolver
5862
])
5963

6064
// Export generated schema
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const apiModules = require('../../modules')
2+
3+
module.exports = {
4+
5+
Wallet: {
6+
},
7+
Query: {
8+
},
9+
Mutation: {
10+
updateContributorOnChainAddress: async (root, { contributor_id, address }, { models }) => {
11+
const contributorWallet = await models.Wallet.findOne({
12+
where: {
13+
contributor_id: contributor_id
14+
}
15+
})
16+
if (!contributorWallet) {
17+
const createFields = {
18+
contributor_id: contributor_id,
19+
onchain_address: address
20+
}
21+
const wallet = await models.Wallet.create({
22+
...createFields
23+
})
24+
return wallet
25+
}
26+
await models.Wallet.update({
27+
onchain_address: address
28+
}, {
29+
where: {
30+
id: contributorWallet.get('id')
31+
}
32+
})
33+
return models.Wallet.findOne({
34+
where: {
35+
contributor_id: contributor_id
36+
}
37+
})
38+
}
39+
}
40+
41+
}

api/schema/types/WalletType.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const { gql } = require('apollo-server')
2+
3+
module.exports = gql`
4+
5+
type Wallet {
6+
id: Int!
7+
contributor_id: Int
8+
project_id: Int
9+
onchain_address: String
10+
invoice_macaroon: String
11+
lnd_host: String
12+
lnd_port: Int
13+
btcps_api_key: String
14+
balance: Int
15+
balance_last_updated: String
16+
alby_oauth_token: String
17+
voltage_node_id: String
18+
voltage_api_key: String
19+
}
20+
21+
type Mutation {
22+
updateContributorOnChainAddress(
23+
contributor_id: Int
24+
address: String
25+
): Wallet
26+
}
27+
28+
`

public/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
66
<link
77
rel="stylesheet"
8-
href="https://use.fontawesome.com/releases/v5.13.1/css/all.css"
8+
href="https://use.fontawesome.com/releases/v6.4.0/css/all.css"
99
/>
1010
<link
1111
rel="stylesheet"
12-
href="https://use.fontawesome.com/releases/v5.13.1/css/v4-shims.css"
12+
href="https://use.fontawesome.com/releases/v6.4.0/css/v4-shims.css"
1313
/>
1414
<meta name="viewport" content="width=device-width, initial-scale=1" />
1515
<meta name="theme-color" content="#000000" />

srcv2/components/Overlay.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react'
2+
import { Modal, Icon } from '@material-ui/core'
3+
4+
import Section from './Section'
5+
6+
const Overlay = ({
7+
open,
8+
setOpen,
9+
buttonText,
10+
buttonAction,
11+
goBackAction,
12+
height = '',
13+
fullScreen,
14+
children,
15+
containerClassName,
16+
position = 'bottom'
17+
}) => {
18+
19+
return (
20+
<div className='Overlay'>
21+
<Modal
22+
open={open}
23+
onClose={() => { setOpen(false) }}
24+
className={'modal fixed inset-0 flex bg-black bg-opacity-50 items-center justify-center transition-opacity duration-300 z-40'}
25+
>
26+
<div className={'Overlay fixed inset-5'} onClick={() => { setOpen(false) }}>
27+
<div
28+
className={`bg-white flex flex-col rounded-lg border-2 !py-3 px-6 ${fullScreen ? 'h-full' : position} ${height} ${containerClassName}`}
29+
>
30+
<div className='y-3'>
31+
<Icon
32+
className={`icon fas fa-arrow-left my-3 !w-8 ${goBackAction ? 'visible' : 'invisible'}`}
33+
onClick={() => { goBackAction() }}
34+
/>
35+
<Icon
36+
className={`icon fas fa-x !w-8 my-3 absolute top-4 right-4`}
37+
onClick={() => { setOpen(false) }}
38+
/>
39+
</div>
40+
<div className='flex-grow mt-5'>
41+
{ children }
42+
</div>
43+
<button
44+
className={`bg-setlife rounded-full py-2 w-full font-bold text-white mt-4 mb-2 self-end ${buttonText ? 'visible' : 'invisible'}`}
45+
onClick={() => { buttonAction() }}
46+
type='button'
47+
>
48+
{buttonText}
49+
</button>
50+
</div>
51+
</div>
52+
</Modal>
53+
</div>
54+
)
55+
}
56+
57+
export default Overlay

srcv2/components/Selector.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import React from 'react'
22

33
const Selector = ({ title, renderOptions, openOptions, setOpenOptions, loadingOptions }) => {
4+
5+
const selectorOptions = renderOptions()
6+
47
return (
58
<div>
69
<button type='button' className='border border-light rounded-lg px-4 py-1 w-full' onClick={() => setOpenOptions(!openOptions)}>
710
<div className='grid grid-flow-col auto-cols-max flex justify-between'>
811
<p className='text-black text-left'>{title}</p>
9-
<svg className='-mr-1 ml-2 h-5 w-5' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor' aria-hidden='true'>
12+
<svg className='-mr-1 ml-2 h-5 w-5 h-full' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor' aria-hidden='true'>
1013
<path fillRule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clipRule='evenodd' />
1114
</svg>
1215
</div>
@@ -23,7 +26,11 @@ const Selector = ({ title, renderOptions, openOptions, setOpenOptions, loadingOp
2326
{loadingOptions &&
2427
'Loading'
2528
}
26-
{renderOptions()}
29+
{selectorOptions.length == 0 && !loadingOptions ? (
30+
'No options available'
31+
) : (
32+
selectorOptions
33+
)}
2734
</div>
2835
</div>
2936
}

srcv2/components/Step.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
3+
const Step = ({
4+
title,
5+
number
6+
}) => {
7+
8+
return (
9+
<div className='Step flex mt-10'>
10+
<div className='w-10 h-10 rounded-full bg-setlife text-white flex items-center justify-center'>
11+
<p className='font-bold text-lg'>{number}</p>
12+
</div>
13+
<p className='mt-2 ml-3 text-sm'>{title}</p>
14+
</div>
15+
)
16+
}
17+
18+
export default Step

srcv2/styles/Overlay.scss

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.Overlay {
2+
.bottom {
3+
position: absolute;
4+
bottom: 0;
5+
left: 0;
6+
right: 0;
7+
}
8+
.top {
9+
position: absolute;
10+
top: 0;
11+
left: 0;
12+
right: 0;
13+
}
14+
}

srcv2/styles/index.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ code {
3131
//Components
3232
@import './AllocationsList.scss';
3333
@import './AllocationTile.scss';
34-
@import './CreatePaymentFloatingBadge.scss';
34+
@import './CreatePaymentFloatingBadge.scss';
35+
@import './Overlay.scss'

0 commit comments

Comments
 (0)