Skip to content

Commit d2877c3

Browse files
committed
Made the Archotect page Dynamic and also made the Architect detail page
1 parent 6abcbad commit d2877c3

4 files changed

Lines changed: 303 additions & 151 deletions

File tree

src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import Developers from "./pages/categories/Developers";
2424
import Architects from "./pages/categories/Architects";
2525
import Contractors from "./pages/categories/Contractors";
2626
import CategoriesLayout from "./pages/categories/CategoriesLayout";
27+
import ArchitectDetail from "./pages/categories/ArchitectDetail";
28+
29+
2730
// Import i18n configuration
2831
import './i18n';
2932

@@ -48,6 +51,7 @@ const AppRoutes = () => {
4851
<Route path="developers" element={<Developers />} />
4952
<Route path="architects" element={<Architects />} />
5053
<Route path="contractors" element={<Contractors />} />
54+
<Route path="architect-detail/:id" element={<ArchitectDetail />} />
5155
</Route>
5256
<Route path="/auth" element={<AuthLayout />}>
5357
<Route path="login" element={<Login />} />

src/integrations/supabase/types.ts

21.8 KB
Binary file not shown.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import React, { useEffect, useState } from "react";
2+
import { useParams, useNavigate } from "react-router-dom";
3+
import { supabase } from "@/integrations/supabase/client";
4+
import Navbar from "@/components/Navbar";
5+
import Footer from "@/components/Footer";
6+
import { Loader2 } from "lucide-react";
7+
8+
export default function ArchitectDetail() {
9+
const { id } = useParams<{ id: string }>();
10+
const navigate = useNavigate();
11+
const [architect, setArchitect] = useState<any>(null);
12+
const [loading, setLoading] = useState(true);
13+
14+
useEffect(() => {
15+
const fetchArchitect = async () => {
16+
if (!id) return;
17+
18+
setLoading(true);
19+
const { data, error } = await supabase
20+
.from("architects")
21+
.select("*")
22+
.eq("id", Number(id))
23+
.single();
24+
25+
console.log("Supabase data:", data);
26+
console.log("Supabase error:", error);
27+
28+
if (error) {
29+
console.error("Error fetching architect:", error);
30+
} else {
31+
setArchitect(data);
32+
}
33+
setLoading(false);
34+
};
35+
36+
fetchArchitect();
37+
}, [id]);
38+
39+
if (loading) {
40+
return (
41+
<div className="flex items-center justify-center h-screen">
42+
<Loader2 className="animate-spin w-8 h-8 text-gray-600" />
43+
</div>
44+
);
45+
}
46+
47+
if (!architect) {
48+
return (
49+
<div className="min-h-screen flex flex-col items-center justify-center text-center">
50+
<p className="text-lg text-gray-600 mb-4">Architect not found 😢</p>
51+
<button
52+
onClick={() => navigate(-1)}
53+
className="px-6 py-3 bg-purple-600 text-white rounded-lg hover:bg-purple-700"
54+
>
55+
Go Back
56+
</button>
57+
</div>
58+
);
59+
}
60+
61+
return (
62+
<div className="bg-white min-h-screen font-sans">
63+
<Navbar />
64+
65+
<div className="max-w-5xl mx-auto p-6 mt-10">
66+
<h1 className="text-4xl font-bold mb-4 text-center text-purple-700">
67+
{architect.name}
68+
</h1>
69+
<p className="text-center text-gray-600 mb-8 text-lg">
70+
{architect.specialization || "Architecture Expert"}
71+
</p>
72+
73+
<div className="flex justify-center mb-8">
74+
<img
75+
src={architect.image_url || "/placeholder-architect.jpg"}
76+
alt={architect.name}
77+
className="w-full sm:w-2/3 rounded-2xl shadow-lg"
78+
/>
79+
</div>
80+
81+
<p className="text-gray-700 leading-relaxed text-center text-lg">
82+
{architect.description || "No additional details available."}
83+
</p>
84+
</div>
85+
86+
<Footer />
87+
</div>
88+
);
89+
}

0 commit comments

Comments
 (0)