File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
app/(main)/dispute-template Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ import ReactMarkdown from "components/ReactMarkdown";
2626import FetchDisputeRequestInput , { DisputeRequest } from "./FetchDisputeRequestInput" ;
2727import FetchFromIDInput from "./FetchFromIdInput" ;
2828import CustomContextInputs from "./CustomContextInputs" ;
29+ import { debounceErrorToast } from "utils/debounceErrorToast" ;
30+ import { isEmpty } from "utils/isEmtpy" ;
2931
3032const Container = styled . div `
3133 height: auto;
@@ -193,12 +195,14 @@ const DisputeTemplateView = () => {
193195 if ( customContext ) initialContext = { ...initialContext , ...customContext } ;
194196
195197 const fetchData = async ( ) => {
198+ if ( isEmpty ( disputeTemplateInput ) ) return ;
196199 try {
197200 const data = dataMappingsInput ? await executeActions ( JSON . parse ( dataMappingsInput ) , initialContext ) : { } ;
198201 const finalDisputeDetails = populateTemplate ( disputeTemplateInput , data ) ;
199202 setDisputeDetails ( finalDisputeDetails ) ;
200- } catch ( e ) {
203+ } catch ( e : any ) {
201204 console . error ( e ) ;
205+ debounceErrorToast ( e ?. message ) ;
202206 setDisputeDetails ( undefined ) ;
203207 } finally {
204208 setLoading ( false ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { isUndefined } from "utils/isUndefined";
55
66import { graphql } from "src/graphql-generated" ;
77import { DisputeTemplateQuery } from "src/graphql-generated/graphql" ;
8+ import { isEmpty } from "utils/isEmtpy" ;
89
910const disputeTemplateQuery = graphql ( `
1011 query DisputeTemplate($id: ID!) {
@@ -18,7 +19,7 @@ const disputeTemplateQuery = graphql(`
1819` ) ;
1920
2021export const useDisputeTemplateFromId = ( templateId ?: string ) => {
21- const isEnabled = ! isUndefined ( templateId ) ;
22+ const isEnabled = ! isUndefined ( templateId ) && ! isEmpty ( templateId ) ;
2223 const { graphqlBatcher } = useGraphqlBatcher ( ) ;
2324
2425 return useQuery < DisputeTemplateQuery > ( {
Original file line number Diff line number Diff line change 1+ export const isEmpty = ( str : string ) : boolean => str . trim ( ) === "" ;
You can’t perform that action at this time.
0 commit comments