Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
bnonni committed May 7, 2022
2 parents 2ba23e5 + d40d521 commit e69de52
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 49 deletions.
101 changes: 58 additions & 43 deletions backend/sensei/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ const fetch = require('node-fetch');
const BASE_URL = process.env.BASE_URL;

const getUnusedAddress = async () => {
const res = await fetch(`${BASE_URL}/v1/node/wallet/address`, {
method: 'GET'
});
const res = await fetch(`${BASE_URL}/v1/node/wallet/address`);
console.log(res);
return await res.json();
}

const getBalance = async () => {
const res = await fetch(`${BASE_URL}/v1/node/wallet/balance`, {
method: 'GET'
});
const res = await fetch(`${BASE_URL}/v1/node/wallet/balance`);
console.log(res);
return await res.json();
}
Expand All @@ -23,34 +19,15 @@ const getChannels = async ({ page, searchTerm, take }) => {
method: 'GET'
});

return await channels;
return await channels.json();
}

const getPayments = async ({ filter = {}, pagination }) => {
const { page, take, } = pagination;

const res = await fetch(
`${BASE_URL}/v1/node/payments?page=${page}&take=${take}`,
);
const res = await fetch(`${BASE_URL}/v1/node/payments?page=${page}&take=${take}`);

return {
pagination: res.pagination,
payments: res.payments.map((payment) => {
return {
id: payment.id,
paymentHash: payment.payment_hash,
preimage: payment.preimage,
secret: payment.secret,
status: payment.status,
origin: payment.origin,
amtMsat: payment.amt_msat,
createdAt: payment.created_at,
updatedAt: payment.updated_at,
label: payment.label,
invoice: payment.invoice,
};
}),
};
return await res.json();
}

const getInfo = async () => {
Expand All @@ -69,21 +46,59 @@ const getInfo = async () => {
const getPeers = async () => {
const { peers } = await fetch(`${BASE_URL}/v1/node/peers`);

return {
peers: peers.map((peer) => {
return {
nodePubkey: peer.node_pubkey,
};
}),
};
return await peers.json();
}

const stopNode = async () => {
const res = await fetch(`${BASE_URL}/v1/node/stop`);
return res.json();
}

export {
getUnusedAddress,
getBalance,
getInfo,
getPeers,
getChannels,
getPayments
};
const createInvoice = async (amountMillisats, description) => {
const res = await fetch(`${BASE_URL}/v1/node/invoices`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({
amt_msat: amountMillisats,
description,
}),
});
return await res.json();
}

const payInvoice = async (invoice) => {
const res = await fetch(`${BASE_URL}/v1/node/invoices/pay`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({
invoice
})
}

);
return await res.json();
}

const keysend = async (destPubkey, amtMsat) => {
const res = await fetch(`${BASE_URL}/v1/node/keysend`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({
dest_pubkey: destPubkey,
amt_msat: amtMsat
})
}
);
}
2 changes: 2 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import React from 'react';
import {ContactsIcon, CrossIcon, GearIcon, MenuIcon} from '@bitcoin-design/bitcoin-icons-react/filled';
import {ChartSquareBarIcon} from '@heroicons/react/solid';
import NewFamily from './routes/NewFamily';
import Invite from './routes/Invite';

const Child = {};

Expand Down Expand Up @@ -56,6 +57,7 @@ function App() {

<Routes>
<Route path="onboarding" element={<Onboarding />} />
<Route path="invite" element={<Invite />} />
<Route path="new-family" element={<NewFamily />} />
<Route path="/" element={<Home />}>
<Route path="family" element={<Family />}>
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/components/InputText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const InputText = ({placeholder, value, type, onChange}) => {
return (
<input
type={type ? type : 'text'}
className="w-full p-4 rounded-md font-light text-lg text-black"
placeholder={placeholder}
value={value}
onChange={onChange}
/>
)
}

export default InputText;
6 changes: 5 additions & 1 deletion frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}

.default-bg {
@apply fixed h-screen w-screen;
@apply fixed h-screen w-screen z-0;
opacity: 0.10;
filter: blur(8px);
background-image: url('../public/pebbles.jpg');
Expand All @@ -19,4 +19,8 @@

h1, h2 {
@apply font-display;
}

.tile {
@apply rounded-lg bg-fam-bg-dark p-8 drop-shadow-lg my-4 border border-fam-teal border-solid space-y-4 flex flex-col;
}
21 changes: 17 additions & 4 deletions frontend/src/routes/Home.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import React from "react";
import { Link, Outlet } from "react-router-dom";
import Button from '../components/Button';
import {PlusIcon} from '@heroicons/react/solid';

const Home = () => {
return (
<div className="min-h-screen">
<div className="default-bg"></div>
<div className="min-w-screen min-h-screen p-8 flex flex-col justify-center">
<div className="min-w-screen min-h-screen p-8 flex flex-col justify-center z-10 relative">
<h1 className="text-2xl">Welcome, Jerry</h1>

<div className="rounded-md bg-fam-bg-dark p-8">
<h2>Balance</h2>
<p>1000 <span>sats</span></p>
<div className="rounded-lg bg-fam-bg-dark p-8 drop-shadow-lg my-4 border border-fam-teal border-solid">
<h2 className="mb-4">Your Balance</h2>
<p className="text-4xl">1000 <span>sats</span></p>
</div>

<div className="rounded-lg bg-fam-bg-dark p-8 drop-shadow-lg my-4 border border-fam-teal border-solid space-y-4 flex flex-col">
<h2>Members</h2>

<p className="text-lg">Your tribe has no members. Add&nbsp;one! </p>

<Link to="/invite">
<Button><PlusIcon className="w-8 h-8" /> <span>Add Member</span></Button>
</Link>
</div>

</div>
<Outlet />
</div>
Expand Down
53 changes: 53 additions & 0 deletions frontend/src/routes/Invite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import { Link } from "react-router-dom";
import Button from '../components/Button';
import {MailIcon, PlusIcon} from '@heroicons/react/solid';
import InputText from '../components/InputText';

const Invite = () => {
const [invited, setInvited] = React.useState(false)
const [invitedEmail, setInvitedEmail] = React.useState('')

return (
<div className="min-h-screen">
<div className="default-bg"></div>
<div className="min-w-screen min-h-screen p-8 flex flex-col justify-center z-10 relative">
{!invited ?
<div className="tile">
<h2>Invite Members</h2>

<p className="text-lg">Your tribe has no members. Add&nbsp;one! </p>

<InputText
type="email"
placeholder="[email protected]"
value={invitedEmail}
onChange={ (e)=>{setInvitedEmail(e.target.value)} }
/>

<Button onClick={() => setInvited(true)}>
<MailIcon className="w-8 h-8"/> <span>Invite Member</span>
</Button>
</div>
:
<div className="tile">
<h2>Invite Members</h2>

<p className="text-lg">
<strong>{invitedEmail}</strong> has been invited! Would you like to add another member?
</p>

<Button onClick={()=>{setInvited(false); setInvitedEmail('');}}>
<PlusIcon className="w-8 h-8" /> <span>Invite Another</span>
</Button>
<Link to="/">
<Button style="free">Return to Dashboard</Button>
</Link>
</div>
}
</div>
</div>
);
};

export default Invite;
3 changes: 2 additions & 1 deletion frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
colors: {
'fam-orange': '#ff9500',
'fam-orange-inactive': '#A68659',
'fam-bg-dark': '#3B474B'
'fam-bg-dark': '#3B474B',
'fam-teal': '#56737D'
},
backgroundImage: {
'mountains': "url('../public/mountains.jpg')",
Expand Down

0 comments on commit e69de52

Please sign in to comment.