Skip to content

Commit

Permalink
fix(provider): fixed issue with types
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-arc10 committed Jan 20, 2025
1 parent ba5f01d commit 90e7e12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import consoleClient from "@src/utils/consoleClient";
import { useWallet } from "../WalletProvider";

type ContextType = {
providerDetails: ProviderDetails | undefined;
providerDashboard: ProviderDashoard | undefined;
providerDetails: ProviderDetails | null | undefined;
providerDashboard: ProviderDashoard | null | undefined;
isLoadingProviderDetails: boolean;
isLoadingProviderDashboard: boolean;
};
Expand All @@ -18,12 +18,12 @@ const ProviderContext = React.createContext<ContextType>({} as ContextType);
export const ProviderContextProvider = ({ children }) => {
const { address } = useWallet();

const { data: providerDetails, isLoading: isLoadingProviderDetails } = useQuery(
const { data: providerDetails, isLoading: isLoadingProviderDetails } = useQuery<ProviderDetails | null>(
"providerDetails",
async () => {
try {
return await consoleClient.get(`/v1/providers/${address}`);
} catch (error: any) {
return await consoleClient.get<ProviderDetails, ProviderDetails>(`/v1/providers/${address}`);
} catch (error) {
if (error.response?.status === 404) {
return null; // Return null for non-existent providers
}
Expand All @@ -37,12 +37,12 @@ export const ProviderContextProvider = ({ children }) => {
}
);

const { data: providerDashboard, isLoading: isLoadingProviderDashboard } = useQuery<ProviderDashoard>(
const { data: providerDashboard, isLoading: isLoadingProviderDashboard } = useQuery<ProviderDashoard | null>(
"providerDashboard",
async () => {
try {
return await consoleClient.get(`/internal/provider-dashboard/${address}`);
} catch (error: any) {
} catch (error) {
if (error.response?.status === 404) {
return null; // Return null for non-existent dashboard data
}
Expand Down
2 changes: 1 addition & 1 deletion apps/provider-console/src/pages/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SettingsPage: React.FC = () => {

const { providerDetails } = useProvider();
const { activeControlMachine } = useControlMachine();
const [url, setUrl] = useState(() => stripProviderPrefixAndPort(providerDetails?.hostUri) || "");
const [url, setUrl] = useState(() => stripProviderPrefixAndPort(providerDetails?.hostUri ?? "") || "");

const handleUrlUpdate = async () => {
try {
Expand Down

0 comments on commit 90e7e12

Please sign in to comment.