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";
26
26
import FetchDisputeRequestInput , { DisputeRequest } from "./FetchDisputeRequestInput" ;
27
27
import FetchFromIDInput from "./FetchFromIdInput" ;
28
28
import CustomContextInputs from "./CustomContextInputs" ;
29
+ import { debounceErrorToast } from "utils/debounceErrorToast" ;
30
+ import { isEmpty } from "utils/isEmtpy" ;
29
31
30
32
const Container = styled . div `
31
33
height: auto;
@@ -193,12 +195,14 @@ const DisputeTemplateView = () => {
193
195
if ( customContext ) initialContext = { ...initialContext , ...customContext } ;
194
196
195
197
const fetchData = async ( ) => {
198
+ if ( isEmpty ( disputeTemplateInput ) ) return ;
196
199
try {
197
200
const data = dataMappingsInput ? await executeActions ( JSON . parse ( dataMappingsInput ) , initialContext ) : { } ;
198
201
const finalDisputeDetails = populateTemplate ( disputeTemplateInput , data ) ;
199
202
setDisputeDetails ( finalDisputeDetails ) ;
200
- } catch ( e ) {
203
+ } catch ( e : any ) {
201
204
console . error ( e ) ;
205
+ debounceErrorToast ( e ?. message ) ;
202
206
setDisputeDetails ( undefined ) ;
203
207
} finally {
204
208
setLoading ( false ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { isUndefined } from "utils/isUndefined";
5
5
6
6
import { graphql } from "src/graphql-generated" ;
7
7
import { DisputeTemplateQuery } from "src/graphql-generated/graphql" ;
8
+ import { isEmpty } from "utils/isEmtpy" ;
8
9
9
10
const disputeTemplateQuery = graphql ( `
10
11
query DisputeTemplate($id: ID!) {
@@ -18,7 +19,7 @@ const disputeTemplateQuery = graphql(`
18
19
` ) ;
19
20
20
21
export const useDisputeTemplateFromId = ( templateId ?: string ) => {
21
- const isEnabled = ! isUndefined ( templateId ) ;
22
+ const isEnabled = ! isUndefined ( templateId ) && ! isEmpty ( templateId ) ;
22
23
const { graphqlBatcher } = useGraphqlBatcher ( ) ;
23
24
24
25
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