diff --git a/client/data/disputes/hooks.ts b/client/data/disputes/hooks.ts index 256faf30152..e3797499537 100644 --- a/client/data/disputes/hooks.ts +++ b/client/data/disputes/hooks.ts @@ -15,6 +15,7 @@ import type { CachedDisputes, DisputesSummary, } from 'wcpay/types/disputes'; +import type { ApiError } from 'wcpay/types/errors'; import { STORE_NAME } from '../constants'; import { disputeAwaitingResponseStatuses } from 'wcpay/disputes/filters/config'; @@ -25,16 +26,20 @@ import { disputeAwaitingResponseStatuses } from 'wcpay/disputes/filters/config'; export const useDispute = ( id: string ): { - dispute: Dispute; + dispute?: Dispute; + error?: ApiError; isLoading: boolean; doAccept: () => void; } => { - const { dispute, isLoading } = useSelect( + const { dispute, error, isLoading } = useSelect( ( select ) => { - const { getDispute, isResolving } = select( STORE_NAME ); + const { getDispute, getDisputeError, isResolving } = select( + STORE_NAME + ); return { - dispute: getDispute( id ), + dispute: getDispute( id ), + error: getDisputeError( id ), isLoading: isResolving( 'getDispute', [ id ] ), }; }, @@ -44,7 +49,7 @@ export const useDispute = ( const { acceptDispute } = useDispatch( STORE_NAME ); const doAccept = () => acceptDispute( id ); - return { dispute, isLoading, doAccept }; + return { dispute, isLoading, error, doAccept }; }; /**