1
-
2
1
import { databases , users } from "@/models/server/config" ;
3
2
import { UserPrefs } from "@/store/Auth" ;
4
3
import React from "react" ;
@@ -7,60 +6,69 @@ import {NumberTicker} from "@/components/magicui/number-ticker";
7
6
import { answerCollection , db , questionCollection } from "@/models/name" ;
8
7
import { Query } from "node-appwrite" ;
9
8
import { Particles } from "@/components/magicui/particles" ;
9
+ import { notFound } from 'next/navigation' ;
10
10
11
11
const Page = async ( props : { params : Promise < { userId : string ; userSlug : string } > } ) => {
12
12
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
+ }
24
29
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
+ }
64
72
} ;
65
73
66
74
export default Page ;
0 commit comments