Skip to content

Commit a270973

Browse files
committed
refactor(web-devtools): error-display
1 parent 2ccc5cd commit a270973

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

web-devtools/src/app/(main)/dispute-template/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import ReactMarkdown from "components/ReactMarkdown";
2626
import FetchDisputeRequestInput, { DisputeRequest } from "./FetchDisputeRequestInput";
2727
import FetchFromIDInput from "./FetchFromIdInput";
2828
import CustomContextInputs from "./CustomContextInputs";
29+
import { debounceErrorToast } from "utils/debounceErrorToast";
30+
import { isEmpty } from "utils/isEmtpy";
2931

3032
const 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);

web-devtools/src/hooks/queries/useDisputeTemplateFromId.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isUndefined } from "utils/isUndefined";
55

66
import { graphql } from "src/graphql-generated";
77
import { DisputeTemplateQuery } from "src/graphql-generated/graphql";
8+
import { isEmpty } from "utils/isEmtpy";
89

910
const disputeTemplateQuery = graphql(`
1011
query DisputeTemplate($id: ID!) {
@@ -18,7 +19,7 @@ const disputeTemplateQuery = graphql(`
1819
`);
1920

2021
export 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>({

web-devtools/src/utils/isEmtpy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const isEmpty = (str: string): boolean => str.trim() === "";

0 commit comments

Comments
 (0)