Skip to content

Commit 6949724

Browse files
committed
Fixed : undefined Behaviour
1 parent a121bee commit 6949724

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/pages/resources/components/ResourceCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface CenterCardProps {
1717
const ResourceCard = ({ repo }: CenterCardProps) => {
1818

1919
const handleRedirect = (url: string) => {
20+
if (!url) return;
2021
console.log(window.location.href);
2122
if (url.startsWith("https://")) {
2223
window.location.href = url;
@@ -27,7 +28,7 @@ const ResourceCard = ({ repo }: CenterCardProps) => {
2728
}
2829

2930
return (
30-
31+
3132
<Card className="mb-4 overflow-hidden border-0 shadow-md" onClick={() => handleRedirect(repo.url)}>
3233
<Accordion type="single" className="w-full">
3334
<AccordionItem value={repo.url} className="border-0">

src/pages/resources/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Loader } from '@/components/layout/Loader';
1010

1111
const ResourcePage = () => {
1212

13-
const [data, setData] = useState<any[] | null>([]);
13+
const [data, setData] = useState<any[]>([]);
1414
const [loading, setLoading] = useState(true);
1515

1616
useEffect(() => {
@@ -25,6 +25,14 @@ const ResourcePage = () => {
2525
});
2626
return;
2727
}
28+
if (!data) {
29+
toast({
30+
title: "Error",
31+
description: "Could not fetch data",
32+
variant: "destructive"
33+
});
34+
return;
35+
}
2836
setData(data);
2937
setLoading(false);
3038
};

0 commit comments

Comments
 (0)