Skip to content

Commit ca4c82c

Browse files
refactor: clean up code and remove unused configurations
Remove unused Vercel configuration file, clean up imports, and simplify footer navigation links. Add error handling for user profile page to improve robustness.
1 parent 193887f commit ca4c82c

File tree

4 files changed

+59
-69
lines changed

4 files changed

+59
-69
lines changed

src/app/components/Footer.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ const Footer = () => {
1010
title: "Home",
1111
href: "/",
1212
},
13-
{
14-
title: "About",
15-
href: "/about",
16-
},
17-
{
18-
title: "Privacy Policy",
19-
href: "/privacy-policy",
20-
},
21-
{
22-
title: "Terms of Service",
23-
href: "/terms-of-service",
24-
},
2513
{
2614
title: "Questions",
2715
href: "/questions",

src/app/questions/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { databases, users } from "@/models/server/config";
32
import { answerCollection, db, voteCollection, questionCollection } from "@/models/name";
43
import { Query } from "node-appwrite";
Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { databases, users } from "@/models/server/config";
32
import { UserPrefs } from "@/store/Auth";
43
import React from "react";
@@ -7,60 +6,69 @@ import {NumberTicker} from "@/components/magicui/number-ticker";
76
import { answerCollection, db, questionCollection } from "@/models/name";
87
import { Query } from "node-appwrite";
98
import { Particles } from "@/components/magicui/particles";
9+
import { notFound } from 'next/navigation';
1010

1111
const Page = async (props: { params: Promise<{ userId: string; userSlug: string }> }) => {
1212
const params = await props.params;
13-
const [user, questions, answers] = await Promise.all([
14-
users.get<UserPrefs>(params.userId),
15-
databases.listDocuments(db, questionCollection, [
16-
Query.equal("authorId", params.userId),
17-
Query.limit(1), // for optimization
18-
]),
19-
databases.listDocuments(db, answerCollection, [
20-
Query.equal("authorId", params.userId),
21-
Query.limit(1), // for optimization
22-
]),
23-
]);
13+
try {
14+
const [user, questions, answers] = await Promise.all([
15+
users.get<UserPrefs>(params.userId),
16+
databases.listDocuments(db, questionCollection, [
17+
Query.equal("authorId", params.userId),
18+
Query.limit(1), // for optimization
19+
]),
20+
databases.listDocuments(db, answerCollection, [
21+
Query.equal("authorId", params.userId),
22+
Query.limit(1), // for optimization
23+
]),
24+
]);
25+
26+
if (!user) {
27+
notFound();
28+
}
2429

25-
return (
26-
27-
<div>
28-
<Particles
29-
className="fixed inset-0 h-full w-full"
30-
quantity={500}
31-
ease={100}
32-
color="#ffffff"
33-
refresh
34-
/>
35-
<MagicCard className="flex w-full cursor-pointer flex-col items-center justify-center overflow-hidden p-20 shadow-2xl">
36-
<div className="text-center">
37-
<h2 className="text-xl font-medium z-10">User reputation</h2>
38-
</div>
39-
<p className="whitespace-nowrap text-4xl font-mediumm">
40-
<NumberTicker value={user.prefs.reputation} />
41-
</p>
42-
</MagicCard>
43-
<MagicCard className="flex w-full cursor-pointer flex-col items-center justify-center overflow-hidden p-20 shadow-2xl">
44-
<div className="text-center">
45-
<h2 className="text-xl font-medium">Questions asked</h2>
46-
</div>
47-
<p className="whitespace-nowrap text-4xl font-medium">
48-
<NumberTicker value={questions.total} />
49-
</p>
50-
{/* <div className="pointer-events-none absolute inset-0 h-full bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" /> */}
51-
</MagicCard>
52-
<MagicCard className="flex w-full cursor-pointer flex-col items-center justify-center overflow-hidden p-20 shadow-2xl">
53-
<div className="text-center">
54-
<h2 className="text-xl font-medium">Answers given</h2>
55-
</div>
56-
<p className="whitespace-nowrap text-4xl font-medium">
57-
<NumberTicker value={answers.total} />
58-
</p>
59-
{/* /<div className="pointer-events-none absolute inset-0 h-full bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" /> */}
60-
</MagicCard>
61-
62-
</div>
63-
);
30+
return (
31+
<div>
32+
<Particles
33+
className="fixed inset-0 h-full w-full"
34+
quantity={500}
35+
ease={100}
36+
color="#ffffff"
37+
refresh
38+
/>
39+
<MagicCard className="flex w-full cursor-pointer flex-col items-center justify-center overflow-hidden p-20 shadow-2xl">
40+
<div className="text-center">
41+
<h2 className="text-xl font-medium z-10">User reputation</h2>
42+
</div>
43+
<p className="whitespace-nowrap text-4xl font-mediumm">
44+
<NumberTicker value={user.prefs.reputation} />
45+
</p>
46+
</MagicCard>
47+
<MagicCard className="flex w-full cursor-pointer flex-col items-center justify-center overflow-hidden p-20 shadow-2xl">
48+
<div className="text-center">
49+
<h2 className="text-xl font-medium">Questions asked</h2>
50+
</div>
51+
<p className="whitespace-nowrap text-4xl font-medium">
52+
<NumberTicker value={questions.total} />
53+
</p>
54+
{/* <div className="pointer-events-none absolute inset-0 h-full bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" /> */}
55+
</MagicCard>
56+
<MagicCard className="flex w-full cursor-pointer flex-col items-center justify-center overflow-hidden p-20 shadow-2xl">
57+
<div className="text-center">
58+
<h2 className="text-xl font-medium">Answers given</h2>
59+
</div>
60+
<p className="whitespace-nowrap text-4xl font-medium">
61+
<NumberTicker value={answers.total} />
62+
</p>
63+
{/* /<div className="pointer-events-none absolute inset-0 h-full bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" /> */}
64+
</MagicCard>
65+
66+
</div>
67+
);
68+
} catch (error) {
69+
console.error('Error loading user profile:', error);
70+
notFound();
71+
}
6472
};
6573

6674
export default Page;

vercel.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)