mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-21 14:04:03 +01:00
chore: toggle private hints (#304)
This commit is contained in:
parent
c1a84dcc8b
commit
5a212db898
6 changed files with 51 additions and 7 deletions
|
@ -78,12 +78,21 @@ export const invoiceResolvers = {
|
|||
Mutation: {
|
||||
createInvoice: async (
|
||||
_: undefined,
|
||||
params: { amount: number; description?: string; secondsUntil?: number },
|
||||
{
|
||||
amount,
|
||||
description,
|
||||
secondsUntil,
|
||||
includePrivate,
|
||||
}: {
|
||||
amount: number;
|
||||
description?: string;
|
||||
secondsUntil?: number;
|
||||
includePrivate?: boolean;
|
||||
},
|
||||
context: ContextType
|
||||
) => {
|
||||
await requestLimiter(context.ip, 'createInvoice');
|
||||
|
||||
const { amount, description, secondsUntil } = params;
|
||||
const { lnd } = context;
|
||||
|
||||
const getDate = (secondsUntil: number) => {
|
||||
|
@ -93,12 +102,19 @@ export const invoiceResolvers = {
|
|||
return date.toISOString();
|
||||
};
|
||||
|
||||
const invoiceParams = {
|
||||
tokens: amount,
|
||||
...(description && { description }),
|
||||
...(!!secondsUntil && { expires_at: getDate(secondsUntil) }),
|
||||
...(includePrivate && { is_including_private_channels: true }),
|
||||
};
|
||||
|
||||
logger.info('Creating invoice with params: %o', invoiceParams);
|
||||
|
||||
return await to<CreateInvoiceType>(
|
||||
createInvoiceRequest({
|
||||
lnd,
|
||||
...(description && { description }),
|
||||
...(!!secondsUntil && { expires_at: getDate(secondsUntil) }),
|
||||
tokens: amount,
|
||||
...invoiceParams,
|
||||
})
|
||||
);
|
||||
},
|
||||
|
|
|
@ -162,6 +162,7 @@ export const mutationTypes = gql`
|
|||
amount: Int!
|
||||
description: String
|
||||
secondsUntil: Int
|
||||
includePrivate: Boolean
|
||||
): newInvoiceType
|
||||
circularRebalance(route: String!): Boolean
|
||||
bosPay(
|
||||
|
|
|
@ -8,6 +8,7 @@ export type CreateInvoiceMutationVariables = Types.Exact<{
|
|||
amount: Types.Scalars['Int'];
|
||||
description?: Types.Maybe<Types.Scalars['String']>;
|
||||
secondsUntil?: Types.Maybe<Types.Scalars['Int']>;
|
||||
includePrivate?: Types.Maybe<Types.Scalars['Boolean']>;
|
||||
}>;
|
||||
|
||||
|
||||
|
@ -21,11 +22,12 @@ export type CreateInvoiceMutation = (
|
|||
|
||||
|
||||
export const CreateInvoiceDocument = gql`
|
||||
mutation CreateInvoice($amount: Int!, $description: String, $secondsUntil: Int) {
|
||||
mutation CreateInvoice($amount: Int!, $description: String, $secondsUntil: Int, $includePrivate: Boolean) {
|
||||
createInvoice(
|
||||
amount: $amount
|
||||
description: $description
|
||||
secondsUntil: $secondsUntil
|
||||
includePrivate: $includePrivate
|
||||
) {
|
||||
request
|
||||
id
|
||||
|
@ -50,6 +52,7 @@ export type CreateInvoiceMutationFn = Apollo.MutationFunction<CreateInvoiceMutat
|
|||
* amount: // value for 'amount'
|
||||
* description: // value for 'description'
|
||||
* secondsUntil: // value for 'secondsUntil'
|
||||
* includePrivate: // value for 'includePrivate'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
|
|
|
@ -5,11 +5,13 @@ export const CREATE_INVOICE = gql`
|
|||
$amount: Int!
|
||||
$description: String
|
||||
$secondsUntil: Int
|
||||
$includePrivate: Boolean
|
||||
) {
|
||||
createInvoice(
|
||||
amount: $amount
|
||||
description: $description
|
||||
secondsUntil: $secondsUntil
|
||||
includePrivate: $includePrivate
|
||||
) {
|
||||
request
|
||||
id
|
||||
|
|
|
@ -358,6 +358,7 @@ export type MutationCreateInvoiceArgs = {
|
|||
amount: Scalars['Int'];
|
||||
description?: Maybe<Scalars['String']>;
|
||||
secondsUntil?: Maybe<Scalars['Int']>;
|
||||
includePrivate?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ import { Title } from 'src/layouts/footer/Footer.styled';
|
|||
import { Link } from 'src/components/link/Link';
|
||||
import { InputWithDeco } from 'src/components/input/InputWithDeco';
|
||||
import { formatSeconds } from 'src/utils/helpers';
|
||||
import {
|
||||
MultiButton,
|
||||
SingleButton,
|
||||
} from 'src/components/buttons/multiButton/MultiButton';
|
||||
import { getErrorContent } from '../../../../utils/error';
|
||||
import { ColorButton } from '../../../../components/buttons/colorButton/ColorButton';
|
||||
import { mediaWidths, chartColors } from '../../../../styles/Themes';
|
||||
|
@ -61,6 +65,7 @@ export const CreateInvoiceCard = ({ color }: { color: string }) => {
|
|||
const [amount, setAmount] = useState(0);
|
||||
const [seconds, setSeconds] = useState(0);
|
||||
const [description, setDescription] = useState('');
|
||||
const [includePrivate, setIncludePrivate] = useState(false);
|
||||
|
||||
const [request, setRequest] = useState('');
|
||||
const [id, setId] = useState('');
|
||||
|
@ -126,7 +131,7 @@ export const CreateInvoiceCard = ({ color }: { color: string }) => {
|
|||
const handleEnter = () => {
|
||||
if (amount === 0) return;
|
||||
createInvoice({
|
||||
variables: { amount, description, secondsUntil: seconds },
|
||||
variables: { amount, description, secondsUntil: seconds, includePrivate },
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -159,6 +164,22 @@ export const CreateInvoiceCard = ({ color }: { color: string }) => {
|
|||
color={color}
|
||||
onEnter={() => handleEnter()}
|
||||
/>
|
||||
<InputWithDeco title={'Include Private Channels'} noInput={true}>
|
||||
<MultiButton>
|
||||
<SingleButton
|
||||
onClick={() => setIncludePrivate(true)}
|
||||
selected={includePrivate}
|
||||
>
|
||||
Yes
|
||||
</SingleButton>
|
||||
<SingleButton
|
||||
onClick={() => setIncludePrivate(false)}
|
||||
selected={!includePrivate}
|
||||
>
|
||||
No
|
||||
</SingleButton>
|
||||
</MultiButton>
|
||||
</InputWithDeco>
|
||||
<ColorButton
|
||||
onClick={() => handleEnter()}
|
||||
disabled={amount === 0}
|
||||
|
|
Loading…
Add table
Reference in a new issue