mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 22:25:21 +01:00
chore: 🔧 add error handling
This commit is contained in:
parent
c221c5cc1c
commit
8a2ac677c3
3 changed files with 18 additions and 4 deletions
|
@ -8,6 +8,8 @@ import { InputWithDeco } from 'src/components/input/InputWithDeco';
|
|||
import { ColorButton } from 'src/components/buttons/colorButton/ColorButton';
|
||||
import { usePayLnUrlMutation } from 'src/graphql/mutations/__generated__/lnUrl.generated';
|
||||
import { Link } from 'src/components/link/Link';
|
||||
import { toast } from 'react-toastify';
|
||||
import { getErrorContent } from 'src/utils/error';
|
||||
|
||||
const ModalText = styled.div`
|
||||
width: 100%;
|
||||
|
@ -34,7 +36,9 @@ export const LnPay: FC<LnPayProps> = ({ request }) => {
|
|||
const [amount, setAmount] = useState<number>(min);
|
||||
const [comment, setComment] = useState<string>('');
|
||||
|
||||
const [payLnUrl, { data, loading }] = usePayLnUrlMutation();
|
||||
const [payLnUrl, { data, loading }] = usePayLnUrlMutation({
|
||||
onError: error => toast.error(getErrorContent(error)),
|
||||
});
|
||||
|
||||
if (!callback) {
|
||||
return <ModalText>Missing information from LN Service</ModalText>;
|
||||
|
|
|
@ -11,6 +11,8 @@ import { useGetInvoiceStatusChangeLazyQuery } from 'src/graphql/queries/__genera
|
|||
import { chartColors } from 'src/styles/Themes';
|
||||
import { CheckCircle } from 'react-feather';
|
||||
import { Link } from 'src/components/link/Link';
|
||||
import { getErrorContent } from 'src/utils/error';
|
||||
import { toast } from 'react-toastify';
|
||||
import { Timer } from '../../account/createInvoice/Timer';
|
||||
|
||||
const Center = styled.div`
|
||||
|
@ -49,11 +51,15 @@ export const LnWithdraw: FC<LnWithdrawProps> = ({ request }) => {
|
|||
defaultDescription || ''
|
||||
);
|
||||
|
||||
const [withdraw, { data, loading }] = useWithdrawLnUrlMutation();
|
||||
const [withdraw, { data, loading }] = useWithdrawLnUrlMutation({
|
||||
onError: error => toast.error(getErrorContent(error)),
|
||||
});
|
||||
const [
|
||||
checkStatus,
|
||||
{ data: statusData, loading: statusLoading, error },
|
||||
] = useGetInvoiceStatusChangeLazyQuery();
|
||||
] = useGetInvoiceStatusChangeLazyQuery({
|
||||
onError: error => toast.error(getErrorContent(error)),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading && data?.lnUrlWithdraw) {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { FC, useEffect } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
import { ColorButton } from 'src/components/buttons/colorButton/ColorButton';
|
||||
import { Separation } from 'src/components/generic/Styled';
|
||||
import { LoadingCard } from 'src/components/loading/LoadingCard';
|
||||
import { Title } from 'src/components/typography/Styled';
|
||||
import { useFetchLnUrlMutation } from 'src/graphql/mutations/__generated__/lnUrl.generated';
|
||||
import { getErrorContent } from 'src/utils/error';
|
||||
import styled from 'styled-components';
|
||||
import { LnPay } from './LnPay';
|
||||
import { LnWithdraw } from './LnWithdraw';
|
||||
|
@ -21,7 +23,9 @@ type lnUrlProps = {
|
|||
export const LnUrlModal: FC<lnUrlProps> = ({ url, type }) => {
|
||||
const fullUrl = new URL(url);
|
||||
|
||||
const [fetchLnUrl, { data, loading }] = useFetchLnUrlMutation();
|
||||
const [fetchLnUrl, { data, loading }] = useFetchLnUrlMutation({
|
||||
onError: error => toast.error(getErrorContent(error)),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!type) {
|
||||
|
|
Loading…
Add table
Reference in a new issue