@@ -2,17 +2,16 @@ import { commands, OfferSummary, TakeOfferResponse } from '@/bindings';
22import ConfirmationDialog from '@/components/ConfirmationDialog' ;
33import Container from '@/components/Container' ;
44import Header from '@/components/Header' ;
5+ import { Loading } from '@/components/Loading' ;
56import { OfferCard } from '@/components/OfferCard' ;
67import { Button } from '@/components/ui/button' ;
78import { Input } from '@/components/ui/input' ;
89import { Label } from '@/components/ui/label' ;
910import { useErrors } from '@/hooks/useErrors' ;
10- import { toDecimal , toMojos } from '@/lib/utils' ;
11+ import { toMojos } from '@/lib/utils' ;
1112import { useWalletState } from '@/state' ;
12- import BigNumber from 'bignumber.js' ;
1313import { useEffect , useState } from 'react' ;
1414import { useNavigate , useParams } from 'react-router-dom' ;
15- import { Loading } from '@/components/Loading' ;
1615
1716export function ViewOffer ( ) {
1817 const { offer } = useParams ( ) ;
@@ -30,21 +29,17 @@ export function ViewOffer() {
3029 if ( ! offer ) return ;
3130
3231 const loadOffer = async ( ) => {
33- try {
34- setIsLoading ( true ) ;
35- setLoadingStatus ( 'Decoding offer...' ) ;
32+ setIsLoading ( true ) ;
33+ setLoadingStatus ( 'Fetching offer details...' ) ;
3634
37- setLoadingStatus ( 'Fetching offer details...' ) ;
38- const data = await commands . viewOffer ( { offer } ) ;
39-
40- setLoadingStatus ( 'Processing offer data...' ) ;
41- setSummary ( data . offer ) ;
42- } catch ( error : any ) {
43- setLoadingStatus ( 'Error loading offer' ) ;
44- addError ( error ) ;
45- } finally {
46- setIsLoading ( false ) ;
47- }
35+ commands
36+ . viewOffer ( { offer } )
37+ . then ( ( data ) => {
38+ setSummary ( data . offer ) ;
39+ setLoadingStatus ( 'Processing offer data...' ) ;
40+ } )
41+ . catch ( addError )
42+ . finally ( ( ) => setIsLoading ( false ) ) ;
4843 } ;
4944
5045 loadOffer ( ) ;
@@ -58,15 +53,13 @@ export function ViewOffer() {
5853 } ;
5954
6055 const take = async ( ) => {
61- try {
62- const result = await commands . takeOffer ( {
56+ await commands
57+ . takeOffer ( {
6358 offer : offer ! ,
6459 fee : toMojos ( fee || '0' , walletState . sync . unit . decimals ) ,
65- } ) ;
66- setResponse ( result ) ;
67- } catch ( error : any ) {
68- addError ( error ) ;
69- }
60+ } )
61+ . then ( ( result ) => setResponse ( result ) )
62+ . catch ( addError ) ;
7063 } ;
7164
7265 return (
0 commit comments