Skip to content

Commit 8cca475

Browse files
author
Boopathi
committed
Add API fallback logic for blog, incubators, mentors, msmes, and education views for GitHub Pages compatibility
1 parent 6444b31 commit 8cca475

File tree

5 files changed

+114
-5
lines changed

5 files changed

+114
-5
lines changed

src/components/views/blog.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,31 @@ export default function BlogView({ isOpen, onOpenChange }: BlogViewProps) {
6161
const data = await response.json();
6262
setBlogPosts(data);
6363
} catch (err: any) {
64-
setError(err.message || "An unexpected error occurred.");
64+
// Fallback static data
65+
setBlogPosts([
66+
{
67+
title: "Fallback Blog Post 1",
68+
image: "https://placehold.co/600x400",
69+
excerpt: "This is a fallback blog post shown when the API is unavailable.",
70+
hint: "fallback",
71+
content: "This is the full content of Fallback Blog Post 1."
72+
},
73+
{
74+
title: "Fallback Blog Post 2",
75+
image: "https://placehold.co/600x400",
76+
excerpt: "Another example fallback post.",
77+
hint: "fallback",
78+
content: "This is the full content of Fallback Blog Post 2."
79+
},
80+
{
81+
title: "Fallback Blog Post 3",
82+
image: "https://placehold.co/600x400",
83+
excerpt: "Fallback content keeps your UI looking good!",
84+
hint: "fallback",
85+
content: "This is the full content of Fallback Blog Post 3."
86+
},
87+
]);
88+
setError(null); // Hide error, show fallback
6589
} finally {
6690
setIsLoading(false);
6791
}

src/components/views/education.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,20 @@ export default function EducationView({ isOpen, onOpenChange, onApplicationSucce
9292
const data = await response.json();
9393
setEducationPrograms(data);
9494
} catch (err: any) {
95-
setError(err.message || "An unexpected error occurred.");
95+
// Fallback static data
96+
setEducationPrograms([
97+
{
98+
title: "Fallback Program",
99+
description: "This is a fallback education program.",
100+
features: [
101+
{ icon: "Check", name: "Fallback Feature" }
102+
],
103+
sessions: [
104+
{ language: "English", date: "TBA", time: "TBA" }
105+
],
106+
},
107+
]);
108+
setError(null); // Hide error, show fallback
96109
} finally {
97110
setIsLoading(false);
98111
}

src/components/views/incubators.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,28 @@ export default function IncubatorsView({ isOpen, onOpenChange, isLoggedIn, hasSu
137137
const data = await response.json();
138138
setIncubators(data);
139139
} catch (err: any) {
140-
setError(err.message || 'An unexpected error occurred.');
140+
// Fallback static data
141+
setIncubators([
142+
{
143+
name: "Fallback Incubator",
144+
image: "https://placehold.co/600x400",
145+
hint: "fallback",
146+
location: "Fallback City",
147+
rating: 5,
148+
reviews: 10,
149+
description: "This is a fallback incubator shown when the API is unavailable.",
150+
metrics: { startups: "10+", funding: "$1M+", successRate: "90%" },
151+
focus: ["Tech", "Innovation"],
152+
details: {
153+
overview: "Fallback overview.",
154+
services: [{ title: "Mentorship", description: "Expert guidance." }],
155+
benefits: ["Networking"],
156+
eligibility: { focusAreas: "All", requirements: ["None"] },
157+
timeline: [{ event: "Application", period: "Year-round" }],
158+
},
159+
},
160+
]);
161+
setError(null); // Hide error, show fallback
141162
} finally {
142163
setIsLoading(false);
143164
}

src/components/views/mentors.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,22 @@ export default function MentorsView({ isOpen, onOpenChange, isLoggedIn, hasSubsc
9191
const data = await response.json();
9292
setMentors(data);
9393
} catch (err: any) {
94-
setError(err.message || 'An unexpected error occurred.');
94+
// Fallback static data
95+
setMentors([
96+
{
97+
name: "Fallback Mentor",
98+
avatar: "https://placehold.co/100x100",
99+
hint: "fallback",
100+
title: "Expert in fallback logic",
101+
expertise: ["Tech", "Business"],
102+
bio: "This is a fallback mentor shown when the API is unavailable.",
103+
rating: 5,
104+
socials: { x: "#", linkedin: "#" },
105+
hourlyRate: "$0",
106+
availability: {},
107+
},
108+
]);
109+
setError(null); // Hide error, show fallback
95110
} finally {
96111
setIsLoading(false);
97112
}

src/components/views/msmes.tsx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,43 @@ export default function MsmesView({ isOpen, onOpenChange, isLoggedIn, hasSubscri
131131
setCorporateChallenges(data.corporateChallenges || []);
132132
setMsmeCollaborations(data.msmeCollaborations || []);
133133
} catch (err: any) {
134-
setError(err.message || 'An unexpected error occurred.');
134+
// Fallback static data
135+
setCorporateChallenges([
136+
{
137+
company: "Fallback Corp",
138+
logo: "https://placehold.co/56x56",
139+
hint: "fallback",
140+
title: "Fallback Challenge",
141+
reward: "$1000",
142+
description: "This is a fallback corporate challenge.",
143+
details: {
144+
about: "Fallback about.",
145+
problemStatements: 1,
146+
stages: 1,
147+
rewardPerStatement: "$1000",
148+
mission: "Fallback mission.",
149+
participation: "Open",
150+
rewards: "Recognition",
151+
},
152+
},
153+
]);
154+
setMsmeCollaborations([
155+
{
156+
name: "Fallback MSME",
157+
logo: "https://placehold.co/56x56",
158+
hint: "fallback",
159+
sector: "Fallback Sector",
160+
description: "This is a fallback MSME collaboration.",
161+
details: {
162+
about: "Fallback about.",
163+
scope: ["Tech"],
164+
lookingFor: "Partners",
165+
benefits: ["Networking"],
166+
contact: { name: "Fallback Contact", title: "Manager" },
167+
},
168+
},
169+
]);
170+
setError(null); // Hide error, show fallback
135171
} finally {
136172
setIsLoading(false);
137173
}

0 commit comments

Comments
 (0)