Skip to content

Commit 394c988

Browse files
committed
Error message vs direct display.
1 parent 23a663b commit 394c988

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

apps/dashboard/src/components/pay/RouteDiscovery.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
"use client";
2-
3-
import type { Project } from "@/api/projects";
42
import { addUniversalBridgeTokenRoute } from "@/api/universal-bridge/addRoute"; // Adjust the import path
5-
import type { Fee } from "@/api/universal-bridge/developer";
63
import { RouteDiscoveryCard } from "@/components/blocks/RouteDiscoveryCard";
74
import {
85
Form,
@@ -23,23 +20,19 @@ import { useTrack } from "hooks/analytics/useTrack";
2320
import { useState } from "react";
2421
import { useForm } from "react-hook-form";
2522
import { toast } from "sonner";
26-
27-
interface RouteDiscoveryProps {
28-
project: Project;
29-
teamId: string;
30-
teamSlug: string;
31-
fees: Fee;
32-
}
23+
import { useActiveWalletChain } from "thirdweb/react";
3324

3425
const TRACKING_CATEGORY = "token_discovery";
3526

36-
export const RouteDiscovery: React.FC<RouteDiscoveryProps> = () => {
27+
export const RouteDiscovery: React.FC = () => {
3728
const [isSubmitSuccess, setIsSubmitSuccess] = useState(false);
3829
const [isSubmitFail, setIsSubmitFailed] = useState(false);
30+
const [routeError, setError] = useState<Error>();
31+
const walletChain = useActiveWalletChain();
3932

4033
// State to track the selected chain ID directly from the NetworkSelectorButton
4134
const [selectedChainId, setSelectedChainId] = useState<number | undefined>(
42-
undefined,
35+
walletChain?.id,
4336
);
4437

4538
const form = useForm<RouteDiscoveryValidationSchema>({
@@ -94,9 +87,9 @@ export const RouteDiscovery: React.FC<RouteDiscoveryProps> = () => {
9487
});
9588
},
9689
onError: (err) => {
90+
setError(err);
9791
setIsSubmitFailed(true);
9892
toast.error("Token Submission Failed");
99-
console.error("Token route addition failed:", err);
10093

10194
// Get appropriate error message
10295
let errorMessage = "An unknown error occurred";
@@ -142,9 +135,9 @@ export const RouteDiscovery: React.FC<RouteDiscoveryProps> = () => {
142135
<p className="mb-2 text-red-600">
143136
Please double check the network and token address. If issues persist,
144137
please reach out to our support team.
145-
{submitDiscoveryMutation.error instanceof Error && (
138+
{routeError && (
146139
<span className="mt-1 block text-sm">
147-
Error: {submitDiscoveryMutation.error.message}
140+
Error: {routeError.message}
148141
</span>
149142
)}
150143
</p>
@@ -191,7 +184,6 @@ export const RouteDiscovery: React.FC<RouteDiscoveryProps> = () => {
191184
onSwitchChain={(chain) => {
192185
// When a chain is selected, capture its ID and name
193186
setSelectedChainId(chain.chainId);
194-
195187
// Update the form field value
196188
field.onChange(chain.chainId);
197189
}}

0 commit comments

Comments
 (0)