diff --git a/src/features/cashu/hooks/useCashu.ts b/src/features/cashu/hooks/useCashu.ts index ade89a571..628002aee 100644 --- a/src/features/cashu/hooks/useCashu.ts +++ b/src/features/cashu/hooks/useCashu.ts @@ -34,7 +34,15 @@ function useCashu() { }, }); + const { mutate: getQuoteState } = useMutation({ + mutationFn: (quote_id: string) => api.get(`/api/v1/ditto/cashu/quote/${quote_id}`), + onSuccess: () => { + queryClient.refetchQueries({ queryKey: ['cashu', 'nutzap', 'info'] }); + }, + }); + return { + getQuoteState, createQuote, createWallet, createNutzapInfo, diff --git a/src/features/cashu/index.tsx b/src/features/cashu/index.tsx index 924a945c4..0ba463df8 100644 --- a/src/features/cashu/index.tsx +++ b/src/features/cashu/index.tsx @@ -21,11 +21,12 @@ const messages = defineMessages({ mint_placeholder: { id: 'cashu.wallet.mint_placeholder', defaultMessage: 'https://' }, submit_success: { id: 'generic.saved', defaultMessage: 'Saved!' }, create_cashu_quote: { id: 'cashu.quote', defaultMessage: 'Create Cashu Quote' }, + get_cashu_quote_state: { id: 'cashu.quote.state', defaultMessage: 'Create Cashu Quote' }, }); const Cashu = () => { const intl = useIntl(); - const { createWallet, createNutzapInfo, swapCashuToWallet, createQuote } = useCashu(); + const { createWallet, createNutzapInfo, swapCashuToWallet, createQuote, getQuoteState } = useCashu(); const [mints, setMints] = useState([]); @@ -135,6 +136,27 @@ const Cashu = () => { }); }; + const handleGetMintQuoteState: React.FormEventHandler = async (event) => { + event.preventDefault(); + getQuoteState(mints[0], { + onSuccess: async () => { + toast.success(messages.submit_success); + }, + onError: async (err) => { + if (err instanceof HTTPError) { + try { + const { error } = await err.response.json(); + if (typeof error === 'string') { + toast.error(error); + return; + } + } catch { /* empty */ } + } + toast.error(err.message); + }, + }); + }; + return (
@@ -230,6 +252,30 @@ const Cashu = () => {
+ +
+ + + + + + + + + + +
); }; diff --git a/src/locales/en.json b/src/locales/en.json index 585cdcc9a..333dc2926 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1163,6 +1163,7 @@ "cashu.nutzap.info": "Your nutzap info", "cashu.nutzap.swap": "Swap your Cashu", "cashu.quote": "Create Cashu Quote", + "cashu.quote.state": "Get Cashu Quote State", "cashu.wallet.mints": "Your mints", "cashu.wallet.mint_placeholder": "https://", "nostr_extension.found": "Sign in with browser extension.",